aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-10-11 18:27:54 +0100
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-10-11 18:27:54 +0100
commitd4d38f40f4500c3dfa218b516fc7621d64bc1759 (patch)
tree599ff65b5b3a3033df43463519f0cbce712e52ea /src
parent4a2fa070a2ae91173cf15785c63b4090016323d4 (diff)
downloadGT5-Unofficial-d4d38f40f4500c3dfa218b516fc7621d64bc1759.tar.gz
GT5-Unofficial-d4d38f40f4500c3dfa218b516fc7621d64bc1759.tar.bz2
GT5-Unofficial-d4d38f40f4500c3dfa218b516fc7621d64bc1759.zip
+ Added Round-Robinator.
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/core/block/ModBlocks.java4
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java162
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java190
-rw-r--r--src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java44
-rw-r--r--src/Java/gtPlusPlus/core/handler/GuiHandler.java7
-rw-r--r--src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java173
-rw-r--r--src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java5
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java291
8 files changed, 875 insertions, 1 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java
index b59facf9e2..a448e313ac 100644
--- a/src/Java/gtPlusPlus/core/block/ModBlocks.java
+++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java
@@ -21,6 +21,7 @@ import gtPlusPlus.core.block.machine.Machine_ModularityTable;
import gtPlusPlus.core.block.machine.Machine_PestKiller;
import gtPlusPlus.core.block.machine.Machine_PooCollector;
import gtPlusPlus.core.block.machine.Machine_ProjectTable;
+import gtPlusPlus.core.block.machine.Machine_RoundRobinator;
import gtPlusPlus.core.block.machine.Machine_SuperJukebox;
import gtPlusPlus.core.block.machine.Machine_TradeTable;
import gtPlusPlus.core.block.machine.Machine_Workbench;
@@ -34,6 +35,7 @@ import net.minecraftforge.fluids.Fluid;
public final class ModBlocks {
+ public static Block blockRoundRobinator;
public static Block blockCircuitProgrammer;
public static Block blockFakeMiningPipe;
public static Block blockFakeMiningHead;
@@ -147,6 +149,8 @@ public final class ModBlocks {
blockPooCollector = new Machine_PooCollector();
blockPestKiller = new Machine_PestKiller();
+
+ blockRoundRobinator = new Machine_RoundRobinator();
new BlockGenericRedstoneDetector();
new BlockGenericRedstoneTest();
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java
new file mode 100644
index 0000000000..71814cb868
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java
@@ -0,0 +1,162 @@
+package gtPlusPlus.core.block.machine;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.common.items.GT_MetaGenerated_Tool_01;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.api.interfaces.ITileTooltip;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.handler.GuiHandler;
+import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator;
+import gtPlusPlus.core.util.minecraft.InventoryUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+
+public class Machine_RoundRobinator extends BlockContainer implements ITileTooltip
+{
+ @SideOnly(Side.CLIENT)
+ private IIcon textureTop;
+ @SideOnly(Side.CLIENT)
+ private IIcon textureBottom;
+ @SideOnly(Side.CLIENT)
+ private IIcon textureFront;
+
+ /**
+ * Determines which tooltip is displayed within the itemblock.
+ */
+ private final int mTooltipID = 7;
+
+ @Override
+ public int getTooltipID() {
+ return this.mTooltipID;
+ }
+
+ @SuppressWarnings("deprecation")
+ public Machine_RoundRobinator(){
+ super(Material.iron);
+ this.setHardness(1f);
+ this.setResistance(1f);
+ this.setBlockName("blockRoundRobinator");
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockRoundRobinator");
+ LanguageRegistry.addName(this, "Round-Robinator");
+
+ }
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(final int p_149691_1_, final int p_149691_2_)
+ {
+ return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : (this.textureFront));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(final IIconRegister p_149651_1_)
+ {
+ this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B");
+ this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B");
+ this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G");
+ this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I");
+ }
+
+ /**
+ * Called upon block activation (right click on the block.)
+ */
+ @Override
+ public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz)
+ {
+ if (world.isRemote) {
+ return true;
+ }
+ else {
+
+ boolean mDidScrewDriver = false;
+ // Check For Screwdriver
+ try {
+ final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName());
+ final Item mHandItem = mHandStack.getItem();
+ if (((mHandItem instanceof GT_MetaGenerated_Tool_01)
+ && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) {
+ final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z);
+ if (tile != null) {
+ mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z);
+ }
+ }
+ }
+ catch (final Throwable t) {}
+
+ if (!mDidScrewDriver) {
+ final TileEntity te = world.getTileEntity(x, y, z);
+ if ((te != null) && (te instanceof TileEntityRoundRobinator)){
+ player.openGui(GTplusplus.instance, GuiHandler.GUI16, world, x, y, z);
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ @Override
+ public int getRenderBlockPass() {
+ return 1;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
+ return new TileEntityRoundRobinator();
+ }
+
+ @Override
+ public void onBlockAdded(final World world, final int x, final int y, final int z) {
+ super.onBlockAdded(world, x, y, z);
+ }
+
+ @Override
+ public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) {
+ InventoryUtils.dropInventoryItems(world, x, y, z, block);
+ super.breakBlock(world, x, y, z, block, number);
+ }
+
+ @Override
+ public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) {
+ if (stack.hasDisplayName()) {
+ ((TileEntityRoundRobinator) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName());
+ }
+ }
+
+ @Override
+ public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) {
+ return false;
+ }
+
+} \ 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..ad2aef02f8
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/container/Container_RoundRobinator.java
@@ -0,0 +1,190 @@
+package gtPlusPlus.core.container;
+
+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 gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.inventories.Inventory_RoundRobinator;
+import gtPlusPlus.core.slots.SlotIntegratedCircuit;
+import gtPlusPlus.core.slots.SlotNoInput;
+import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator;
+
+public class Container_RoundRobinator extends Container {
+
+ protected TileEntityRoundRobinator tile_entity;
+ public final Inventory_RoundRobinator inventoryChest;
+
+ private final World worldObj;
+ private final int posX;
+ private final int posY;
+ private final int posZ;
+
+ public static final int SLOT_OUTPUT = 25;
+
+ public static int StorageSlotNumber = 26; // 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_RoundRobinator(final InventoryPlayer inventory, final TileEntityRoundRobinator te) {
+ this.tile_entity = te;
+ this.inventoryChest = te.getInventory();
+
+ int var6;
+ int var7;
+ this.worldObj = te.getWorldObj();
+ this.posX = te.xCoord;
+ this.posY = te.yCoord;
+ this.posZ = te.zCoord;
+ Logger.INFO("1");
+
+ int o = 0;
+
+ // Storage Side
+ /*for (var6 = 0; var6 < 3; var6++) {
+ for (var7 = 0; var7 < 5; var7++) {
+ this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18)));
+ o++;
+ }
+ }*/
+
+
+ int xStart = 8;
+ int yStart = 5;
+
+ try {
+ //0
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart, yStart));
+ //1-10
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+18));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+18));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+18));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+18));
+ //11-20
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+18));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+18));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+36));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+54));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+54));
+ //21-24
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+54));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+54));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+54));
+ this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+54));
+ Logger.INFO("2");
+
+ //Add Output
+ this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart+(8*18), yStart+54));
+ o++;
+ Logger.INFO("3");
+
+
+
+ // 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));
+ }
+
+
+
+ Logger.INFO("4");
+ }
+ catch (Throwable t) {}
+
+ }
+
+ @Override
+ public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold,
+ final EntityPlayer aPlayer) {
+
+ if (!aPlayer.worldObj.isRemote) {
+ if ((aSlotIndex == 999) || (aSlotIndex == -999)) {
+ // Utils.LOG_WARNING("??? - "+aSlotIndex);
+ }
+ }
+ 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;
+ }
+
+ @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/gui/machine/GUI_RoundRobinator.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java
new file mode 100644
index 0000000000..7a9417c806
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java
@@ -0,0 +1,44 @@
+package gtPlusPlus.core.gui.machine;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+import gtPlusPlus.core.container.Container_RoundRobinator;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator;
+
+@SideOnly(Side.CLIENT)
+public class GUI_RoundRobinator extends GuiContainer {
+
+ private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/RoundRobinator.png");
+
+ public GUI_RoundRobinator(final InventoryPlayer player_inventory, final TileEntityRoundRobinator te){
+ super(new Container_RoundRobinator(player_inventory, te));
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(final int i, final int j){
+ super.drawGuiContainerForegroundLayer(i, j);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){
+ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ this.mc.renderEngine.bindTexture(craftingTableGuiTextures);
+ final int x = (this.width - this.xSize) / 2;
+ final int y = (this.height - this.ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
+ }
+
+ //This method is called when the Gui is first called!
+ @Override
+ public void initGui(){
+ super.initGui();
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
index 67493d7964..2141210650 100644
--- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
@@ -54,6 +54,7 @@ public class GuiHandler implements IGuiHandler {
public static final int GUI13 = 12; // Decayables Chest
public static final int GUI14 = 13; // Super Jukebox
public static final int GUI15 = 14; // Pest Killer
+ public static final int GUI16 = 15; // Round-Robinator
public static void init() {
@@ -102,6 +103,8 @@ public class GuiHandler implements IGuiHandler {
return new Container_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te);
} else if (ID == GUI15) {
return new Container_PestKiller(player.inventory, (TileEntityPestKiller) te);
+ } else if (ID == GUI16) {
+ return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te);
}
}
@@ -162,7 +165,9 @@ public class GuiHandler implements IGuiHandler {
return new GUI_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te);
} else if (ID == GUI15) {
return new GUI_PestKiller(player.inventory, (TileEntityPestKiller) te);
- }
+ } else if (ID == GUI16) {
+ return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te);
+ }
}
if (ID == GUI9) {
diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java
new file mode 100644
index 0000000000..58d60b595f
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java
@@ -0,0 +1,173 @@
+package gtPlusPlus.core.inventories;
+
+import gtPlusPlus.core.recipe.common.CI;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class Inventory_RoundRobinator implements IInventory{
+
+ private final String name = "Circuit Programmer";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 26;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ public void readFromNBT(final NBTTagCompound nbt){
+ final NBTTagList list = nbt.getTagList("Items", 10);
+ this.inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++){
+ final NBTTagCompound data = list.getCompoundTagAt(i);
+ final int slot = data.getInteger("Slot");
+ if((slot >= 0) && (slot < INV_SIZE)){
+ //Utils.LOG_INFO("Trying to read NBT data from inventory.");
+ this.inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(final NBTTagCompound nbt){
+ final NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++){
+ final ItemStack stack = this.inventory[i];
+ if(stack != null){
+ //Utils.LOG_INFO("Trying to write NBT data to inventory.");
+ final NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return this.inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return this.inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot)
+ {
+ return this.inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int amount)
+ {
+ ItemStack stack = this.getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ this.setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot)
+ {
+ final ItemStack stack = this.getStackInSlot(slot);
+ this.setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack)
+ {
+ this.inventory[slot] = stack;
+
+ if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit()))
+ {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return this.name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return this.name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < this.getSizeInventory(); ++i)
+ {
+ final ItemStack temp = this.getStackInSlot(i);
+ if (temp != null){
+ //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize);
+ }
+
+ if ((temp != null) && (temp.stackSize == 0)) {
+ this.inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
+ return (itemstack.getItem() == CI.getNumberedCircuit(0).getItem());
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java
index 21ea826eea..73d6bb0ca2 100644
--- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java
+++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java
@@ -44,6 +44,11 @@ public class ItemBlockBasicTile extends ItemBlock {
list.add("Kills Forestry Butterflies, Bats and other pests");
list.add("Use either Formaldehyde or Hydrogen cyanide");
list.add("Be weary of your neighbours");
+ } else if (this.mID == 7) { // Round-Robinator
+ list.add("Attempts to output items evenly on all for horizontal planes");
+ list.add("Each tier operates at a factor of one operation every (20/tier)ticks");
+ list.add("Top and bottom do not pull, so you must push item in");
+ list.add("Sides can be disabled with a screwdriver");
} else {
list.add("Bad Tooltip ID - " + mID);
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java
new file mode 100644
index 0000000000..13ba5ca44d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java
@@ -0,0 +1,291 @@
+package gtPlusPlus.core.tileentities.machines;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.inventories.Inventory_RoundRobinator;
+import gtPlusPlus.core.recipe.common.CI;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+
+public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory {
+
+ private int tickCount = 0;
+ private final Inventory_RoundRobinator inventoryContents;
+ private String customName;
+ public int locationX;
+ public int locationY;
+ public int locationZ;
+ private int aCurrentMode = 0;
+
+ public TileEntityRoundRobinator() {
+ this.inventoryContents = new Inventory_RoundRobinator();
+ this.setTileLocation();
+ }
+
+ public boolean setTileLocation() {
+ if (this.hasWorldObj()) {
+ if (!this.getWorldObj().isRemote) {
+ this.locationX = this.xCoord;
+ this.locationY = this.yCoord;
+ this.locationZ = this.zCoord;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //Rename to hasCircuitToConfigure
+ public final boolean hasCircuitToConfigure() {
+ for (ItemStack i : this.getInventory().getInventory()) {
+ if (i == null) {
+ continue;
+ }
+ else {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Inventory_RoundRobinator getInventory() {
+ return this.inventoryContents;
+ }
+
+ public boolean addOutput() {
+ ItemStack[] aInputs = this.getInventory().getInventory().clone();
+ //Check if there is output in slot.
+ Boolean hasOutput = false;
+ if (aInputs[25] != null) {
+ hasOutput = true;
+ }
+ AutoMap<Integer> aValidSlots = new AutoMap<Integer>();
+ int aSlotCount = 0;
+ for (ItemStack i : aInputs) {
+ if (i != null) {
+ aValidSlots.put(aSlotCount);
+ }
+ aSlotCount++;
+ }
+ for (int e : aValidSlots) {
+ boolean doAdd = false;
+ ItemStack g = this.getStackInSlot(e);
+ int aSize = 0;
+ ItemStack aInputStack = null;
+ if (g != null) {
+ if (!hasOutput) {
+ aSize = g.stackSize;
+ doAdd = true;
+ }
+ else {
+ ItemStack f = this.getStackInSlot(25);
+ if (f != null) {
+ if (f.getItemDamage() == e) {
+ aSize = f.stackSize + g.stackSize;
+ if (aSize > 64) {
+ aInputStack = g.copy();
+ aInputStack.stackSize = (aSize-64);
+ }
+ doAdd = true;
+ }
+ }
+ else {
+ doAdd = true;
+ aSize = g.stackSize;
+ }
+ }
+ if (doAdd) {
+ ItemStack aOutput = CI.getNumberedCircuit(e);
+ if (aOutput != null) {
+ aOutput.stackSize = aSize;
+ this.setInventorySlotContents(e, aInputStack);
+ this.setInventorySlotContents(25, aOutput);
+ return true;
+ }
+ }
+ }
+ continue;
+ }
+ return false;
+ }
+
+ @Override
+ public void updateEntity() {
+ try{
+ if (!this.worldObj.isRemote) {
+ if (tickCount % 10 == 0) {
+ if (hasCircuitToConfigure()) {
+ this.addOutput();
+ this.markDirty();
+ }
+ }
+ this.tickCount++;
+ }
+ }
+ catch (final Throwable t){}
+ }
+
+ public boolean anyPlayerInRange() {
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null;
+ }
+
+ public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) {
+ if (!nbt.hasKey(tag)) {
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public void writeToNBT(final NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ // Utils.LOG_WARNING("Trying to write NBT data to TE.");
+ final NBTTagCompound chestData = new NBTTagCompound();
+ this.inventoryContents.writeToNBT(chestData);
+ nbt.setTag("ContentsChest", chestData);
+ if (this.hasCustomInventoryName()) {
+ nbt.setString("CustomName", this.getCustomName());
+ }
+ nbt.setInteger("aCurrentMode", aCurrentMode);
+ }
+
+ @Override
+ public void readFromNBT(final NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ // Utils.LOG_WARNING("Trying to read NBT data from TE.");
+ this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest"));
+ if (nbt.hasKey("CustomName", 8)) {
+ this.setCustomName(nbt.getString("CustomName"));
+ }
+ aCurrentMode = nbt.getInteger("aCurrentMode");
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return this.getInventory().getSizeInventory();
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot) {
+ return this.getInventory().getStackInSlot(slot);
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int count) {
+ return this.getInventory().decrStackSize(slot, count);
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ return this.getInventory().getStackInSlotOnClosing(slot);
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ this.getInventory().setInventorySlotContents(slot, stack);
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return this.getInventory().getInventoryStackLimit();
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
+ return this.getInventory().isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public void openInventory() {
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().openInventory();
+ }
+
+ @Override
+ public void closeInventory() {
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().closeInventory();
+ }
+
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
+ return this.getInventory().isItemValidForSlot(slot, itemstack);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
+ final int[] accessibleSides = new int[this.getSizeInventory()];
+ for (int r=0; r<this.getInventory().getSizeInventory(); r++){
+ accessibleSides[r]=r;
+ }
+ return accessibleSides;
+
+ }
+
+ @Override
+ public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
+ return p_102007_1_ >= 0 && p_102007_1_ <= 24;
+ }
+
+ @Override
+ public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
+ return p_102008_1_ == 25;
+ }
+
+ public String getCustomName() {
+ return this.customName;
+ }
+
+ public void setCustomName(final String customName) {
+ this.customName = customName;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return this.hasCustomInventoryName() ? this.customName : "container.circuitprogrammer";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return (this.customName != null) && !this.customName.equals("");
+ }
+
+ @Override
+ public Packet getDescriptionPacket() {
+ final NBTTagCompound tag = new NBTTagCompound();
+ this.writeToNBT(tag);
+ return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag);
+ }
+
+ @Override
+ public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) {
+ final NBTTagCompound tag = pkt.func_148857_g();
+ this.readFromNBT(tag);
+ }
+
+ public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) {
+ try {
+ if (aCurrentMode == 24) {
+ aCurrentMode = 0;
+ }
+ else {
+ aCurrentMode++;
+ }
+ PlayerUtils.messagePlayer(player, "Now configuring units for type "+aCurrentMode+".");
+ return true;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ }
+
+}