Skip to content

Commit

Permalink
Merge pull request #356 from IcarussOne/main
Browse files Browse the repository at this point in the history
Batch of Tweaks
  • Loading branch information
ACGaming authored Jan 12, 2024
2 parents 173fc64 + 6e522cf commit a673478
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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 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 All @@ -59,6 +60,7 @@ All changes are toggleable via config files.
* **Mount Desync:** Fixes mounts and boats sometimes disappearing after dismounting
* **Packet Size:** Increases the packet size limit to account for large packets in modded environments
* **Piston Progress:** Properly saves the last state of pistons to tags
* **Portal Duplication Fix:** Fixes duplication issues that can occur when entities travel through portals
* **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms
* **Skeleton Aim:** Fixes skeletons not looking at their targets when strafing
* **Tile Entity Map:** Replaces the chunk position data table to prevent tile entity related issues
Expand Down Expand Up @@ -168,6 +170,7 @@ All changes are toggleable via config files.
* **Skip Missing Registry Entries Screen:** Automatically confirms the 'Missing Registry Entries' screen on world load
* **Sleeping Time:** Determines at which time of day sleeping is allowed in ticks (0 - 24000)
* **Smooth Scrolling:** Adds smooth scrolling to every in-game list
* **Soulbound Vexes:** Summoned vexes will also die when their summoner is killed
* **Spawn Caps:** Sets maximum spawning limits for different entity types
* **Super Hot Torch:** Enables one-time ignition of entities by hitting them with a torch
* **Stronghold Replacement:** Replaces stronghold generation with a safer variant
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package mod.acgaming.universaltweaks.bugfixes.entities.entitylists.mixin;

import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityPiston;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
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.Surrogate;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

// MC-108469
// https://bugs.mojang.com/browse/MC-108469
// Courtesy of mrgrim
@Mixin(TileEntityPiston.class)
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);
}

@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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package mod.acgaming.universaltweaks.bugfixes.entities.entitylists.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;

// MC-108469
// https://bugs.mojang.com/browse/MC-108469
// Courtesy of mrgrim
@Mixin(World.class)
public abstract class UTWorldMixin
{
@Redirect(method = "updateEntityWithOptionalForce",
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(II)Lnet/minecraft/world/chunk/Chunk;", ordinal = 0),
to = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunk(II)Lnet/minecraft/world/chunk/Chunk;", ordinal = 1)),
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setPositionNonDirty()Z", ordinal = 0))
public boolean utAlwaysLoadChunk(Entity entityIn)
{
if (UTConfigBugfixes.ENTITIES.utEntityListsToggle)
{
return true;
} else
{
// Returns false
return entityIn.setPositionNonDirty();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package mod.acgaming.universaltweaks.bugfixes.world.portalduplicationfixes;

import org.apache.logging.log4j.Level;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;

// Courtesy of fonnymunkey
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID)
public class UTPortalDuplicationFix
{
@SubscribeEvent
public static void dimensionChangeEvent(EntityTravelToDimensionEvent event)
{
if (event.getEntity().world.isRemote || !(UTConfigBugfixes.WORLD.utPortalDuplicationFixToggle)) return;
if (event.getEntity() instanceof EntityLiving && !(event.getEntity() instanceof EntityPlayer))
{
EntityLiving entity = (EntityLiving) event.getEntity();

if (entity.isDead || !entity.isEntityAlive() || entity.getHealth() <= 0)
{
event.setCanceled(true);
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.log(Level.WARN, "Possible attempted dupe at X: " + entity.posX + " Y: " + entity.posY + " Z: " + entity.posZ + " Entity Name: " + entity.getName());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ 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 @@ -345,6 +350,11 @@ public static class WorldCategory
@Config.Comment("Fixes invisible chunks in edge cases (small enclosed rooms at chunk borders)")
public boolean utFrustumCullingToggle = true;

@Config.RequiresMcRestart
@Config.Name("Portal Duplication Fix")
@Config.Comment("Fixes duplication issues that can occur when entities travel through portals")
public boolean utPortalDuplicationFixToggle = true;

@Config.RequiresMcRestart
@Config.Name("Tile Entity Map")
@Config.Comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ public static class EntitiesCategory
@Config.RangeDouble(min = 0.0D, max = 1.0D)
public double utRabbitToastChance = 0.0D;

@Config.RequiresMcRestart
@Config.Name("Soulbound Vexes")
@Config.Comment("Summoned vexes will also die when their summoner is killed")
public boolean utSoulboundVexesToggle = true;

public static class AttributesCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.bugfixes.entities.dimensionchange.json");
configs.add("mixins.bugfixes.entities.disconnectdupe.json");
configs.add("mixins.bugfixes.entities.entityid.json");
configs.add("mixins.bugfixes.entities.entitylists.json");
configs.add("mixins.bugfixes.entities.horsefalling.json");
configs.add("mixins.bugfixes.entities.maxhealth.json");
configs.add("mixins.bugfixes.entities.mount.json");
Expand Down Expand Up @@ -345,6 +346,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle;
case "mixins.bugfixes.entities.entityid.json":
return UTConfigBugfixes.ENTITIES.utEntityIDToggle;
case "mixins.bugfixes.entities.entitylists.json":
return UTConfigBugfixes.ENTITIES.utEntityListsToggle;
case "mixins.bugfixes.entities.horsefalling.json":
return UTConfigBugfixes.ENTITIES.utHorseFallingToggle;
case "mixins.bugfixes.entities.maxhealth.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package mod.acgaming.universaltweaks.tweaks.entities.soulboundvexes;

import org.apache.logging.log4j.Level;

import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityVex;
import net.minecraft.util.DamageSource;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;

@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID)
public class UTSoulboundVexes
{
@SubscribeEvent
public static void soulboundVexesEvent(LivingUpdateEvent event)
{
if (!(UTConfigTweaks.ENTITIES.utSoulboundVexesToggle)) return;

if (event.getEntity() instanceof EntityVex)
{
Entity summoner = ((EntityVex) event.getEntity()).getOwner();

if (summoner != null && summoner.isDead && !(event.getEntity().isDead))
{
event.getEntity().attackEntityFrom(DamageSource.GENERIC.setDamageIsAbsolute().setDamageBypassesArmor(), event.getEntityLiving().getMaxHealth());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static List<String> obsoleteModsMessage()
if (Loader.isModLoaded("parry") && UTConfigTweaks.ITEMS.PARRY.utParryToggle) messages.add("Shield Parry");
if (Loader.isModLoaded("pathundergates") && UTConfigTweaks.BLOCKS.utLenientPathsToggle) messages.add("Path Under Gates");
if (Loader.isModLoaded("pickupnotifier") && UTConfigTweaks.MISC.PICKUP_NOTIFICATION.utPickupNotificationToggle) messages.add("Pick Up Notifier");
if (Loader.isModLoaded("portaldupebegone") && UTConfigBugfixes.WORLD.utPortalDuplicationFixToggle) messages.add("PortalDupeBegone");
if (Loader.isModLoaded("preventghost") && UTConfigBugfixes.BLOCKS.utMiningGlitchToggle) messages.add("Prevent Ghost Blocks");
if (Loader.isModLoaded("quickleafdecay") && UTConfigTweaks.BLOCKS.utLeafDecayToggle) messages.add("Quick Leaf Decay");
if (Loader.isModLoaded("rallyhealth") && UTConfigTweaks.ENTITIES.RALLY_HEALTH.utRallyHealthToggle) messages.add("Rally Health");
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 @@ -88,6 +88,7 @@ cfg.universaltweaks.tweaks.blocks.overhaulbeacon=Overhaul Beacon
cfg.universaltweaks.tweaks.blocks.sapling=Sapling Behavior
cfg.universaltweaks.tweaks.entities.attributes=Attributes
cfg.universaltweaks.tweaks.entities.betterburning=Better Burning
cfg.universaltweaks.tweaks.entities.chickenshedding=Chicken Shedding
cfg.universaltweaks.tweaks.entities.collisiondamage=Collision Damage
cfg.universaltweaks.tweaks.entities.creeperconfetti=Creeper Confetti
cfg.universaltweaks.tweaks.entities.damagevelocity=Damage Velocity
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.bugfixes.entities.entitylists.json
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",
"mixins": ["UTEntityTilePistonMixin", "UTWorldMixin"]
}

0 comments on commit a673478

Please sign in to comment.