Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge mixin from BQ3-Thermos-patch mod #437

Merged
merged 2 commits into from
Nov 16, 2024
Merged
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 @@ -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();
}
}