From bad0601f3e340e66ce164d124cb7105445158981 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sat, 11 Nov 2017 02:36:20 +1000 Subject: + More work on modular stuff. --- .../block/machine/Machine_ModularityTable.java | 80 +++++++ .../core/container/Container_ModularityTable.java | 236 +++++++++++++++++++++ .../core/gui/machine/GUI_ModularityTable.java | 38 ++++ src/Java/gtPlusPlus/core/handler/GuiHandler.java | 7 +- src/Java/gtPlusPlus/core/item/ModItems.java | 2 + .../gtPlusPlus/core/item/bauble/BaseBauble.java | 10 +- .../gtPlusPlus/core/item/bauble/ModularBauble.java | 123 +++++++++-- .../core/tileentities/ModTileEntities.java | 3 + .../machines/TileEntityModularityTable.java | 104 +++++++++ .../core/util/nbt/ModularArmourUtils.java | 11 + 10 files changed, 595 insertions(+), 19 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java create mode 100644 src/Java/gtPlusPlus/core/container/Container_ModularityTable.java create mode 100644 src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java create mode 100644 src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java (limited to 'src/Java/gtPlusPlus') diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java new file mode 100644 index 0000000000..d95fc7a985 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java @@ -0,0 +1,80 @@ +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 gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +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.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Machine_ModularityTable extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public Machine_ModularityTable() + { + super(Material.iron); + this.setBlockName("blockModularity"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockModularity"); + LanguageRegistry.addName(this, "Modularity Configurator"); + + } + + /** + * 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/" + "cover_crafting"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + } + + /** + * 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; + } + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityModularityTable)){ + player.openGui(GTplusplus.instance, 1, world, x, y, z); + return true; + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityModularityTable(); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java b/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java new file mode 100644 index 0000000000..df3ee63f92 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java @@ -0,0 +1,236 @@ +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.TileEntityModularityTable; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.*; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; + +public class Container_ModularityTable extends Container { + + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); + + protected TileEntityModularityTable 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_ModularityTable(final InventoryPlayer inventory, final TileEntityModularityTable tile){ + this.tile_entity = tile; + this.inventoryGrid = tile.inventoryGrid; + this.inventoryOutputs = tile.inventoryOutputs; + this.tile_entity.setContainer(this); + + int var6; + int var7; + this.worldObj = tile.getWorldObj(); + this.posX = tile.xCoord; + this.posY = tile.yCoord; + this.posZ = tile.zCoord; + + int nextFreeSlot = 0; + + + //Output slots + 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) + { + 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 attributes, ItemStack stack) { - attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 40, 0)); + + //Get Stats + int mStatlevel = 0; + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0){ + if (mStatlevel == 1){ + attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 1, 0)); + } + else if (mStatlevel == 2){ + attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 2, 0)); + } + else if (mStatlevel == 3){ + attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 4, 0)); + } + else if (mStatlevel == 4){ + attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 8, 0)); + } + else if (mStatlevel == 5){ + attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 16, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0){ + if (mStatlevel == 1){ + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 1, 0)); + } + else if (mStatlevel == 2){ + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 2, 0)); + } + else if (mStatlevel == 3){ + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 3, 0)); + } + else if (mStatlevel == 4){ + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 6, 0)); + } + else if (mStatlevel == 5){ + attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 10, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0){ + if (mStatlevel == 1){ + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 15, 0)); + } + else if (mStatlevel == 2){ + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 20, 0)); + } + else if (mStatlevel == 3){ + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 25, 0)); + } + else if (mStatlevel == 4){ + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 30, 0)); + } + else if (mStatlevel == 5){ + attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 40, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0){ + if (mStatlevel == 1){ + attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 1, 0)); + } + else if (mStatlevel == 2){ + attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 2, 0)); + } + else if (mStatlevel == 3){ + attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 3, 0)); + } + else if (mStatlevel == 4){ + attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 4, 0)); + } + else if (mStatlevel == 5){ + attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 5, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0){ + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0){ + } + } - + + @SuppressWarnings({ "unchecked"}) @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { //Bauble Type @@ -46,7 +121,7 @@ public class ModularBauble extends BaseBauble{ list.add(EnumChatFormatting.GRAY+"Current Form: "+EnumChatFormatting.RED+"Belt"+EnumChatFormatting.GRAY+"."); list.add(EnumChatFormatting.GRAY+"You can change this into a Ring or an Amulet."); } - + //Get Stats int mStatlevel = 0; if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0){ @@ -67,14 +142,34 @@ public class ModularBauble extends BaseBauble{ if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0){ list.add(EnumChatFormatting.GRAY+"Holy Boost: "+EnumChatFormatting.GOLD+mStatlevel+EnumChatFormatting.GRAY+"."); } - + super.addInformation(stack, player, list, bool); } @Override - public boolean addDamageNegation(DamageSource damageSource) { - // TODO Auto-generated method stub - return super.addDamageNegation(damageSource); + public boolean addDamageNegation(DamageSource damageSource,ItemStack aStack) { + + this.clearDamageNegation(); + int mStatlevel = 0; + if ((mStatlevel = ModularArmourUtils.getModifierLevel(aStack, Modifiers.BOOST_HOLY)) > 0){ + addDamageNegation(DamageSource.cactus); + if (mStatlevel == 1){ + addDamageNegation(DamageSource.inWall); + } + else if (mStatlevel == 2){ + addDamageNegation(DamageSource.drown); + } + else if (mStatlevel == 3){ + addDamageNegation(DamageSource.starve); + } + else if (mStatlevel == 4){ + addDamageNegation(DamageSource.fall); + } + else if (mStatlevel == 5){ + addDamageNegation(DamageSource.lava); + } + } + return super.addDamageNegation(damageSource, null); } @Override @@ -110,8 +205,8 @@ public class ModularBauble extends BaseBauble{ // TODO Auto-generated method stub super.onUnequipped(stack, player); } - - - - + + + + } diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 6d089ee29c..6eb1942493 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.tileentities; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.tileentities.general.*; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; @@ -25,6 +26,8 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); + GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); + } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java new file mode 100644 index 0000000000..592ee8a9b6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java @@ -0,0 +1,104 @@ +package gtPlusPlus.core.tileentities.machines; + +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; +import gtPlusPlus.core.inventories.projecttable.InventoryProjectOutput; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityModularityTable extends TileEntity { + + public InventoryProjectMain inventoryGrid; + public InventoryProjectOutput inventoryOutputs; + + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix; + public IInventory craftResult; + private Container_ModularityTable container; + + public TileEntityModularityTable(){ + 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_ModularityTable container_ModularityTable){ + this.container = container_ModularityTable; + } + + @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); + 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.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); + this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); + } + + @Override + public void updateEntity() { + if (!this.worldObj.isRemote){ + //Data stick + ItemStack dataStick = this.inventoryOutputs.getStackInSlot(0); + if (dataStick != null && this.container != null && container.getOutputContent() != 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"); + NBTUtils.setBoolean(newStick, "mEncrypted", true); + 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/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java index 5fb70ab540..d37e79b8cb 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java @@ -125,4 +125,15 @@ public class ModularArmourUtils { } } + public static ItemStack setDefaultStats(ItemStack aStack){ + ItemStack tempStack = aStack; + setModifierLevel(tempStack, Modifiers.BOOST_DAMAGE, 0); + setModifierLevel(tempStack, Modifiers.BOOST_DEF, 0); + setModifierLevel(tempStack, Modifiers.BOOST_HOLY, 0); + setModifierLevel(tempStack, Modifiers.BOOST_HP, 0); + setModifierLevel(tempStack, Modifiers.BOOST_MINING, 0); + setModifierLevel(tempStack, Modifiers.BOOST_SPEED, 0); + return tempStack; + } + } -- cgit