Skip to content

Commit

Permalink
Add double eat fix (MC-849)
Browse files Browse the repository at this point in the history
  • Loading branch information
makamys committed Nov 25, 2021
1 parent 3818e9f commit f0b9552
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions project.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ jar {

}

jar.manifest.attributes (
'FMLAT': "${project.modid}_at.cfg",
)

apply from: "makalibs.gradle"
2 changes: 2 additions & 0 deletions src/main/java/makamys/coretweaks/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Config {
public static CloudHeightCheck cloudHeightCheck;
public static boolean fixDisplayListDelete;
public static boolean fixHeightmapRange;
public static boolean fixDoubleEat;
public static boolean forgeFastDeobfuscationRemapper;
public static float minFarPlaneDistance;

Expand Down Expand Up @@ -88,6 +89,7 @@ public static void reload() {
EnumUtils.getEnumMap(CloudHeightCheck.class).keySet().toArray(new String[]{})).getString());
fixDisplayListDelete = config.getBoolean("fixDisplayListDelete", "Bugfixes", true, "Fixes graphical glitches that happen after recovering from a game crash, caused by world renderer display lists getting deleted but never reallocated. From 1.12.");
fixHeightmapRange = config.getBoolean("fixHeightmapRange", "Bugfixes", true, "Fixes heightmap calculation not including the top layer of 16x16x16 regions, causing lighting errors (MC-7508)");
fixDoubleEat = config.getBoolean("fixDoubleEat", "Bugfixes", true, "Fixes an extra food item sometimes getting silently consumed (MC-849)");

getPendingBlockUpdates = config.getBoolean("getPendingBlockUpdates", "Optimizations", true, "Optimizes WorldServer#getPendingBlockUpdates. OptiFine also does this, but this won't have an effect when OF is present, so there's no conflict.");
clientChunkMap = config.getBoolean("clientChunkMap", "Optimizations", false, "Faster implementation of ChunkProviderClient#chunkMapping. From 1.16 (I don't know when exactly it was added). Might be a little buggy (it should only cause client-side errors though).");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/makamys/coretweaks/CoreTweaksMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import makamys.coretweaks.bugfix.DoubleEatFixer;
import makamys.coretweaks.command.CoreTweaksCommand;
import makamys.coretweaks.diagnostics.FrameProfiler;
import makamys.coretweaks.diagnostics.ServerRunTimePrinter;
Expand Down Expand Up @@ -104,6 +105,9 @@ public void init(FMLInitializationEvent event) {
if(CoreTweaks.textureLoader != null) {
FMLCommonHandler.instance().bus().register(CoreTweaks.textureLoader);
}
if(Config.fixDoubleEat) {
FMLCommonHandler.instance().bus().register(new DoubleEatFixer());
}

listeners.forEach(l -> l.onInit(event));
}
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/makamys/coretweaks/bugfix/DoubleEatFixer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package makamys.coretweaks.bugfix;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import net.minecraft.item.ItemStack;

public class DoubleEatFixer {

/*
* Using the second suggested fix in this comment (don't reset itemInUse if the items are the "same"): https://bugs.mojang.com/browse/MC-86252?focusedCommentId=298278&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-298278
* We don't ignore item damage though. Not that it matters for food.
*/
@SubscribeEvent
public void onClientTick(TickEvent.PlayerTickEvent event) {
if(event.phase == Phase.START) {
if(event.player.itemInUse != null) {
ItemStack currentItem = event.player.inventory.getCurrentItem();
if(event.player.itemInUse != currentItem && ItemStack.areItemStacksEqual(currentItem, event.player.itemInUse)) {
event.player.itemInUse = currentItem;
}
}
}
}

}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/coretweaks_at.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public net.minecraft.entity.player.EntityPlayer field_71074_e #itemInUse

0 comments on commit f0b9552

Please sign in to comment.