diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-12-30 01:48:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 01:48:09 +0000 |
commit | 5af823e80a611090216375fecd3794d345446830 (patch) | |
tree | c54a19977b4a25cb86f54394eb9711aaf268efe3 /src/Java/gtPlusPlus/core/container | |
parent | a731e939c6b9a70ac9fd444dbf06243f63f29c06 (diff) | |
parent | cc825179dce70a5f2c4a13730639e3300243e21a (diff) | |
download | GT5-Unofficial-5af823e80a611090216375fecd3794d345446830.tar.gz GT5-Unofficial-5af823e80a611090216375fecd3794d345446830.tar.bz2 GT5-Unofficial-5af823e80a611090216375fecd3794d345446830.zip |
Merge pull request #525 from alkcorp/DevTop
+ 6 Months of work, let's get the ball rolling.
Diffstat (limited to 'src/Java/gtPlusPlus/core/container')
3 files changed, 402 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_PestKiller.java b/src/Java/gtPlusPlus/core/container/Container_PestKiller.java new file mode 100644 index 0000000000..2f25c5aace --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_PestKiller.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.container; + +import gregtech.api.gui.GT_Slot_Render; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryPestKiller; +import gtPlusPlus.core.slots.SlotGeneric; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; + +public class Container_PestKiller extends Container { + + public TileEntityPestKiller tile_entity; + public final InventoryPestKiller inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 3; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_PestKiller(final InventoryPlayer inventory, final TileEntityPestKiller te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + te.openInventory(); + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + int o = 0; + + int aSlotX = 134; + + this.addSlotToContainer(new SlotGeneric(this.inventoryChest, o++, aSlotX, 10)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, aSlotX, 60)); + addSlotToContainer(new GT_Slot_Render(tile_entity, o++, aSlotX, 35)); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + } + + public FluidStack getFluidOfStoredTank() { + if (tile_entity != null) { + if (tile_entity.getTank() != null) { + return tile_entity.getTank().getFluid(); + } + } + return null; + } + + public int getFluidStoredAmount() { + FluidStack f = getFluidOfStoredTank(); + return f == null ? 0 : f.amount; + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + boolean fluid = false; + if (aSlotIndex == 2) { + fluid = true; + } + if (!fluid) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + else { + return null; + } + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockPestKiller) { + return false; + } + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java new file mode 100644 index 0000000000..cbd08c2cca --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java @@ -0,0 +1,246 @@ +package gtPlusPlus.core.container; + +import java.util.Iterator; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_RoundRobinator; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Container_RoundRobinator extends Container { + + public TileEntityRoundRobinator tile_entity; + public final Inventory_RoundRobinator inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final boolean[] mActiveData = new boolean[] {false, false, false, false}; + + public static int mStorageSlotNumber = 4; // Number of slots in storage area + public static int mInventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int mFullSlotNumber = mInventorySlotNumber + mStorageSlotNumber; // All + // slots + + public Container_RoundRobinator(final InventoryPlayer inventory, final TileEntityRoundRobinator te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + boolean [] aTemp = te.getActiveSides(); + if (aTemp != null && aTemp.length == 4) { + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + } + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + int xStart = 134; + int yStart = 32; + + try { + //0 + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart, yStart+17)); + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, xStart+18, yStart+17)); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + this.detectAndSendChanges(); + + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if (aSlotIndex < 4) { + this.tile_entity.toggleSide(aSlotIndex+2); + //Logger.INFO("Toggling side: "+(aSlotIndex+2)+" | Active: "+this.tile_entity.getSideActive(aSlotIndex+2)+" | Data:"+this.tile_entity.getDataString()); + } + } + return GT_Values.NI; + //return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockRoundRobinator) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + + + public final void addCraftingToCrafters(ICrafting par1ICrafting) { + try { + super.addCraftingToCrafters(par1ICrafting); + } catch (Throwable var3) { + var3.printStackTrace(); + } + } + + public final void removeCraftingFromCrafters(ICrafting par1ICrafting) { + try { + super.removeCraftingFromCrafters(par1ICrafting); + } catch (Throwable var3) { + var3.printStackTrace(); + } + } + + public final void detectAndSendChanges() { + try { + super.detectAndSendChanges(); + detectAndSendChangesEx(); + } catch (Throwable var2) { + var2.printStackTrace(); + } + } + + public final void updateProgressBar(int par1, int par2) { + try { + super.updateProgressBar(par1, par2); + updateProgressBarEx(par1, par2); + } catch (Throwable var4) { + var4.printStackTrace(); + } + } + + + public int mSide_1 = 0; + public int mSide_2 = 0; + public int mSide_3 = 0; + public int mSide_4 = 0; + public int mTier = 1; + public int mTickRate = 50; + + private int oSide_1 = 0; + private int oSide_2 = 0; + private int oSide_3 = 0; + private int oSide_4 = 0; + private int oTier = 1; + private int oTickRate = 50; + + private int mTimer = 0; + + + + public void detectAndSendChangesEx() { + super.detectAndSendChanges(); + if (!this.tile_entity.getWorldObj().isRemote) { + boolean [] aTemp = tile_entity.getActiveSides(); + for (int i=0;i<4;i++) { + mActiveData[i] = aTemp[i]; + } + this.mSide_1 = aTemp[0] ? 1 : 0; + this.mSide_2 = aTemp[1] ? 1 : 0; + this.mSide_3 = aTemp[2] ? 1 : 0; + this.mSide_4 = aTemp[3] ? 1 : 0; + this.mTier = this.tile_entity.getTier(); + this.mTickRate = this.tile_entity.getTickRate(); + ++this.mTimer; + Iterator var2 = this.crafters.iterator(); + + while (true) { + ICrafting var1; + do { + if (!var2.hasNext()) { + this.oSide_1 = this.mSide_1; + this.oSide_2 = this.mSide_2; + this.oSide_3 = this.mSide_3; + this.oSide_4 = this.mSide_4; + this.oTier = this.mTier; + this.oTickRate = this.mTickRate; + return; + } + var1 = (ICrafting) var2.next(); + if (this.mTimer % 500 == 10 || this.oSide_1 != this.mSide_1) { + var1.sendProgressBarUpdate(this, 2, this.mSide_1); + } + if (this.mTimer % 500 == 10 || this.oSide_2 != this.mSide_2) { + var1.sendProgressBarUpdate(this, 4, this.mSide_2); + } + if (this.mTimer % 500 == 10 || this.oSide_3 != this.mSide_3) { + var1.sendProgressBarUpdate(this, 6, this.mSide_3); + } + if (this.mTimer % 500 == 10 || this.oSide_4 != this.mSide_4) { + var1.sendProgressBarUpdate(this, 8, this.mSide_4); + } + if (this.mTimer % 500 == 10 || this.oTier != this.mTier) { + var1.sendProgressBarUpdate(this, 10, this.mTier); + } + if (this.mTimer % 500 == 10 || this.oTickRate != this.mTickRate) { + var1.sendProgressBarUpdate(this, 12, this.mTickRate); + } + } while (this.mTimer % 500 != 10); + + } + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBarEx(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 2 : + this.mSide_1 = par2; + break; + case 4 : + this.mSide_2 = par2; + break; + case 6 : + this.mSide_3 = par2; + case 8 : + this.mSide_4 = par2; + case 10 : + this.mTier = par2; + case 12 : + this.mTickRate = par2; + break; + } + + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java index 34a4e9fa97..f9bf617e1b 100644 --- a/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java +++ b/src/Java/gtPlusPlus/core/container/Container_SuperJukebox.java @@ -191,7 +191,7 @@ public class Container_SuperJukebox extends Container { @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return null; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; switch (aSlotIndex) { case SLOT_HOLO_PLAY: if (tile_entity == null) return null; @@ -217,7 +217,7 @@ public class Container_SuperJukebox extends Container { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (tile_entity.getWorldObj().isRemote || tile_entity == null) return; + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; isPlaying = tile_entity.mIsPlaying; isLooping = tile_entity.mIsLooping; |