By Eris it works on MP.

main
Astoria 1 year ago
parent 3206c61a9e
commit 9811e590e7

@ -57,10 +57,10 @@ public class SteelChest extends BlockContainer{
public static void displayGui(EntityPlayer player, IInventory inventory){
if(player instanceof EntityPlayerMP) {
//Multiplayer
((IEntityPlayerMP)player).displayGUIIronChest(inventory);
((IEntityPlayerMP)player).displayGUIDiamondChest(inventory);
return;
}
//Singleplayer
((IEntityPlayerSP)player).displayGUIIronChest(inventory);
((IEntityPlayerSP)player).displayGUIDiamondChest(inventory);
}
}

@ -4,28 +4,26 @@ import net.minecraft.src.*;
public class ContainerWideChest extends Container {
private IInventory inventory;
private int numberOfRowsLower = 4;
private int numberOfRowsUpper;
public ContainerWideChest(IInventory lowerInventory, IInventory upperInventory) {
this.inventory = upperInventory;
this.numberOfRowsUpper = upperInventory.getSizeInventory() / 12;
int i = (this.numberOfRowsUpper - 4) * 18;
//Upper
for (int j = 0; j < this.numberOfRowsUpper; ++j) {
for (int i1 = 0; i1 < 12; ++i1) {
this.addSlot(new Slot(upperInventory, i1 + j * 12, -18 - 6 + i1 * 18, -36 + j * 18));
this.addSlot(new Slot(upperInventory, i1 + j * 12, 8 + i1 * 18, 8 + j * 18));
}
}
//Lower
for (int k = 0; k < 3; ++k) {
for (int j1 = 0; j1 < 9; ++j1) {
this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 3 + j1 * 18, 49 + k * 18 + i));
this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 8 + 18 + 9 + j1 * 18, 174 + k * 18));
}
}
//Taskbar
for (int l = 0; l < 9; ++l) {
this.addSlot(new Slot(lowerInventory, l, 3 + l * 18, 49 + 18 * 3 + 4 + i));
this.addSlot(new Slot(lowerInventory, l, 8 + 18 + 9 + l * 18, 232));
}
}

@ -9,24 +9,14 @@ public class GuiDiamondChest extends GuiContainer {
private IInventory lowerChestInventory;
private int inventoryRows;
public int xSize = 240;
public int ySize = 222;
public GuiDiamondChest(IInventory iinventory, IInventory iinventory1) {
super(new ContainerWideChest(iinventory, iinventory1));
this.upperChestInventory = iinventory;
this.lowerChestInventory = iinventory1;
this.field_948_f = false;
int c = 222;
int i = c - 108;
this.inventoryRows = iinventory1.getSizeInventory() / 12;
this.ySize = i + this.inventoryRows * 18;
}
@Override
protected void drawGuiContainerForegroundLayer() {
this.fontRenderer.drawString(this.lowerChestInventory.getInvName(), -24, -47, 0x404040);
this.fontRenderer.drawString(this.upperChestInventory.getInvName(), 3, 128, 0x404040);
this.ySize = 256;
this.xSize = 230;
}
@Override
@ -36,15 +26,6 @@ public class GuiDiamondChest extends GuiContainer {
this.mc.renderEngine.bindTexture(i);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
int h1 = Math.min(this.inventoryRows, 6) * 18 + 17;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, h1);
int rows = this.inventoryRows;
while (rows > 6) {
int h2 = Math.min(rows, 6) * 18;
this.drawTexturedModalRect(x, y + h1, 0, 17, this.xSize, h2);
rows -= 6;
h1 += h2;
}
this.drawTexturedModalRect(x, y + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
}

@ -29,7 +29,7 @@ public class MixinEntityPlayerMP implements IEntityPlayerMP {
public void displayGUIDiamondChest(IInventory iinventory) {
this.getNextWindowId();
NetServerHandler.logger.info(((EntityPlayerMP)(Object)this).username + " interacted with chest at (" + ((EntityPlayerMP)(Object)this).posX + ", " + ((EntityPlayerMP)(Object)this).posY + ", " + ((EntityPlayerMP)(Object)this).posZ + ")");
this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 0, iinventory.getInvName(), iinventory.getSizeInventory()));
this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 7, iinventory.getInvName(), iinventory.getSizeInventory()));
((EntityPlayerMP)(Object)this).craftingInventory = new ContainerWideChest(((EntityPlayerMP)(Object)this).inventory, iinventory);
((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId;
((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this));

@ -0,0 +1,29 @@
package net.brokenmoon.afloydironchest.mixin;
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 {
@Shadow
private Minecraft mc;
@Inject(method = "handleOpenWindow", at = @At("TAIL"))
public void injectMethod(Packet100OpenWindow packet100openwindow, CallbackInfo info) {
if (packet100openwindow.inventoryType == 7) {
TileEntityDiamondChest dchest = new TileEntityDiamondChest();
((IEntityPlayerSP)this.mc.thePlayer).displayGUIDiamondChest(dchest);
this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId;
}
}
}

@ -6,7 +6,8 @@
"mixins": [
"MixinEntityPlayerMP",
"MixinEntityPlayerSP",
"MixinTileEntity"
"MixinTileEntity",
"MixinNetClientHandler"
],
"client": [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Loading…
Cancel
Save