Skip to content

Commit

Permalink
Merge pull request #4 from Hendrix-Shen/master
Browse files Browse the repository at this point in the history
rule `zombiePiglinTracingFix`
  • Loading branch information
FxMorin authored May 22, 2021
2 parents 6941b08 + 4d0fea6 commit b3288f5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/carpetfixes/CarpetFixesSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public class CarpetFixesSettings {
)
public static boolean comparatorUpdateFix = false;

//By Hendrix-Shen
@Rule(
desc = "Tracing the target to another dimension does not stop checking for visibility, so that a large number of necessary chunks are loaded.",
extra = "This bug may cause server crash. Use 1.13",
category = {CARPETFIXES,BUGFIX}
)
public static boolean zombiePiglinTracingFix = false;


/*
Expand All @@ -112,7 +120,7 @@ public class CarpetFixesSettings {
@Rule(
desc = "Shulkers do not teleport correctly when going through a portal.",
extra = "Fixed [MC-139265](https://bugs.mojang.com/browse/MC-139265) from 21w03a",
category = {CARPETFIXES,BACKPORT}
category = {CARPETFIXES,BUGFIX,BACKPORT}
)
public static boolean shulkerTeleportFix = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package carpetfixes.mixins.entityFixes;

import carpetfixes.CarpetFixesSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(LivingEntity.class)
public abstract class LivingEntity_VisibilityCheckMixin extends Entity {
public LivingEntity_VisibilityCheckMixin(EntityType<?> type, World world) {
super(type, world);
}

@Inject(
method = "canSee",
at = @At(
value = "HEAD"
),
cancellable = true
)
private void onVisibilityCheck(Entity entity, CallbackInfoReturnable<Boolean> cir) {
if (CarpetFixesSettings.zombiePiglinTracingFix) {
if (entity.world != this.world) {
cir.setReturnValue(false);
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/carpetfixes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"entityFixes.Entity_blockCollisionMixin",
"entityFixes.EntityAccessorMixin",
"entityFixes.ItemEntity_shulkerDroppingMixin",
"entityFixes.LivingEntity_VisibilityCheckMixin",
"entityFixes.ShulkerEntity_CustomDataMixin",
"redstoneFixes.AbstractRedstoneGateBlock_repeaterPriorityMixin",
"redstoneFixes.PistonBlock_doubleRetractionMixin",
Expand Down

0 comments on commit b3288f5

Please sign in to comment.