Skip to content

Commit

Permalink
Merge pull request #525 from jchung01/vanilla-tweaks
Browse files Browse the repository at this point in the history
Minor improvements to vanilla tweaks
  • Loading branch information
ACGaming authored Jul 21, 2024
2 parents a86a481 + b63e5c9 commit 8e5139a
Show file tree
Hide file tree
Showing 40 changed files with 60 additions and 72 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ final def mod_dependencies = [

dependencies {
// Libraries
implementation 'com.cleanroommc:configanytime:2.0'
implementation 'com.cleanroommc:configanytime:3.0'

implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
embed 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class UniversalTweaks
public static final String MODID = Tags.MOD_ID;
public static final String NAME = Tags.MOD_NAME;
public static final String VERSION = Tags.VERSION;
public static final String DEPENDENCIES = "required-after:mixinbooter@[8.9,);required-after:configanytime;"
public static final String DEPENDENCIES = "required-after:mixinbooter@[9.0,);required-after:configanytime@[3.0,);"
+ "after:abyssalcraft;"
+ "after:actuallyadditions;"
+ "after:aoa3;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class UTBlockOverlayMixin
{
@Shadow
private WorldClient world;
public WorldClient world;

@Shadow
@Final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

// Courtesy of WaitingIdly, TheRandomLabs (RandomPatches)
@Mixin(value = RenderPlayer.class)
public abstract class UTRenderPlayerMixin
public class UTRenderPlayerMixin
{
@WrapOperation(method = "applyRotations", at = @At(value = "INVOKE", target = "Ljava/lang/Math;acos(D)D"))
@WrapOperation(method = "applyRotations(Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V", at = @At(value = "INVOKE", target = "Ljava/lang/Math;acos(D)D"))
private double utClampToPreventInvisiblePlayerOnElytra(double instance, Operation<Double> original)
{
if (!UTConfigBugfixes.ENTITIES.utFixInvisiblePlayerModelWithElytra) return original.call(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public abstract class UTSlotCraftingMixin extends Slot
{
@Shadow
private int amountCrafted;
public int amountCrafted;

public UTSlotCraftingMixin(IInventory inventoryIn, int index, int xPosition, int yPosition)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.particle.ParticleManager;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package mod.acgaming.universaltweaks.bugfixes.misc.particlespawning.mixin;

import java.util.Objects;

import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.ServerWorldEventHandler;

import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import net.minecraft.world.WorldServer;
import org.spongepowered.asm.mixin.Final;
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 org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

// MC-10369, MC-93826
// https://bugs.mojang.com/browse/MC-10369
Expand All @@ -18,16 +17,22 @@
@Mixin(ServerWorldEventHandler.class)
public abstract class UTParticleSpawningMixin
{
@Final
@Shadow
private WorldServer world;

/**
* Fixes particles not properly being spawned on the client
* @author IcarussOne
* @reason Fixes particles not properly being spawned on the client
* Based on a patch by RandomPatches
* https://github.com/TheRandomLabs/RandomPatches/blob/1.12/src/main/java/com/therandomlabs/randompatches/patch/ServerWorldEventHandlerPatch.java
*/
@Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"))
public void utSpawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int[] parameters, CallbackInfo ci)
@SuppressWarnings("OverwriteModifiers")
@Overwrite
public void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int... parameters)
{
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()) world.spawnParticle(particle, xCoord, yCoord, zCoord, 0, xSpeed, ySpeed, zSpeed, 1.0, parameters);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

// Courtesy of Sk1erLLC
@SuppressWarnings("UnresolvedMixinReference")
@Mixin(targets = "net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace")
public class UTSmoothLightingMixin
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public void callUpdateBoundingBox(int chunkX, int chunkZ, CallbackInfoReturnable
}

@Shadow
protected abstract void updateBoundingBox();
public abstract void updateBoundingBox();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Mixin(value = BlockLaserRelay.class)
public abstract class UTBlockLaserRelayMixin
{
@Inject(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isCreative()Z"))
@Inject(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isCreative()Z"), cancellable = true)
public void utOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9, CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfigMods.ACTUALLY_ADDITIONS.utLaserUpgradeVoid) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.inventory.Container;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
import net.tslat.aoa3.utils.player.PlayerDataManager.PlayerEquipment;
Expand All @@ -21,7 +21,6 @@ private void utShouldUpdateInventory(CallbackInfo ci, @Share("shouldUpdate") Loc
shouldUpdate.set(true);
}

// TODO: Replace with v2.WrapWithCondition once we depend on MixinBooter 9.x
@WrapWithCondition(method = "tickEquipment", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Container;detectAndSendChanges()V", remap = true))
private boolean utUpdateInventoryIfAllowed(Container instance, @Share("shouldUpdate") LocalBooleanRef shouldUpdate)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;

import com.elenai.elenaidodge2.api.FeathersHelper;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.PrintStream;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import funwayguy.epicsiegemod.ai.additions.AdditionDigger;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mod.acgaming.universaltweaks.mods.forestry.mixin;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import forestry.core.utils.DamageSourceForestry;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class UTContainerBackpackMixin extends Container
@ParametersAreNonnullByDefault
public boolean canInteractWith(EntityPlayer playerIn)
{
// Currently breaks hotkey functionality
// TODO: Currently breaks hotkey functionality
return this.backpackStack.getItem() instanceof IBackpack && (playerIn.getHeldItemMainhand() == this.backpackStack || playerIn.getHeldItemOffhand() == this.backpackStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Mixin(value = Config.class, remap = false)
public class UTConfigMixin
{
// MixinBooter 8.9 (MixinExtras 0.2.1) required!
@WrapOperation(method = "register", at = @At(value = "NEW", target = "()Lopenblocks/enchantments/LastStandEnchantmentsHandler;"))
private static LastStandEnchantmentsHandler utCaptureLastStandHandler(Operation<LastStandEnchantmentsHandler> original)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Mixin(value = SmelteryRenderer.class, remap = false)
public abstract class UTSmelteryRendererMixin extends SmelteryTankRenderer<TileSmeltery>
{
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lslimeknights/tconstruct/smeltery/client/SmelteryRenderer;renderFluids(Lslimeknights/tconstruct/library/smeltery/SmelteryTank;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;DDD)V", shift = At.Shift.AFTER), cancellable = true)
@Inject(method = "render(Lslimeknights/tconstruct/smeltery/tileentity/TileSmeltery;DDDFIF)V", at = @At(value = "INVOKE", target = "Lslimeknights/tconstruct/smeltery/client/SmelteryRenderer;renderFluids(Lslimeknights/tconstruct/library/smeltery/SmelteryTank;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;DDD)V", shift = At.Shift.AFTER), cancellable = true)
public void utSmelteryRenderer(@Nonnull TileSmeltery smeltery, double x, double y, double z, float partialTicks, int destroyStage, float alpha, CallbackInfo ci)
{
if (UTConfigMods.TINKERS_CONSTRUCT.utMaximumItemRendersInSmeltery < 0) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UTContainerRepairMixin
{
@Shadow
@Final
private IInventory inputSlots;
public IInventory inputSlots;

@Inject(method = "canInteractWith", at = @At("HEAD"), cancellable = true)
private void canInteractWith(EntityPlayer player, CallbackInfoReturnable<Boolean> info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.entity.boss.EntityWither;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.item.Item;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private EntityItem utDropMinecartType(EntityMinecart instance, ItemStack item, f
{
if (!UTConfigTweaks.ENTITIES.utMinecartDropsType || !(instance instanceof EntityMinecartFurnace || instance instanceof EntityMinecartChest || instance instanceof EntityMinecartTNT || instance instanceof EntityMinecartHopper))
{
return original.call(instance, instance, y);
return original.call(instance, item, y);
}
ItemStack itemstack = instance.getCartItem().copy();
if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.entity.item.EntityItem;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptions;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptions;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigGeneral;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public int utGetEventDWheel(int mouseX, int mouseY)
int wheel = Mouse.getEventDWheel();
if (wheel != 0)
{
if (wheel > 0) wheel = -1;
else if (wheel < 0) wheel = 1;
wheel = -Integer.signum(wheel);
offset(UTSmoothScrolling.getScrollStep() * wheel, true);
}
return 0;
Expand All @@ -83,7 +82,7 @@ public void scrollTo(float value, boolean animated)
@Unique
public void scrollTo(float value, boolean animated, long duration)
{
target = UTSmoothScrolling.clamp(value, func_148135_f());
target = UTSmoothScrolling.clamp(value, getMaxScroll());
if (animated)
{
start = System.currentTimeMillis();
Expand All @@ -95,18 +94,18 @@ public void scrollTo(float value, boolean animated, long duration)
@Redirect(method = "drawScreen(IIF)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/GuiScrollingList;applyScrollLimits()V"))
public void utBindScrollDistance(GuiScrollingList guiSlot)
{
if (Mouse.isButtonDown(0)) target = scrollDistance = UTSmoothScrolling.clamp(scrollDistance, func_148135_f(), 0);
if (Mouse.isButtonDown(0)) target = scrollDistance = UTSmoothScrolling.clamp(scrollDistance, getMaxScroll(), 0);
}

@Inject(method = "drawScreen(IIF)V", at = @At("HEAD"))
public void utRender(int int_1, int int_2, float delta, CallbackInfo callbackInfo)
{
float[] target = new float[] {this.target};
this.scrollDistance = UTSmoothScrolling.handleScrollingPosition(target, this.scrollDistance, this.func_148135_f(), 20f / Minecraft.getDebugFPS(), (double) this.start, (double) this.duration);
this.scrollDistance = UTSmoothScrolling.handleScrollingPosition(target, this.scrollDistance, this.getMaxScroll(), 20f / Minecraft.getDebugFPS(), (double) this.start, (double) this.duration);
this.target = target[0];
if (lastContentHeight != getContentHeight())
{
if (lastContentHeight != -1) scrollDistance = this.target = UTSmoothScrolling.clamp(this.target, func_148135_f(), 0);
if (lastContentHeight != -1) scrollDistance = this.target = UTSmoothScrolling.clamp(this.target, getMaxScroll(), 0);
lastContentHeight = getContentHeight();
}
}
Expand All @@ -118,12 +117,12 @@ public void utRenderScrollbar(int int_1, int int_2, float float_1, CallbackInfo
BufferBuilder buffer = tessellator.getBuffer();
int scrollbarPositionMaxX = this.left + this.listWidth;
int scrollbarPositionMinX = scrollbarPositionMaxX - 6;
int maxScroll = this.func_148135_f();
int maxScroll = this.getMaxScroll();
if (maxScroll > 0)
{
int height = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
height = MathHelper.clamp(height, 32, this.bottom - this.top - 8);
height = (int) (height - Math.min(this.scrollDistance < 0.0D ? (int) (-this.scrollDistance) : (this.scrollDistance > (double) this.func_148135_f() ? (int) this.scrollDistance - this.func_148135_f() : 0), height * 0.75D));
height = (int) (height - Math.min(this.scrollDistance < 0.0D ? (int) (-this.scrollDistance) : (this.scrollDistance > (double) this.getMaxScroll() ? (int) this.scrollDistance - this.getMaxScroll() : 0), height * 0.75D));
int minY = Math.min(Math.max(((int) scrollDistance) * (this.bottom - this.top - height) / maxScroll + this.top, this.top), this.bottom - height);
GlStateManager.disableTexture2D();
buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
Expand Down Expand Up @@ -161,7 +160,7 @@ public void utRenderScrollbar(int int_1, int int_2, float float_1, CallbackInfo
protected abstract void drawScreen(int mouseX, int mouseY);

@Unique
private int func_148135_f()
private int getMaxScroll()
{
int max = this.getContentHeight() - (this.bottom - this.top) + 4;
if (max < 0) max /= 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.client.gui.toasts.IToast;
import net.minecraft.client.multiplayer.ClientAdvancementManager;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.apache.logging.log4j.Logger;
import net.minecraft.advancements.AdvancementManager;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Loading

0 comments on commit 8e5139a

Please sign in to comment.