From aa563b79fea267830f563a9d3d5d61f9f531b16f Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 22 Sep 2017 14:59:49 +1000 Subject: + More Trade Table work. --- .../core/block/machine/Machine_TradeTable.java | 77 ++-------------------- .../core/container/Container_ProjectTable.java | 4 +- .../core/container/Container_TradeTable.java | 14 +--- .../core/gui/machine/GUI_TradeTable.java | 31 +-------- src/Java/gtPlusPlus/core/handler/GuiHandler.java | 2 +- .../core/item/base/itemblock/ItemBlockBase.java | 1 - .../core/item/base/itemblock/ItemBlockNBT.java | 15 +++++ .../machines/TileEntityTradeTable.java | 47 +------------ .../multi/GregtechMetaTileEntity_Cyclotron.java | 6 +- 9 files changed, 31 insertions(+), 166 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java (limited to 'src/Java/gtPlusPlus') diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java index fc155765c6..6af3aa36e4 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -1,6 +1,5 @@ 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; @@ -8,24 +7,16 @@ 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.TileEntityTradeTable; -import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; -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) @@ -70,19 +61,7 @@ public class Machine_TradeTable extends BlockContainer * 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); - } + 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; @@ -91,11 +70,12 @@ public class Machine_TradeTable extends BlockContainer final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityTradeTable)) { - if (!holdingWrench){ + //Utils.LOG_INFO("Clicked on TE - ok"); player.openGui(GTplusplus.instance, 6, world, x, y, z); return true; - } - Utils.LOG_INFO("Holding a Wrench, doing wrench things instead."); + } + else { + Utils.LOG_INFO("Bad TE"); } return false; } @@ -105,51 +85,4 @@ public class Machine_TradeTable extends BlockContainer return new TileEntityTradeTable(); } - 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_ProjectTable.java b/src/Java/gtPlusPlus/core/container/Container_ProjectTable.java index 3a256d07a9..25e6756f71 100644 --- a/src/Java/gtPlusPlus/core/container/Container_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/container/Container_ProjectTable.java @@ -50,8 +50,8 @@ public class Container_ProjectTable extends Container { //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 SlotDataStick(this.inventoryOutputs, 0, 26+(18*6), 8)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26+(18*6), 44)); this.addSlotToContainer(new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26+(18*4), 25)); diff --git a/src/Java/gtPlusPlus/core/container/Container_TradeTable.java b/src/Java/gtPlusPlus/core/container/Container_TradeTable.java index b0345ba8a6..bdf349abb8 100644 --- a/src/Java/gtPlusPlus/core/container/Container_TradeTable.java +++ b/src/Java/gtPlusPlus/core/container/Container_TradeTable.java @@ -1,21 +1,15 @@ package gtPlusPlus.core.container; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.inventories.InventoryWorkbenchChest; -import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; -import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; import gtPlusPlus.core.inventories.tradetable.InventoryTradeMain; import gtPlusPlus.core.inventories.tradetable.InventoryTradeOutput; 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 { @@ -50,12 +44,11 @@ public class Container_TradeTable extends Container { //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 SlotDataStick(this.inventoryOutputs, 0, 26+(18*6), 8)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26+(18*6), 44)); //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) @@ -86,7 +79,6 @@ public class Container_TradeTable extends Container { } //this.onCraftMatrixChanged(this.craftMatrix); - } /** @@ -132,7 +124,7 @@ public class Container_TradeTable extends Container { @Override public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockProjectTable){ + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockTradeTable){ return false; } diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java index 5b5a919291..70bfed3be3 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java @@ -11,6 +11,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; +import gtPlusPlus.core.util.Utils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; @@ -25,15 +26,6 @@ public class GUI_TradeTable extends GuiContainer { 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); @@ -43,25 +35,4 @@ public class GUI_TradeTable extends GuiContainer { 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 5abc35eaf5..55235e614e 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -123,7 +123,7 @@ public class GuiHandler implements IGuiHandler { else if (ID == GUI6){ return new GUI_FishTrap(player.inventory, (TileEntityFishTrap)te); } - else if (ID == GUI1){ + else if (ID == GUI7){ return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te); } } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java index bccfeaebab..372539ca7d 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java @@ -14,7 +14,6 @@ public class ItemBlockBase extends ItemBlock { @Override public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { - return super.getColorFromItemStack(p_82790_1_, p_82790_2_); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java new file mode 100644 index 0000000000..454b41ffe5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java @@ -0,0 +1,15 @@ +package gtPlusPlus.core.item.base.itemblock; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemBlock; + +public class ItemBlockNBT extends ItemBlock { + + public ItemBlockNBT(final Block block, final CreativeTabs tab) { + super(block); + this.setCreativeTab(tab); + } + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java index 911fb7b40e..c8998b5bab 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java @@ -3,43 +3,27 @@ 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.inventories.tradetable.InventoryTradeMain; import gtPlusPlus.core.inventories.tradetable.InventoryTradeOutput; -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 InventoryTradeMain inventoryGrid; public InventoryTradeOutput inventoryOutputs; - - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix; - public IInventory craftResult; private Container_TradeTable container; public TileEntityTradeTable(){ this.inventoryGrid = new InventoryTradeMain();//number of slots - without product slot this.inventoryOutputs = new InventoryTradeOutput();//number of slots - without product slot - this.canUpdate(); } public void setContainer(Container_TradeTable container_TradeTable){ @@ -74,7 +58,7 @@ public class TileEntityTradeTable extends TileEntity implements INetworkDataProv @Override public List getNetworkedFields(){ - final List ret = new Vector(2); + final List ret = new Vector(2); ret.add("facing"); return ret; } @@ -126,35 +110,6 @@ public class TileEntityTradeTable extends TileEntity implements INetworkDataProv @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(); } 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 ce04ef8658..a6fc495bab 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 @@ -150,11 +150,11 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas mHardHammer = true; mSolderingTool = true; mCrowbar = true; - Utils.LOG_INFO("Built Cyclotron."); + //Utils.LOG_INFO("Built Cyclotron."); turnCasingActive(true); return true; } - Utils.LOG_INFO("Failed building Cyclotron."); + //Utils.LOG_INFO("Failed building Cyclotron."); return false; } @@ -286,7 +286,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas @Override public boolean checkRecipe(ItemStack aStack) { - Utils.LOG_INFO("Recipe Check."); + //Utils.LOG_INFO("Recipe Check."); ArrayList tItemList = getStoredInputs(); ItemStack[] tItemInputs = (ItemStack[]) tItemList.toArray(new ItemStack[tItemList.size()]); ArrayList tInputList = getStoredFluids(); -- cgit