-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge mixin from BQ3-Thermos-patch mod (#437)
Co-authored-by: Martin Robertz <[email protected]>
- Loading branch information
1 parent
2defc58
commit d55e395
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinContainerPlayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |