Skip to content

Commit

Permalink
Refactor, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jan 20, 2024
1 parent 767f210 commit 30d085f
Show file tree
Hide file tree
Showing 66 changed files with 151 additions and 155 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Available for MC 1.12.2](https://img.shields.io/badge/Available%20for-MC%201.12.2-3498db.svg?labelColor=34495e&style=for-the-badge)
![License LGPL-3.0](https://img.shields.io/github/license/ACGaming/UniversalTweaks?labelColor=34495e&color=3498db&style=for-the-badge)
[![Stars](https://img.shields.io/github/stars/ACGaming/UniversalTweaks?labelColor=34495e&color=3498db&style=for-the-badge)](https://github.com/ACGaming/UniversalTweaks/stargazers)
[![Superseded Mods](https://img.shields.io/badge/Superseded%20Mods-96-3498db.svg?labelColor=34495e&style=for-the-badge)](https://www.curseforge.com/minecraft/mc-mods/universal-tweaks/relations/dependencies?page=1&type=Incompatible)
[![Superseded Mods](https://img.shields.io/badge/Superseded%20Mods-97-3498db.svg?labelColor=34495e&style=for-the-badge)](https://www.curseforge.com/minecraft/mc-mods/universal-tweaks/relations/dependencies?page=1&type=Incompatible)

# UNIVERSAL TWEAKS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import mod.acgaming.universaltweaks.tweaks.items.useduration.UTCustomUseDuration;
import mod.acgaming.universaltweaks.tweaks.misc.armorcurve.UTArmorCurve;
import mod.acgaming.universaltweaks.tweaks.misc.endportal.UTEndPortalParallax;
import mod.acgaming.universaltweaks.tweaks.misc.incurablepotions.UTIncurablePotions;
import mod.acgaming.universaltweaks.tweaks.misc.gui.lanserverproperties.UTLanServerProperties;
import mod.acgaming.universaltweaks.tweaks.misc.incurablepotions.UTIncurablePotions;
import mod.acgaming.universaltweaks.tweaks.misc.loadsound.UTLoadSound;
import mod.acgaming.universaltweaks.tweaks.misc.pickupnotification.UTPickupNotificationOverlay;
import mod.acgaming.universaltweaks.tweaks.misc.swingthroughgrass.UTSwingThroughGrassLists;
Expand Down Expand Up @@ -208,7 +208,7 @@ public void onLoadComplete(FMLLoadCompleteEvent event)
{
for (String line : UTObsoleteModsHandler.obsoleteModsMessage())
{
if (!line.equals("")) UniversalTweaks.LOGGER.warn(line);
if (!line.isEmpty()) UniversalTweaks.LOGGER.warn(line);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package mod.acgaming.universaltweaks.bugfixes.blocks.piston.pistonretraction.mixin;

import static net.minecraft.block.BlockPistonBase.EXTENDED;
package mod.acgaming.universaltweaks.bugfixes.blocks.piston.retraction.mixin;

import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.objectweb.asm.Opcodes;
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.CallbackInfo;

import static net.minecraft.block.BlockPistonBase.EXTENDED;

// MC-88959
// https://bugs.mojang.com/browse/MC-88959
// Courtesy of mrgrim
@Mixin(BlockPistonBase.class)
public abstract class UTPistonBaseBlockMixin
{
@Inject(method = "checkForMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V", ordinal = 1))
private void onPistonDepower(World worldIn, BlockPos pos, IBlockState state, CallbackInfo ci)
{
private void utOnPistonDepower(World worldIn, BlockPos pos, IBlockState state, CallbackInfo ci)
{
if (UTConfigBugfixes.BLOCKS.utPistonRetractionToggle)
{
{
worldIn.setBlockState(pos, state.withProperty(EXTENDED, false), 2);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mod.acgaming.universaltweaks.bugfixes.blocks.piston.mixin;
package mod.acgaming.universaltweaks.bugfixes.blocks.piston.tile.mixin;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UTEntityAITasksMixin
@Mutable
@Shadow
@Final
private Set<EntityAITasks.EntityAITaskEntry> executingTaskEntries;
public Set<EntityAITasks.EntityAITaskEntry> executingTaskEntries;

@Inject(method = "<init>", at = @At(value = "TAIL"))
public void utEntityAITasks(Profiler profilerIn, CallbackInfo ci)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Mixin(EntityMob.class)
public abstract class UTAttackRadiusMixin extends EntityCreature
{
public UTAttackRadiusMixin(World worldIn)
protected UTAttackRadiusMixin(World worldIn)
{
super(worldIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Mixin(EntityLivingBase.class)
public abstract class UTDeathTimeMixin extends Entity
{
public UTDeathTimeMixin(World worldIn)
protected UTDeathTimeMixin(World worldIn)
{
super(worldIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class UTDestroyPacketMixin extends EntityPlayer
@Final
private List<Integer> entityRemoveQueue;

public UTDestroyPacketMixin(World worldIn, GameProfile gameProfileIn)
protected UTDestroyPacketMixin(World worldIn, GameProfile gameProfileIn)
{
super(worldIn, gameProfileIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class UTDimensionChangeMixin extends EntityPlayer
@Shadow
public NetHandlerPlayServer connection;

public UTDimensionChangeMixin(World worldIn, GameProfile gameProfileIn)
protected UTDimensionChangeMixin(World worldIn, GameProfile gameProfileIn)
{
super(worldIn, gameProfileIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Mixin(EntityPlayerSP.class)
public abstract class UTElytraDeploymentMixin extends AbstractClientPlayer
{
public UTElytraDeploymentMixin(World worldIn, GameProfile playerProfile)
protected UTElytraDeploymentMixin(World worldIn, GameProfile playerProfile)
{
super(worldIn, playerProfile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Mixin(AbstractHorse.class)
public abstract class UTHorseFallingMixin extends EntityAnimal
{
public UTHorseFallingMixin(World worldIn)
protected UTHorseFallingMixin(World worldIn)
{
super(worldIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -20,8 +19,8 @@ public abstract class UTMinecartAIMixin
{
// TODO: Investigate AI code (?)
@Redirect(method = "moveAlongTrack", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;moveForward:F", opcode = Opcodes.GETFIELD, ordinal = 0),
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;getPassengers()Ljava/util/List;", ordinal = 1),
to = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;shouldDoRailFunctions()Z", remap = false)))
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;getPassengers()Ljava/util/List;", ordinal = 1),
to = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;shouldDoRailFunctions()Z", remap = false)))
private float disableMobControl(EntityLivingBase entityIn)
{
if (UTConfigBugfixes.ENTITIES.utMinecartAIToggle && !(entityIn instanceof EntityPlayer))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class UTMountDesyncMixin extends Entity
@Shadow
public NetHandlerPlayServer connection;

public UTMountDesyncMixin(World worldIn)
protected UTMountDesyncMixin(World worldIn)
{
super(worldIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Mixin(EntityPlayer.class)
public abstract class UTSaturationMixin extends EntityLivingBase
{
public UTSaturationMixin(World worldIn)
protected UTSaturationMixin(World worldIn)
{
super(worldIn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand Down Expand Up @@ -44,7 +45,6 @@ public abstract class UTSuffocationMixin
public void utOnSetSize(float width, float height, CallbackInfo ci)
{
if (!UTConfigBugfixes.ENTITIES.utEntitySuffocationToggle) return;
//if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSuffocationMixin ::: Set entity size");
if (width != this.width || height != this.height)
{
float f = this.width;
Expand All @@ -58,6 +58,7 @@ public void utOnSetSize(float width, float height, CallbackInfo ci)
ci.cancel();
}

@Unique
public void pushEntityOutOfBlocks(AxisAlignedBB oldHitbox)
{
// Pass "null" in first argument to only get _possible_ block collisions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Mixin(WorldServer.class)
public abstract class UTWorldServerMixin extends World implements IWorldServer
{
public UTWorldServerMixin(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn)
protected UTWorldServerMixin(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn)
{
super(saveHandlerIn, info, DimensionType.getById(dimensionId).createDimension(), profilerIn, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public void utSpawnParticle(int particleID, boolean ignoreRange, double xCoord,
{
EnumParticleTypes particle = Objects.requireNonNull(EnumParticleTypes.getParticleFromId(particleID));
if (particle == EnumParticleTypes.SPELL_MOB || particle == EnumParticleTypes.SPELL_MOB_AMBIENT || !UTConfigBugfixes.MISC.utParticleSpawningToggle) return;
if (parameters.length == particle.getArgumentCount())
((UTServerWorldEventHandlerAccessor) this).getWorld().spawnParticle(particle, xCoord, yCoord, zCoord, 0, xSpeed, ySpeed, zSpeed, 1.0, parameters);
if (parameters.length == particle.getArgumentCount()) ((UTServerWorldEventHandlerAccessor) this).getWorld().spawnParticle(particle, xCoord, yCoord, zCoord, 0, xSpeed, ySpeed, zSpeed, 1.0, parameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
import net.minecraft.client.resources.I18n;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

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

// MC-130847
// https://bugs.mojang.com/browse/MC-130847
// Courtesy of fonnymunkey
Expand All @@ -25,18 +23,14 @@ public class UTPotionAmplifierMixin
{
private int amplifier = 0;

@Inject(
method = "drawActivePotionEffects",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getTextureManager()Lnet/minecraft/client/renderer/texture/TextureManager;"),
locals = LocalCapture.CAPTURE_FAILHARD
)
public void rlmixins_vanillaInventoryEffectRenderer_drawActivePotionEffects_Inject(CallbackInfo ci, int i, int j, int k, Collection collection, int l, Iterator var6, PotionEffect potioneffect, Potion potion)
@Inject(method = "drawActivePotionEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getTextureManager()Lnet/minecraft/client/renderer/texture/TextureManager;"), locals = LocalCapture.CAPTURE_FAILHARD)
public void utDrawActivePotionEffectsInject(CallbackInfo ci, int i, int j, int k, Collection collection, int l, Iterator var6, PotionEffect potioneffect, Potion potion)
{
this.amplifier = potioneffect.getAmplifier();
}

@ModifyArg(method = "drawActivePotionEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I", ordinal = 0))
public String rlmixins_vanillaInventoryEffectRenderer_drawActivePotionEffects_Modify(String text)
public String utDrawActivePotionEffectsModifyArg(String text)
{
if (this.amplifier > 3 && this.amplifier < 10) text += " " + I18n.format("enchantment.level." + (this.amplifier + 1));
if (this.amplifier >= 10 && this.amplifier < 128) text += " " + (this.amplifier + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -28,22 +29,27 @@
@Mixin(AnvilChunkLoader.class)
public abstract class UTChunkSavingMixin
{
@Unique
private final Map<ChunkPos, NBTTagCompound> chunksInWrite = new HashMap<>();

@Shadow
@Final
public File chunkSaveLocation;

@Shadow
@Final
private Map<ChunkPos, NBTTagCompound> chunksToSave;

@Shadow
private boolean flushing;

@Shadow
protected abstract void writeChunkData(ChunkPos pos, NBTTagCompound compound) throws IOException;
public abstract void writeChunkData(ChunkPos pos, NBTTagCompound compound) throws IOException;

synchronized private void queueChunkToSave(ChunkPos pos, NBTTagCompound data) {chunksToSave.put(pos, data);}
@Unique
private synchronized void queueChunkToSave(ChunkPos pos, NBTTagCompound data) {chunksToSave.put(pos, data);}

synchronized private Map.Entry<ChunkPos, NBTTagCompound> fetchChunkToWrite()
private synchronized Map.Entry<ChunkPos, NBTTagCompound> fetchChunkToWrite()
{
if (chunksToSave.isEmpty()) return null;
Set<Map.Entry<ChunkPos, NBTTagCompound>> entrySet = chunksToSave.entrySet();
Expand All @@ -54,19 +60,22 @@ synchronized private Map.Entry<ChunkPos, NBTTagCompound> fetchChunkToWrite()
return entry;
}

synchronized private void retireChunkToWrite(ChunkPos pos, NBTTagCompound data)
@Unique
private synchronized void retireChunkToWrite(ChunkPos pos, NBTTagCompound data)
{
chunksInWrite.remove(pos);
}

synchronized private NBTTagCompound reloadChunkFromSaveQueues(ChunkPos pos)
@Unique
private synchronized NBTTagCompound reloadChunkFromSaveQueues(ChunkPos pos)
{
NBTTagCompound data = chunksToSave.get(pos);
if (data != null) return data;
return chunksInWrite.get(pos);
}

synchronized private boolean chunkExistInSaveQueues(ChunkPos pos)
@Unique
private synchronized boolean chunkExistInSaveQueues(ChunkPos pos)
{
return chunksToSave.containsKey(pos) || chunksInWrite.containsKey(pos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UTTileEntityMapMixin
@Mutable
@Shadow
@Final
private Map<BlockPos, TileEntity> tileEntities;
public Map<BlockPos, TileEntity> tileEntities;

@Redirect(method = "<init>(Lnet/minecraft/world/World;II)V", at = @At(value = "FIELD", target = "Lnet/minecraft/world/chunk/Chunk;tileEntities:Ljava/util/Map;"))
public void utTileEntityMap(Chunk chunk, Map<BlockPos, TileEntity> map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.gen.structure.StructureStart;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -17,12 +16,12 @@
@Mixin(StructureStart.class)
public abstract class UTWitchHutMixin
{
@Shadow
protected abstract void updateBoundingBox();

@Inject(method = "writeStructureComponentsToNBT", at = @At(value = "CONSTANT", args = "stringValue=Children", ordinal = 0))
public void callUpdateBoundingBox(int chunkX, int chunkZ, CallbackInfoReturnable<NBTTagCompound> ci)
{
if (UTConfigBugfixes.WORLD.utWitchStructuresToggle) this.updateBoundingBox();
}

@Shadow
protected abstract void updateBoundingBox();
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public static class BlocksCategory
@Config.Name("Piston Progress")
@Config.Comment("Properly saves the last state of pistons to tags")
public boolean utPistonTileToggle = true;

@Config.RequiresMcRestart
@Config.Name("Piston Retraction")
@Config.Comment("Improves retraction behavior on double piston extenders")
public boolean utPistonRetractionToggle = true;
public boolean utPistonRetractionToggle = false;

@Config.RequiresMcRestart
@Config.Name("Sleep Resets Weather")
Expand Down Expand Up @@ -232,7 +232,7 @@ public static class EntitiesCategory
@Config.Name("Max Player Health")
@Config.Comment("Corrects maximum player health on joining by setting the last saved health value")
public boolean utMaxHealthToggle = true;

@Config.RequiresMcRestart
@Config.Name("Minecart AI")
@Config.Comment("Fixes non-player entities being able to control minecarts")
Expand Down Expand Up @@ -322,7 +322,7 @@ public static class MiscCategory
@Config.Name("Particle Spawning")
@Config.Comment("Fixes various particle types not showing up on the client")
public boolean utParticleSpawningToggle = true;

@Config.RequiresMcRestart
@Config.Name("Potion Amplifier Visibility")
@Config.Comment("Fixes potion effects not displaying their level above 'IV'")
Expand Down Expand Up @@ -385,7 +385,7 @@ public static class WorldCategory
@Config.Name("Portal Traveling Dupe")
@Config.Comment("Fixes duplication issues that can occur when entities travel through portals")
public boolean utPortalTravelingDupeToggle = true;

@Config.RequiresMcRestart
@Config.Name("Witch Huts")
@Config.Comment("Fixes witch hut structure data not accounting for the height it is generated at")
Expand Down
Loading

0 comments on commit 30d085f

Please sign in to comment.