Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MC-121152 #461

Merged
merged 2 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ All changes are toggleable via config files.
* **Entity Bounding Boxes:** Saves entity bounding boxes to tags to prevent breakouts and suffocation
* **Entity Desync:** Fixes entity motion desyncs most notable with arrows and thrown items
* **Entity ID:** Fixes non-functional elytra firework boosting and guardian targeting if the entity ID is 0
* **Entity Lists:** Fixes entity lists often not getting updated correctly
* **Entity Lists**
* **Chunk Updates:** Fixes chunk entity lists often not getting updated correctly
* **World Additions:** Fixes client-side memory leak where some entity ids are not set before being added to the world's entity list
* **Entity NaN:** Prevents corruption of entities caused by invalid health or damage values
* **Entity Suffocation:** Pushes entities out of blocks when growing up to prevent suffocation
* **Entity Tracker:** Fixes entity tracker to prevent client-sided desyncs when teleporting or changing dimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public abstract class UTEntityTilePistonMixin extends TileEntity
@Inject(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Ljava/lang/ThreadLocal;set(Ljava/lang/Object;)V", ordinal = 1, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
public void utUpdateEntity(float p_184322_1_, CallbackInfo ci, EnumFacing enumfacing, double d0, List list, AxisAlignedBB axisalignedbb, List list1, boolean flag, int i, Entity entity, double d1)
{
if (UTConfigBugfixes.ENTITIES.utEntityListsToggle) world.updateEntityWithOptionalForce(entity, false);
if (UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utChunkUpdatesToggle) world.updateEntityWithOptionalForce(entity, false);
}

@Surrogate
public void utUpdateEntity(float p_184322_1_, CallbackInfo ci, EnumFacing enumfacing, double d0, List list, AxisAlignedBB axisalignedbb, List list1, boolean flag, int i, Entity entity, double d1, int quark0)
{
if (UTConfigBugfixes.ENTITIES.utEntityListsToggle) world.updateEntityWithOptionalForce(entity, false);
if (UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utChunkUpdatesToggle) world.updateEntityWithOptionalForce(entity, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mod.acgaming.universaltweaks.bugfixes.entities.entitylists.mixin;

import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.Entity;
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.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

// MC-121152
// https://bugs.mojang.com/browse/MC-121152
@Mixin(value = WorldClient.class)
public class UTWorldClientMixin
{
@Inject(method = "addEntityToWorld",
slice = @Slice(from = @At(value = "HEAD"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;spawnEntity(Lnet/minecraft/entity/Entity;)Z")),
at = @At(value = "INVOKE", target = "Ljava/util/Set;add(Ljava/lang/Object;)Z", ordinal = 0, remap = false))
private void utSetIdBeforeAdd(int entityID, Entity entityToSpawn, CallbackInfo ci)
{
if (UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utWorldAdditionsToggle)
{
entityToSpawn.setEntityId(entityID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class UTWorldMixin
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setPositionNonDirty()Z", ordinal = 0))
public boolean utAlwaysLoadChunk(Entity entityIn)
{
if (UTConfigBugfixes.ENTITIES.utEntityListsToggle)
if (UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utChunkUpdatesToggle)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public static class EntitiesCategory
@Config.Name("Entity Desync")
public final EntityDesyncCategory ENTITY_DESYNC = new EntityDesyncCategory();

@Config.LangKey("cfg.universaltweaks.bugfixes.entities.entitylists")
@Config.Name("Entity Lists")
public final EntityListsCategory ENTITY_LISTS = new EntityListsCategory();

@Config.RequiresMcRestart
@Config.Name("Attack Radius")
@Config.Comment("Improves the attack radius of hostile mobs by checking the line of sight with raytracing")
Expand Down Expand Up @@ -212,11 +216,6 @@ public static class EntitiesCategory
@Config.Comment("Fixes non-functional elytra firework boosting and guardian targeting if the entity ID is 0")
public boolean utEntityIDToggle = true;

@Config.RequiresMcRestart
@Config.Name("Entity Lists")
@Config.Comment("Fixes entity lists often not getting updated correctly")
public boolean utEntityListsToggle = true;

@Config.Name("Entity NaN Values")
@Config.Comment("Prevents corruption of entities caused by invalid health or damage values")
public boolean utEntityNaNToggle = true;
Expand Down Expand Up @@ -302,6 +301,19 @@ public static class EntityDesyncCategory
"pixelmon:occupied_pokeball"
};
}

public static class EntityListsCategory
{
@Config.RequiresMcRestart
@Config.Name("Chunk Updates")
@Config.Comment("Fixes chunk entity lists often not getting updated correctly")
public boolean utChunkUpdatesToggle = true;

@Config.RequiresMcRestart
@Config.Name("World Additions")
@Config.Comment("Fixes client-side memory leak where some entity ids are not set before being added to the world's entity list")
public boolean utWorldAdditionsToggle = true;
}
}

public static class MiscCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.bugfixes.entities.desync.json", () -> UTConfigBugfixes.ENTITIES.ENTITY_DESYNC.utEntityDesyncToggle);
put("mixins.bugfixes.entities.dimensionchange.json", () -> UTConfigBugfixes.ENTITIES.utDimensionChangeToggle);
put("mixins.bugfixes.entities.entityid.json", () -> UTConfigBugfixes.ENTITIES.utEntityIDToggle);
put("mixins.bugfixes.entities.entitylists.json", () -> UTConfigBugfixes.ENTITIES.utEntityListsToggle);
put("mixins.bugfixes.entities.entitylists.json", () -> UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utChunkUpdatesToggle);
put("mixins.bugfixes.entities.horsefalling.json", () -> UTConfigBugfixes.ENTITIES.utHorseFallingToggle);
put("mixins.bugfixes.entities.maxhealth.json", () -> UTConfigBugfixes.ENTITIES.utMaxHealthToggle);
put("mixins.bugfixes.entities.minecart.json", () -> UTConfigBugfixes.ENTITIES.utMinecartAIToggle);
Expand Down Expand Up @@ -153,6 +153,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.bugfixes.blocks.blockoverlay.json", () -> UTConfigBugfixes.BLOCKS.BLOCK_OVERLAY.utBlockOverlayToggle);
put("mixins.bugfixes.blocks.miningglitch.client.json", () -> UTConfigBugfixes.BLOCKS.MINING_GLITCH.utMiningGlitchToggle);
put("mixins.bugfixes.entities.elytra.json", () -> UTConfigBugfixes.ENTITIES.utElytraDeploymentLandingToggle);
put("mixins.bugfixes.entities.entitylists.client.json", () -> UTConfigBugfixes.ENTITIES.ENTITY_LISTS.utWorldAdditionsToggle);
put("mixins.bugfixes.entities.villagermantle.json", () -> UTConfigBugfixes.ENTITIES.utVillagerMantleToggle);
put("mixins.bugfixes.misc.depthmask.json", () -> UTConfigBugfixes.MISC.utDepthMaskToggle);
put("mixins.bugfixes.misc.modelgap.json", () -> UTConfigBugfixes.MISC.MODEL_GAP.utModelGapToggle);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cfg.universaltweaks.config.world=World

cfg.universaltweaks.bugfixes.blocks.blockoverlay=Block Overlay
cfg.universaltweaks.bugfixes.entities.desync=Entity Desync
cfg.universaltweaks.bugfixes.entities.entitylists=Entity Lists
cfg.universaltweaks.bugfixes.misc.modelgap=Model Gap

cfg.universaltweaks.modintegration.abyssalcraft=AbyssalCraft
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.bugfixes.entities.entitylists.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTWorldClientMixin"]
}
Loading