diff options
Diffstat (limited to 'src/Java')
8 files changed, 645 insertions, 9 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index d351926350..386ebf1b3f 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -43,6 +43,7 @@ public final class ModBlocks { public static Block blockHellfire; public static Block blockInfiniteFLuidTank; public static Block blockProjectTable; + public static Block blockTradeTable; public static void init() { Utils.LOG_INFO("Initializing Blocks."); @@ -70,6 +71,7 @@ public final class ModBlocks { blockMiningExplosive = new MiningExplosives(); blockHellfire = new HellFire(); blockProjectTable = new Machine_ProjectTable(); + blockTradeTable = new Machine_TradeTable(); } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java new file mode 100644 index 0000000000..1551d2cddd --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.Optional; +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 gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.item.tool.ItemToolWrench; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +@Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") +public class Machine_TradeTable extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public Machine_TradeTable() + { + super(Material.leaves); + this.setBlockName("blockTradeBench"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockTradeBench"); + LanguageRegistry.addName(this, "Trade-o-Mat"); + + } + + /** + * 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 : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + } + + /** + * 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) + { + + ItemStack heldItem = null; + if (world.isRemote){ + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } + + boolean holdingWrench = false; + + if (heldItem != null){ + holdingWrench = isWrench(heldItem); + } + + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityProjectTable)) + { + if (!holdingWrench){ + player.openGui(GTplusplus.instance, 6, world, x, y, z); + return true; + } + Utils.LOG_INFO("Holding a Wrench, doing wrench things instead."); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityProjectTable(); + } + + public static boolean isWrench(final ItemStack item){ + if (item.getItem() instanceof ItemToolWrench){ + return true; + } + if (LoadedMods.BuildCraft){ + return checkBuildcraftWrench(item); + } + if (LoadedMods.EnderIO){ + return checkEnderIOWrench(item); + } + return false; + } + + @Optional.Method(modid = "EnderIO") + private static boolean checkEnderIOWrench(final ItemStack item){ + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + Class<?> wrenchClass; + try { + wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())){ + return true; + } + } + catch (final ClassNotFoundException e1) { + return false; + } + } + return false; + } + + @Optional.Method(modid = "Buildcraft") + private static boolean checkBuildcraftWrench(final ItemStack item){ + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + Class<?> wrenchClass; + try { + wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())){ + return true; + } + } + catch (final ClassNotFoundException e1) { + return false; + } + } + return false; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_TradeTable.java b/src/Java/gtPlusPlus/core/container/Container_TradeTable.java new file mode 100644 index 0000000000..1c516d0045 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_TradeTable.java @@ -0,0 +1,238 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; +import gtPlusPlus.core.slots.*; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.*; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; + +public class Container_TradeTable extends Container { + + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); + + protected TileEntityTradeTable tile_entity; + public final InventoryProjectMain inventoryGrid; + public final InventoryProjectOutput inventoryOutputs; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final int[] slotOutputs = new int[2]; + private final int[] slotGrid = new int[9]; + + + public Container_TradeTable(final InventoryPlayer inventory, final TileEntityTradeTable te){ + this.tile_entity = te; + this.inventoryGrid = te.inventoryGrid; + this.inventoryOutputs = te.inventoryOutputs; + this.tile_entity.setContainer(this); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int nextFreeSlot = 0; + + + //Output slots + this.addSlotToContainer(new SlotDataStick(this.inventoryOutputs, 0, 26+(18*6), 7)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26+(18*6), 43)); + + this.addSlotToContainer(new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26+(18*4), 25)); + + + int o = 0; + //Storage Side + for (var6 = 0; var6 < 3; ++var6) + { + for (var7 = 0; var7 < 3; ++var7) + { + //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); + this.addSlotToContainer(new Slot(this.craftMatrix, nextFreeSlot, 8+18 + (var7 * 18), 8 + (var6 * 18))); + this.slotGrid[o] = nextFreeSlot; + nextFreeSlot++; + o++; + } + } + + + //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)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + + } + + /** + * Callback for when the crafting matrix is changed. + */ + public void onCraftMatrixChanged(IInventory p_75130_1_) + { + this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); + } + + /** + * Called when the container is closed. + */ + public void onContainerClosed(EntityPlayer p_75134_1_){ + super.onContainerClosed(p_75134_1_); + if (!this.worldObj.isRemote){ + for (int i = 0; i < 9; ++i){ + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + if (itemstack != null){ + p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + @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); + } + + if (aSlotIndex == 0){ + Utils.LOG_INFO("Player Clicked on the Data Stick slot"); + //TODO + }if (aSlotIndex == 1){ + Utils.LOG_INFO("Player Clicked on the output slot"); + //TODO + } + + for (final int x : this.slotGrid){ + if (aSlotIndex == x){ + Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the crafting Grid"); + } + } + } + //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockProjectTable){ + 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) + { + + return null; + + /*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 + public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_){ + return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); + } + + public ItemStack getOutputContent(){ + ItemStack output = this.craftResult.getStackInSlot(0); + if (output != null){ + return output; + } + return null; + } + + public ItemStack[] getInputComponents(){ + ItemStack inputs[] = new ItemStack[9]; + for (int r=0;r<this.craftMatrix.getSizeInventory();r++){ + ItemStack temp = this.craftMatrix.getStackInSlot(r); + inputs[r] = temp; + } + return inputs; + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java new file mode 100644 index 0000000000..5b5a919291 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java @@ -0,0 +1,67 @@ +package gtPlusPlus.core.gui.machine; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.container.Container_Workbench; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GUI_TradeTable extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/ProjectTable.png"); + + public GUI_TradeTable(final InventoryPlayer player_inventory, final TileEntityTradeTable te){ + super(new Container_TradeTable(player_inventory, te)); + } + + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j){ + //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + + } + + + @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(){ + //You have to add this line for the Gui to function properly! + super.initGui(); + + //The parameters of GuiButton are(id, x, y, width, height, text); + //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + //NOTE: the id always has to be different or else it might get called twice or never! + + //Add any other buttons here too! + } + + @Override + protected void actionPerformed(final GuiButton B){ + + + } + +}
\ 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 cb120f0254..5abc35eaf5 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; @@ -30,7 +31,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI4 = 3; //Workbench public static final int GUI5 = 4; //Workbench Adv public static final int GUI6 = 5; //Fish trap - public static final int GUI7 = 6; // + public static final int GUI7 = 6; //Trade table public static final int GUI8 = 7; // @@ -56,8 +57,6 @@ public class GuiHandler implements IGuiHandler { //HeliumGenerator return new Container_HeliumGenerator(player.inventory, (TileEntityHeliumGenerator)te); } - - } if (ID == GUI3) @@ -68,18 +67,19 @@ public class GuiHandler implements IGuiHandler { if (te != null){ if (ID == GUI4){ - return new Container_Workbench(player.inventory, (TileEntityWorkbench)te); - } - if (ID == GUI5){ + else if (ID == GUI5){ Utils.LOG_INFO("sad"); return new Container_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced)te); } - if (ID == GUI6){ + else if (ID == GUI6){ return new Container_FishTrap(player.inventory, (TileEntityFishTrap)te); } + else if (ID == GUI7){ + return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); + } } @@ -116,13 +116,16 @@ public class GuiHandler implements IGuiHandler { if (ID == GUI4){ return new GUI_Workbench(player.inventory, (TileEntityWorkbench)te); } - if (ID == GUI5){ + else if (ID == GUI5){ Utils.LOG_INFO("sad"); return new GUI_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced)te); } - if (ID == GUI6){ + else if (ID == GUI6){ return new GUI_FishTrap(player.inventory, (TileEntityFishTrap)te); } + else if (ID == GUI1){ + return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te); + } } return null; diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 2e644d6f9b..6d089ee29c 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.tileentities; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.tileentities.general.*; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; @@ -23,6 +24,7 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityFirepit.class, "TileFirePit"); GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); + GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java new file mode 100644 index 0000000000..b3ed225e31 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java @@ -0,0 +1,168 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.List; +import java.util.Vector; + +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.inventories.*; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import ic2.api.network.INetworkDataProvider; +import ic2.api.network.INetworkUpdateListener; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityTradeTable extends TileEntity implements INetworkDataProvider, INetworkUpdateListener, IWrenchable{ + + public InventoryProjectMain inventoryGrid; + public InventoryProjectOutput inventoryOutputs; + + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix; + public IInventory craftResult; + private Container_TradeTable container; + + public TileEntityTradeTable(){ + this.inventoryGrid = new InventoryProjectMain();//number of slots - without product slot + this.inventoryOutputs = new InventoryProjectOutput();//number of slots - without product slot + this.canUpdate(); + } + + public void setContainer(Container_TradeTable container_TradeTable){ + this.container = container_TradeTable; + } + + @SuppressWarnings("static-method") + 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); + nbt.setShort("facing", this.facing); + this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); + this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); + + } + + @Override + public void readFromNBT(final NBTTagCompound nbt){ + super.readFromNBT(nbt); + this.prevFacing = (this.facing = nbt.getShort("facing")); + this.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); + this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); + } + + @Override + public List<String> getNetworkedFields(){ + final List<String> ret = new Vector(2); + ret.add("facing"); + return ret; + } + + + @Override + public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side){ + return false; + } + + private short facing = 0; + public short prevFacing = 0; + + @Override + public void setFacing(final short facing1){ + this.facing = facing1; + if (this.prevFacing != facing1) { + IC2.network.get().updateTileEntityField(this, "facing"); + } + this.prevFacing = facing1; + } + + @Override + public short getFacing(){ + return this.facing; + } + + + @Override + public boolean wrenchCanRemove(final EntityPlayer entityPlayer){ + return true; + } + + @Override + public float getWrenchDropRate(){ + return 1.0F; + } + + @Override + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer){ + return new ItemStack(this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), 1, this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); + } + + @Override + public void onNetworkUpdate(final String field) { + this.prevFacing = this.facing; + + } + + @Override + public void updateEntity() { + + //Data stick + ItemStack dataStick = this.inventoryOutputs.getStackInSlot(0); + if (dataStick != null && this.container != null){ + Utils.LOG_WARNING("Found Data Stick and valid container."); + + + ItemStack outputComponent = container.getOutputContent(); + ItemStack[] craftInputComponent = container.getInputComponents(); + + + ItemStack newStick = NBTUtils.writeItemsToNBT(dataStick, new ItemStack[]{outputComponent}, "Output"); + newStick = NBTUtils.writeItemsToNBT(newStick, craftInputComponent); + NBTUtils.setBookTitle(newStick, "Encrypted Project Data"); + int slotm=0; + Utils.LOG_WARNING("Uploading to Data Stick."); + for (ItemStack is : NBTUtils.readItemsFromNBT(newStick)){ + if (is != null){ + Utils.LOG_WARNING("Uploaded "+is.getDisplayName()+" into memory slot "+slotm+"."); + } + else { + Utils.LOG_WARNING("Left memory slot "+slotm+" blank."); + } + slotm++; + } + Utils.LOG_WARNING("Encrypting Data Stick."); + this.inventoryOutputs.setInventorySlotContents(1, newStick); + this.inventoryOutputs.setInventorySlotContents(0, null); + } + super.updateEntity(); + } + + @Override + public boolean canUpdate() { + return true; + } + + + + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java index 4e379d8eac..ce04ef8658 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_Cyclotron.java @@ -275,6 +275,8 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas return TexturesGtBlock.Overlay_Machine_Dimensional_Orange; } return TexturesGtBlock.Overlay_Machine_Dimensional_Blue; + //mobessence + } |