You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
Java
44 lines
1.6 KiB
Java
package net.brokenmoon.afloydironchest.mixin;
|
|
|
|
import com.moandjiezana.toml.Toml;
|
|
import net.brokenmoon.afloydironchest.IronChestMain;
|
|
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
|
|
import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.src.NetClientHandler;
|
|
import net.minecraft.src.Packet100OpenWindow;
|
|
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(value = NetClientHandler.class, remap = false)
|
|
public class MixinNetClientHandler {
|
|
|
|
private int ironchest_windowid = 0;
|
|
|
|
@Shadow
|
|
private Minecraft mc;
|
|
|
|
@Inject(method = "handleOpenWindow", at = @At("TAIL"))
|
|
public void injectMethod(Packet100OpenWindow packet100openwindow, CallbackInfo info) {
|
|
if (packet100openwindow.inventoryType == getIronchest_windowid()) {
|
|
TileEntityDiamondChest dchest = new TileEntityDiamondChest();
|
|
((IEntityPlayerSP)this.mc.thePlayer).displayGUIDiamondChest(dchest);
|
|
this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId;
|
|
}
|
|
}
|
|
|
|
public int getIronchest_windowid(){
|
|
if (ironchest_windowid != 0 ){
|
|
return ironchest_windowid;
|
|
} else{
|
|
Toml toml = new Toml().read(IronChestMain.getConfig());
|
|
ironchest_windowid = toml.getLong("ids.diamondWindowID", (long)7).intValue();
|
|
return getIronchest_windowid();
|
|
}
|
|
}
|
|
|
|
}
|