Skip to content

Commit

Permalink
Merge mixin from BQ3-Thermos-patch mod (#437)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <[email protected]>
  • Loading branch information
serenibyss and Dream-Master authored Nov 16, 2024
1 parent 2defc58 commit d55e395
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ public class FixesConfig {

/* ====== Minecraft fixes end ===== */

// bukkit fixes

@Config.Comment("Fix crash on Bukkit with BetterQuesting")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixBukkitBetterQuestingCrash;

// affecting multiple mods

@Config.Comment("Remove old/stale/outdated update checks.")
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 @@ -450,6 +450,10 @@ public enum Mixins {
.addMixinClasses("minecraft.MixinRendererLivingEntity_HitEffectBrightness")
.setApplyIf(() -> FixesConfig.fixHitEffectBrightness).addTargetedMod(TargetedMod.VANILLA)),

FIX_BUKKIT_PLAYER_CONTAINER(new Builder("Fix Bukkit BetterQuesting crash").setPhase(Phase.EARLY).setSide(Side.BOTH)
.addTargetedMod(TargetedMod.BUKKIT).addMixinClasses("minecraft.MixinContainerPlayer")
.setApplyIf(() -> FixesConfig.fixBukkitBetterQuestingCrash)),

MEMORY_FIXES_CLIENT(
new Builder("Memory fixes").setPhase(Phase.EARLY).setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses("memory.MixinFMLClientHandler").setApplyIf(() -> FixesConfig.enableMemoryFixes)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S2FPacketSetSlot;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ContainerPlayer.class)
public abstract class MixinContainerPlayer extends Container {

@Shadow
public IInventory craftResult;

// inject point relies on a bukkit patch:
// https://github.com/GTNewHorizons/Thermos/blob/ab8a329b10f0857cb246e5d791ede8e1f7419c63/patches/net/minecraft/inventory/ContainerPlayer.java.patch#L58
@Inject(
method = "onCraftMatrixChanged",
at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;"),
cancellable = true)
private void hodgepodge$bukkitCraftMatrixChangedProxy(CallbackInfo ci) {
if (crafters.get(0) instanceof EntityPlayerMP playerMP) {
ItemStack result = craftResult.getStackInSlot(0);
playerMP.playerNetServerHandler
.sendPacket(new S2FPacketSetSlot(playerMP.openContainer.windowId, 0, result));
}
ci.cancel();
}
}

0 comments on commit d55e395

Please sign in to comment.