Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public class FixesConfig {
@Config.DefaultBoolean(true)
public static boolean fixFriendlyCreatureSounds;

@Config.Comment("Fix vanilla furnaces' burn time overflowing from long burn time fuel")
@Config.DefaultBoolean(true)
public static boolean fixFuelOverflow;

@Config.Comment("Fix Volume Slider is ineffective until reaching the lower end")
@Config.DefaultBoolean(true)
public static boolean logarithmicVolumeControl;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ public enum Mixins implements IMixins {
.setApplyIf(() -> SpeedupsConfig.speedupVanillaFurnace)
.addRequiredMod(TargetedMod.GTNHLIB)
.setPhase(Phase.EARLY)),
FIX_FUEL_OVERFLOW(new MixinBuilder("Fix vanilla furnace fuel overflow")
.addCommonMixins("minecraft.MixinTileEntityFurnace_FixFuelOverflow")
.setApplyIf(() -> FixesConfig.fixFuelOverflow)
.setPhase(Phase.EARLY)),
GAMEOVER_GUI_LOCKED_DISABLED(new MixinBuilder("Fix Gameover GUI")
.addClientMixins("minecraft.MixinGuiGameOver")
.setApplyIf(() -> FixesConfig.fixGuiGameOver)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;

import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.llamalad7.mixinextras.sugar.Local;

@Mixin(TileEntityFurnace.class)
public class MixinTileEntityFurnace_FixFuelOverflow {

/**
* Fixes BurnTime overflow with fuel over Short.MAX_VALUE BurnTime
* <p>
* Writes an Integer instead of a short for the BurnTime tag
*/
@Redirect(
method = "writeToNBT",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/nbt/NBTTagCompound;setShort(Ljava/lang/String;S)V",
ordinal = 0))
private void hodgepodge$writeBurnTime(NBTTagCompound compound, String key, short value) {
compound.setInteger(key, ((TileEntityFurnace) (Object) this).furnaceBurnTime);
}

/**
* Fixes BurnTime overflow with fuel over Short.MAX_VALUE BurnTime
* <p>
* Overwrites the getShort with the getInteger value when it attempts to write the short value
*/
@Redirect(
method = "readFromNBT",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/tileentity/TileEntityFurnace;furnaceBurnTime:I",
opcode = Opcodes.PUTFIELD))
private void hodgepodge$readBurnTime(TileEntityFurnace instance, int value,
@Local(argsOnly = true) NBTTagCompound compound) {
Comment on lines +42 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need this @Local(argsOnly = true) annotation. @Redirect will use the method's arguments for any extra parameters you declare on the injected method, so just adding a plain old NBTTagCompound compound parameter would link it to the first parameter of the containing method.

Suggested change
private void hodgepodge$readBurnTime(TileEntityFurnace instance, int value,
@Local(argsOnly = true) NBTTagCompound compound) {
private void hodgepodge$readBurnTime(TileEntityFurnace instance, int value, NBTTagCompound compound) {

instance.furnaceBurnTime = compound.getInteger("BurnTime");
}
}
Loading