Skip to content

Commit 469cace

Browse files
committed
Crafted Item Statistics Bugfix
1 parent 30f1fb1 commit 469cace

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ All changes are toggleable via config files.
2727
* **Chunk Saving:** Fixes loading of outdated chunks to prevent duplications, deletions and data corruption
2828
* **Comparator Timing:** Fixes inconsistent delays of comparators to prevent redstone timing issues
2929
* **Concurrent Entity AI Tasks:** Replaces linked entity AI task sets with concurrent sets to avoid mod exception concerning entity AI
30+
* **Crafted Item Statistics:** Fixes crafted item statistics not increasing correctly when items are crafted with shift-click or drop methods
3031
* **Death Time:** Fixes corrupted entities exceeding the allowed death time
3132
* **Depth Mask:** Fixes entity and particle rendering issues by enabling depth buffer writing
3233
* **Destroy Entity Packets:** Fixes lag caused by dead entities by sending additional packets when the player is not alive
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package mod.acgaming.universaltweaks.bugfixes.misc.crafteditemstatistics.mixin;
2+
3+
import net.minecraft.inventory.IInventory;
4+
import net.minecraft.inventory.Slot;
5+
import net.minecraft.inventory.SlotCrafting;
6+
import net.minecraft.item.ItemStack;
7+
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13+
14+
// MC-65198, MC-161869
15+
// https://bugs.mojang.com/browse/MC-65198
16+
// https://bugs.mojang.com/browse/MC-161869
17+
// Courtesy of mrgrim
18+
@Mixin(SlotCrafting.class)
19+
public abstract class UTSlotCraftingMixin extends Slot
20+
{
21+
@Shadow
22+
private int amountCrafted;
23+
24+
public UTSlotCraftingMixin(IInventory inventoryIn, int index, int xPosition, int yPosition)
25+
{
26+
super(inventoryIn, index, xPosition, yPosition);
27+
}
28+
29+
@Inject(method = "decrStackSize", at = @At("HEAD"), cancellable = true)
30+
private void utFixCraftingStats(int amount, CallbackInfoReturnable<ItemStack> cir)
31+
{
32+
if (UTConfigBugfixes.MISC.utCraftedItemStatisticsToggle)
33+
{
34+
ItemStack ret = super.decrStackSize(amount);
35+
this.amountCrafted += ret.getCount();
36+
37+
cir.setReturnValue(ret);
38+
}
39+
}
40+
}

src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class UTPlayerMenuObjectMixin
2424
private GameProfile profile;
2525

2626
@Redirect(method = "renderIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V"))
27-
private void redirectbindTexture(TextureManager textureManager, ResourceLocation resource)
27+
private void utRedirectBindTexture(TextureManager textureManager, ResourceLocation resource)
2828
{
2929
if (UTConfigBugfixes.MISC.utSpectatorMenuToggle)
3030
{

src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java

+5
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ public static class MiscCategory
303303
@Config.Name("Blast Protection Knockback")
304304
@Config.Comment("Fixes the blast protection enchantment not reducing knockback from explosions except at very high levels")
305305
public boolean utBlastProtectionKnockbackToggle = false;
306+
307+
@Config.RequiresMcRestart
308+
@Config.Name("Crafted Item Statistics")
309+
@Config.Comment("Fixes crafted item statistics not increasing correctly when items are crafted with shift-click or drop methods")
310+
public boolean utCraftedItemStatisticsToggle = true;
306311

307312
@Config.RequiresMcRestart
308313
@Config.Name("Depth Mask")

src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public List<String> getMixinConfigs()
179179
configs.add("mixins.bugfixes.entities.skeletonaim.json");
180180
configs.add("mixins.bugfixes.entities.suffocation.json");
181181
configs.add("mixins.bugfixes.entities.tracker.json");
182+
configs.add("mixins.bugfixes.misc.crafteditemstatistics.json");
182183
configs.add("mixins.bugfixes.misc.enchantment.json");
183184
configs.add("mixins.bugfixes.misc.packetsize.json");
184185
configs.add("mixins.bugfixes.misc.particlespawning.json");
@@ -355,6 +356,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
355356
return UTConfigBugfixes.BLOCKS.utPistonRetractionToggle;
356357
case "mixins.bugfixes.blocks.bed.json":
357358
return UTConfigBugfixes.BLOCKS.utSleepResetsWeatherToggle;
359+
case "mixins.bugfixes.misc.crafteditemstatistics.json":
360+
return UTConfigBugfixes.MISC.utCraftedItemStatisticsToggle;
358361
case "mixins.bugfixes.misc.enchantment.json":
359362
return UTConfigBugfixes.MISC.utBlastProtectionKnockbackToggle;
360363
case "mixins.bugfixes.misc.packetsize.json":
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"package": "mod.acgaming.universaltweaks.bugfixes.misc.crafteditemstatistics.mixin",
3+
"refmap": "universaltweaks.refmap.json",
4+
"minVersion": "0.8",
5+
"compatibilityLevel": "JAVA_8",
6+
"mixins": ["UTSlotCraftingMixin"]
7+
}

0 commit comments

Comments
 (0)