diff options
Diffstat (limited to 'src/main/java')
16 files changed, 0 insertions, 1097 deletions
diff --git a/src/main/java/client/gui/Gui_ItemProxyEndpoint.java b/src/main/java/client/gui/Gui_ItemProxyEndpoint.java deleted file mode 100644 index d98417f686..0000000000 --- a/src/main/java/client/gui/Gui_ItemProxyEndpoint.java +++ /dev/null @@ -1,55 +0,0 @@ -package client.gui; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import common.container.Container_ItemProxyEndpoint; - -import kekztech.KekzCore; - -public class Gui_ItemProxyEndpoint extends GuiContainer { - - private final ResourceLocation texture = new ResourceLocation( - KekzCore.MODID, - "textures/gui/ItemTechReceiverNode.png"); - - private final InventoryPlayer inventory; - private final IInventory te; - - public Gui_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { - super(new Container_ItemProxyEndpoint(te, player)); - inventory = player.inventory; - this.te = (IInventory) te; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - final int x = (super.width - super.xSize) / 2; - final int y = (super.height - super.ySize) / 2; - - super.drawTexturedModalRect(x, y, 0, 0, super.xSize, super.ySize); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p1, int p2) { - super.fontRendererObj.drawString( - I18n.format(te.getInventoryName()), - (super.xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), - 6, - 4210752, - false); - super.fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, super.ySize - 96 + 2, 4210752); - } -} diff --git a/src/main/java/client/gui/Gui_ItemProxySource.java b/src/main/java/client/gui/Gui_ItemProxySource.java deleted file mode 100644 index 8618ff828f..0000000000 --- a/src/main/java/client/gui/Gui_ItemProxySource.java +++ /dev/null @@ -1,53 +0,0 @@ -package client.gui; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import common.container.Container_ItemProxySource; - -import kekztech.KekzCore; - -public class Gui_ItemProxySource extends GuiContainer { - - private final ResourceLocation texture = new ResourceLocation(KekzCore.MODID, "textures/gui/ItemTech4by4.png"); - - private final InventoryPlayer inventory; - private final IInventory te; - - public Gui_ItemProxySource(TileEntity te, EntityPlayer player) { - super(new Container_ItemProxySource(te, player)); - inventory = player.inventory; - this.te = (IInventory) te; - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - final int x = (super.width - super.xSize) / 2; - final int y = (super.height - super.ySize) / 2; - - super.drawTexturedModalRect(x, y, 0, 0, super.xSize, super.ySize); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p1, int p2) { - super.fontRendererObj.drawString( - I18n.format(te.getInventoryName()), - (super.xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), - 6, - 4210752, - false); - super.fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, super.ySize - 96 + 2, 4210752); - } -} diff --git a/src/main/java/client/renderer/ConduitRenderer.java b/src/main/java/client/renderer/ConduitRenderer.java deleted file mode 100644 index a9e3436bcc..0000000000 --- a/src/main/java/client/renderer/ConduitRenderer.java +++ /dev/null @@ -1,95 +0,0 @@ -package client.renderer; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; - -import common.tileentities.TE_ItemProxyCable; - -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.client.registry.RenderingRegistry; - -public class ConduitRenderer implements ISimpleBlockRenderingHandler { - - public static final int RID = RenderingRegistry.getNextAvailableRenderId(); - private static final ConduitRenderer INSTANCE = new ConduitRenderer(); - - private ConduitRenderer() {} - - public static ConduitRenderer getInstance() { - return INSTANCE; - } - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {} - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, - RenderBlocks renderer) { - final TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - - final float thickness = TE_ItemProxyCable.getThickness(); - final float space = (1.0f - thickness) / 2.0f; - - float xThickness = thickness; - float xOffset = space; - float yThickness = thickness; - float yOffset = space; - float zThickness = thickness; - float zOffset = space; - - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (cable.isConnected(side)) { - switch (side) { - case DOWN: - yOffset = 0.0F; - yThickness += space; - break; - case UP: - yThickness += space; - break; - case NORTH: - zOffset = 0.0F; - zThickness += space; - break; - case SOUTH: - zThickness += space; - break; - case WEST: - xOffset += 0.0F; - xThickness += space; - break; - case EAST: - xThickness += space; - break; - } - } - } - - block.setBlockBounds( - xOffset, - yOffset, - zOffset, - xOffset + xThickness, - yOffset + yThickness, - zOffset + zThickness); - renderer.setRenderBoundsFromBlock(block); - } - - return false; - } - - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } - - @Override - public int getRenderId() { - return ConduitRenderer.RID; - } -} diff --git a/src/main/java/common/CommonProxy.java b/src/main/java/common/CommonProxy.java index 75a775e1bc..0f6600be83 100644 --- a/src/main/java/common/CommonProxy.java +++ b/src/main/java/common/CommonProxy.java @@ -8,10 +8,7 @@ import common.tileentities.GTMTE_TFFTHatch; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import kekztech.GuiHandler; import kekztech.Items; -import kekztech.KekzCore; public class CommonProxy { @@ -27,8 +24,6 @@ public class CommonProxy { TileEntities.preInit(); // TC Research Researches.preInit(); - // GUI Handler - NetworkRegistry.INSTANCE.registerGuiHandler(KekzCore.instance, new GuiHandler()); } public void init(final FMLInitializationEvent e) { diff --git a/src/main/java/common/blocks/Block_ItemProxyCable.java b/src/main/java/common/blocks/Block_ItemProxyCable.java deleted file mode 100644 index cf9307dde0..0000000000 --- a/src/main/java/common/blocks/Block_ItemProxyCable.java +++ /dev/null @@ -1,68 +0,0 @@ -package common.blocks; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import common.itemBlocks.IB_ItemProxyCable; -import common.tileentities.TE_ItemProxyCable; - -import client.renderer.ConduitRenderer; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import kekztech.KekzCore; - -public class Block_ItemProxyCable extends Block { - - private static final Block_ItemProxyCable instance = new Block_ItemProxyCable(); - - private Block_ItemProxyCable() { - super(Material.glass); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemproxycable_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "TFFTCasing"); - instance.setHardness(3.0f); - instance.setResistance(2.0f); - GameRegistry.registerBlock(instance, IB_ItemProxyCable.class, blockName); - - return instance; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createTileEntity(World world, int p_149915_2_) { - return new TE_ItemProxyCable(); - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - return 1; - } - - @Override - public int getRenderType() { - return ConduitRenderer.RID; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } -} diff --git a/src/main/java/common/blocks/Block_ItemProxyEndpoint.java b/src/main/java/common/blocks/Block_ItemProxyEndpoint.java deleted file mode 100644 index 5f60eba040..0000000000 --- a/src/main/java/common/blocks/Block_ItemProxyEndpoint.java +++ /dev/null @@ -1,63 +0,0 @@ -package common.blocks; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import common.itemBlocks.IB_ItemProxyEndpoint; -import common.tileentities.TE_ItemProxyEndpoint; - -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.GuiHandler; -import kekztech.KekzCore; - -public class Block_ItemProxyEndpoint extends Block { - - private static final Block_ItemProxyEndpoint instance = new Block_ItemProxyEndpoint(); - - private Block_ItemProxyEndpoint() { - super(Material.glass); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemproxyendpoint_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemProxyEndpoint"); - instance.setHardness(3.0f); - instance.setResistance(2.0f); - instance.setHarvestLevel("wrench", 2); - GameRegistry.registerBlock(instance, IB_ItemProxyEndpoint.class, blockName); - - return instance; - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, - float lz) { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TE_ItemProxyEndpoint) { - player.openGui(KekzCore.instance, GuiHandler.ITEM_PROXY_ENDPOINT, world, x, y, z); - return true; - } else { - return false; - } - } - - @Override - public TileEntity createTileEntity(World world, int p_149915_2_) { - return new TE_ItemProxyEndpoint(); - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } -} diff --git a/src/main/java/common/blocks/Block_ItemProxySource.java b/src/main/java/common/blocks/Block_ItemProxySource.java deleted file mode 100644 index 7ab34ade52..0000000000 --- a/src/main/java/common/blocks/Block_ItemProxySource.java +++ /dev/null @@ -1,63 +0,0 @@ -package common.blocks; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import common.itemBlocks.IB_ItemProxySource; -import common.tileentities.TE_ItemProxySource; - -import cpw.mods.fml.common.registry.GameRegistry; -import kekztech.GuiHandler; -import kekztech.KekzCore; - -public class Block_ItemProxySource extends Block { - - private static final Block_ItemProxySource instance = new Block_ItemProxySource(); - - private Block_ItemProxySource() { - super(Material.glass); - } - - public static Block registerBlock() { - final String blockName = "kekztech_itemproxysource_block"; - instance.setBlockName(blockName); - instance.setCreativeTab(CreativeTabs.tabMisc); - instance.setBlockTextureName(KekzCore.MODID + ":" + "ItemProxySource"); - instance.setHardness(3.0f); - instance.setResistance(2.0f); - instance.setHarvestLevel("wrench", 2); - GameRegistry.registerBlock(instance, IB_ItemProxySource.class, blockName); - - return instance; - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, - float lz) { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TE_ItemProxySource) { - player.openGui(KekzCore.instance, GuiHandler.ITEM_PROXY_SOURCE, world, x, y, z); - return true; - } else { - return false; - } - } - - @Override - public TileEntity createTileEntity(World world, int p_149915_2_) { - return new TE_ItemProxySource(); - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } -} diff --git a/src/main/java/common/container/Container_ItemProxyEndpoint.java b/src/main/java/common/container/Container_ItemProxyEndpoint.java deleted file mode 100644 index 8f509e789c..0000000000 --- a/src/main/java/common/container/Container_ItemProxyEndpoint.java +++ /dev/null @@ -1,66 +0,0 @@ -package common.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public class Container_ItemProxyEndpoint extends Container { - - private final IInventory teInventory; - - private int slotID = 0; - - public Container_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { - this.teInventory = (IInventory) te; - - // Source Slot - addSlotToContainer(new Slot(teInventory, slotID++, 80, 35)); - // Config slot - addSlotToContainer(new Slot(teInventory, slotID++, 100, 35)); - - // Inventory - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 9; j++) { - addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - // Hotbar - for (int i = 0; i < 9; i++) { - addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { - ItemStack stack = null; - final Slot slot = (Slot) inventorySlots.get(slotRaw); - - if (slot != null && slot.getHasStack()) { - final ItemStack stackInSlot = slot.getStack(); - stack = stackInSlot.copy(); - - if (slotRaw < 3 * 9) { - if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { - return null; - } - } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { - return null; - } - - if (stackInSlot.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - } - return stack; - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return teInventory.isUseableByPlayer(player); - } -} diff --git a/src/main/java/common/container/Container_ItemProxySource.java b/src/main/java/common/container/Container_ItemProxySource.java deleted file mode 100644 index 23af97e5bb..0000000000 --- a/src/main/java/common/container/Container_ItemProxySource.java +++ /dev/null @@ -1,79 +0,0 @@ -package common.container; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public class Container_ItemProxySource extends Container { - - private final IInventory teInventory; - - private int slotID = 0; - - public Container_ItemProxySource(TileEntity te, EntityPlayer player) { - this.teInventory = (IInventory) te; - - // Source Slots - addSlotToContainer(new Slot(teInventory, slotID++, 53, 8)); - addSlotToContainer(new Slot(teInventory, slotID++, 71, 8)); - addSlotToContainer(new Slot(teInventory, slotID++, 89, 8)); - addSlotToContainer(new Slot(teInventory, slotID++, 107, 8)); - addSlotToContainer(new Slot(teInventory, slotID++, 53, 26)); - addSlotToContainer(new Slot(teInventory, slotID++, 71, 26)); - addSlotToContainer(new Slot(teInventory, slotID++, 89, 26)); - addSlotToContainer(new Slot(teInventory, slotID++, 107, 26)); - addSlotToContainer(new Slot(teInventory, slotID++, 53, 44)); - addSlotToContainer(new Slot(teInventory, slotID++, 71, 44)); - addSlotToContainer(new Slot(teInventory, slotID++, 89, 44)); - addSlotToContainer(new Slot(teInventory, slotID++, 107, 44)); - addSlotToContainer(new Slot(teInventory, slotID++, 53, 62)); - addSlotToContainer(new Slot(teInventory, slotID++, 71, 62)); - addSlotToContainer(new Slot(teInventory, slotID++, 89, 62)); - addSlotToContainer(new Slot(teInventory, slotID++, 107, 62)); - - // Inventory - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 9; j++) { - addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - // Hotbar - for (int i = 0; i < 9; i++) { - addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { - ItemStack stack = null; - final Slot slot = (Slot) inventorySlots.get(slotRaw); - - if (slot != null && slot.getHasStack()) { - final ItemStack stackInSlot = slot.getStack(); - stack = stackInSlot.copy(); - - if (slotRaw < 3 * 9) { - if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { - return null; - } - } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { - return null; - } - - if (stackInSlot.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - } - return stack; - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return teInventory.isUseableByPlayer(player); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemProxyCable.java b/src/main/java/common/itemBlocks/IB_ItemProxyCable.java deleted file mode 100644 index 6022194225..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemProxyCable.java +++ /dev/null @@ -1,22 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemProxyCable extends ItemBlock { - - public IB_ItemProxyCable(Block block) { - super(block); - } - - @SuppressWarnings({ "unchecked" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxycable_block.0.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java b/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java deleted file mode 100644 index 2cde2c14d3..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemProxyEndpoint.java +++ /dev/null @@ -1,23 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemProxyEndpoint extends ItemBlock { - - public IB_ItemProxyEndpoint(Block block) { - super(block); - } - - @SuppressWarnings({ "unchecked" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxyendpoint_block.0.desc")); - lines.add(StatCollector.translateToLocal("tile.kekztech_itemproxyendpoint_block.1.desc")); - } -} diff --git a/src/main/java/common/itemBlocks/IB_ItemProxySource.java b/src/main/java/common/itemBlocks/IB_ItemProxySource.java deleted file mode 100644 index 42371ab6e6..0000000000 --- a/src/main/java/common/itemBlocks/IB_ItemProxySource.java +++ /dev/null @@ -1,24 +0,0 @@ -package common.itemBlocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -public class IB_ItemProxySource extends ItemBlock { - - public IB_ItemProxySource(Block block) { - super(block); - } - - @SuppressWarnings({ "unchecked" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) { - lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.0.desc")); - lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.1.desc")); - lines.add(StatCollector.translateToLocal("tile:kekztech_itemproxysource_block.2.desc")); - } -} diff --git a/src/main/java/common/tileentities/TE_ItemProxyCable.java b/src/main/java/common/tileentities/TE_ItemProxyCable.java deleted file mode 100644 index 1dc539c89e..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxyCable.java +++ /dev/null @@ -1,155 +0,0 @@ -package common.tileentities; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -public class TE_ItemProxyCable extends TileEntity { - - private static final float THICKNESS = 0.5F; - private byte connections = 0; - private byte connectionAllowed = 63; - private String idCache = null; - - public TE_ItemProxyCable() {} - - @Override - public void updateEntity() { - // Check all 6 sides and connect the conduit if it is allowed to - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - final TileEntity te = super.getWorldObj().getTileEntity( - super.xCoord + side.offsetX, - super.yCoord + side.offsetY, - super.zCoord + side.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - setConnection(side, cable.isConnectionAllowed(side.getOpposite())); - } else { - setConnection(side, false); - } - } - } - - public static float getThickness() { - return THICKNESS; - } - - /** - * Builds a simple unique identifier for this TileEntity by appending the x, y, and z coordinates in a string. - * - * @return unique identifier for this TileEntity - */ - public String getIdentifier() { - if (idCache == null) { - idCache = "" + super.xCoord + super.yCoord + super.zCoord; - return idCache; - } else { - return idCache; - } - } - - /** - * 0 0 0 0 0 0 0 0 = 0 -> no connection </br> - * 0 0 0 0 0 0 0 1 = 1 -> down </br> - * 0 0 0 0 0 0 1 0 = 2 -> up </br> - * 0 0 0 0 0 1 0 0 = 4 -> north </br> - * 0 0 0 0 1 0 0 0 = 8 -> south </br> - * 0 0 0 1 0 0 0 0 = 16 -> west </br> - * 0 0 1 0 0 0 0 0 = 32 -> east </br> - * - * @param side The side for which to set the connection status. - * @param connected Whether this side should be connected or not - * @return True if the connection was allowed - */ - public boolean setConnection(ForgeDirection side, boolean connected) { - if (isConnectionAllowed(side)) { - switch (side) { - case DOWN: - connections = (byte) ((connected) ? connections | 1 : connections ^ 1); - break; - case UP: - connections = (byte) ((connected) ? connections | 2 : connections ^ 2); - break; - case NORTH: - connections = (byte) ((connected) ? connections | 4 : connections ^ 4); - break; - case SOUTH: - connections = (byte) ((connected) ? connections | 8 : connections ^ 8); - break; - case WEST: - connections = (byte) ((connected) ? connections | 16 : connections ^ 16); - break; - case EAST: - connections = (byte) ((connected) ? connections | 32 : connections ^ 32); - break; - default: - return false; - } - return true; - } else { - return false; - } - } - - public boolean isConnected(ForgeDirection side) { - switch (side) { - case DOWN: - return (connections & 1) == 1; - case UP: - return (connections & 2) == 2; - case NORTH: - return (connections & 4) == 4; - case SOUTH: - return (connections & 8) == 8; - case WEST: - return (connections & 16) == 16; - case EAST: - return (connections & 32) == 32; - default: - return false; - } - } - - public void setConnectionAllowed(ForgeDirection side, boolean allowed) { - switch (side) { - case DOWN: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 1 : connectionAllowed ^ 1); - break; - case UP: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 2 : connectionAllowed ^ 2); - break; - case NORTH: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 4 : connectionAllowed ^ 4); - break; - case SOUTH: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 8 : connectionAllowed ^ 8); - break; - case WEST: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 16 : connectionAllowed ^ 16); - break; - case EAST: - connectionAllowed = (byte) ((allowed) ? connectionAllowed | 32 : connectionAllowed ^ 32); - break; - default: - break; - } - } - - public boolean isConnectionAllowed(ForgeDirection side) { - switch (side) { - case DOWN: - return (connectionAllowed & 1) == 1; - case UP: - return (connectionAllowed & 2) == 2; - case NORTH: - return (connectionAllowed & 4) == 4; - case SOUTH: - return (connectionAllowed & 8) == 8; - case WEST: - return (connectionAllowed & 16) == 16; - case EAST: - return (connectionAllowed & 32) == 32; - default: - return false; - } - } -} diff --git a/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java b/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java deleted file mode 100644 index 7d58a21c61..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxyEndpoint.java +++ /dev/null @@ -1,175 +0,0 @@ -package common.tileentities; - -import java.util.HashSet; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -public class TE_ItemProxyEndpoint extends TileEntity implements ISidedInventory { - - private byte channel = -1; - private IInventory proxyInventory = null; - private int tickCounter = 0; - - public TE_ItemProxyEndpoint() { - channel = 0; - } - - public void setChannel(byte channel) { - this.channel = channel; - } - - public int getChannel() { - return channel; - } - - @Override - public void updateEntity() { - if (tickCounter == 20) { - if (channel != -1) { - proxyInventory = searchSource(); - } - tickCounter = 0; - } - tickCounter++; - } - - private TE_ItemProxySource searchSource() { - - final HashSet<TE_ItemProxySource> sources = new HashSet<>(); - final HashSet<String> visited = new HashSet<>(); - - for (ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { - final TileEntity te = super.getWorldObj().getTileEntity( - super.xCoord + next.offsetX, - super.yCoord + next.offsetY, - super.zCoord + next.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - if (cable.isConnected(next.getOpposite())) { - searchSourceRecursive(sources, visited, next.getOpposite(), cable); - } - } - } - - if (sources.isEmpty()) { - return null; - } else { - return sources.iterator().next(); - } - } - - private void searchSourceRecursive(HashSet<TE_ItemProxySource> sources, HashSet<String> visited, - ForgeDirection from, TE_ItemProxyCable nextTarget) { - - if (!visited.contains(nextTarget.getIdentifier())) { - visited.add(nextTarget.getIdentifier()); - - for (ForgeDirection next : ForgeDirection.VALID_DIRECTIONS) { - if (next != from) { - final TileEntity te = super.getWorldObj().getTileEntity( - nextTarget.xCoord + next.offsetX, - nextTarget.yCoord + next.offsetY, - nextTarget.zCoord + next.offsetZ); - if (te instanceof TE_ItemProxyCable) { - final TE_ItemProxyCable cable = (TE_ItemProxyCable) te; - if (cable.isConnected(next.getOpposite())) { - searchSourceRecursive(sources, visited, next.getOpposite(), cable); - } - } else if (te instanceof TE_ItemProxySource) { - sources.add((TE_ItemProxySource) te); - } - } - } - } - } - - @Override - public int getSizeInventory() { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slot) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.getStackInSlot(channel); - } else { - return null; - } - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.decrStackSize(channel, amount); - } else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return (proxyInventory != null) ? proxyInventory.getStackInSlotOnClosing(channel) : null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) { - if (proxyInventory != null && slot == 0) { - proxyInventory.setInventorySlotContents(channel, itemStack); - } - } - - @Override - public String getInventoryName() { - return (proxyInventory != null) ? "Connected: " + proxyInventory.getInventoryName() : "Untethered Proxy"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public int getInventoryStackLimit() { - return (proxyInventory != null) ? proxyInventory.getInventoryStackLimit() : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - if (proxyInventory != null && slot == 0) { - return proxyInventory.isItemValidForSlot(channel, itemStack); - } else { - return false; - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return new int[] { 0 }; - } - - @Override - public boolean canInsertItem(int slot, ItemStack itemStack, int side) { - return isItemValidForSlot(slot, itemStack); - } - - @Override - public boolean canExtractItem(int slot, ItemStack itemStack, int side) { - return slot == 0; - } -} diff --git a/src/main/java/common/tileentities/TE_ItemProxySource.java b/src/main/java/common/tileentities/TE_ItemProxySource.java deleted file mode 100644 index 31403f5352..0000000000 --- a/src/main/java/common/tileentities/TE_ItemProxySource.java +++ /dev/null @@ -1,105 +0,0 @@ -package common.tileentities; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public class TE_ItemProxySource extends TileEntity implements IInventory { - - private final ItemStack[] slots = new ItemStack[16]; - private String idCache = null; - - /** - * Builds a simple unique identifier for this TileEntity by appending the x, y, and z coordinates in a string. - * - * @return unique identifier for this TileEntity - */ - public String getIdentifier() { - if (idCache == null) { - idCache = "" + super.xCoord + super.yCoord + super.zCoord; - return idCache; - } else { - return idCache; - } - } - - @Override - public int getSizeInventory() { - return slots.length; - } - - @Override - public ItemStack getStackInSlot(int slot) { - return slots[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - if (slots[slot] != null) { - - ItemStack copy; - - if (slots[slot].stackSize == amount) { - copy = slots[slot]; - slots[slot] = null; - super.markDirty(); - return copy; - } else { - copy = slots[slot].splitStack(amount); - if (slots[slot].stackSize == 0) { - slots[slot] = null; - } - return copy; - } - - } else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return null; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemStack) { - slots[slot] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { - itemStack.stackSize = getInventoryStackLimit(); - } - super.markDirty(); - } - - @Override - public String getInventoryName() { - return "Item Proxy Source"; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - return true; - } -} diff --git a/src/main/java/kekztech/GuiHandler.java b/src/main/java/kekztech/GuiHandler.java deleted file mode 100644 index 9708b89d24..0000000000 --- a/src/main/java/kekztech/GuiHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package kekztech; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import common.container.Container_ItemProxyEndpoint; -import common.container.Container_ItemProxySource; - -import client.gui.Gui_ItemProxyEndpoint; -import client.gui.Gui_ItemProxySource; -import cpw.mods.fml.common.network.IGuiHandler; - -public class GuiHandler implements IGuiHandler { - - public static final int ITEM_PROXY_SOURCE = 0; - public static final int ITEM_PROXY_ENDPOINT = 1; - - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - final TileEntity te = world.getTileEntity(x, y, z); - if (te != null) { - switch (ID) { - case ITEM_PROXY_SOURCE: - return new Container_ItemProxySource(te, player); - case ITEM_PROXY_ENDPOINT: - return new Container_ItemProxyEndpoint(te, player); - } - } - return null; - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - final TileEntity te = world.getTileEntity(x, y, z); - if (te != null) { - switch (ID) { - case ITEM_PROXY_SOURCE: - return new Gui_ItemProxySource(te, player); - case ITEM_PROXY_ENDPOINT: - return new Gui_ItemProxyEndpoint(te, player); - } - } - return null; - } -} |