aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_ModularityTable.java118
-rw-r--r--src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java18
-rw-r--r--src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java202
-rw-r--r--src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java188
-rw-r--r--src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java140
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotModularBauble.java31
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java73
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java172
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java22
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java16
10 files changed, 832 insertions, 148 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java b/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java
index 68b46d9aca..edc84a8c5f 100644
--- a/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java
+++ b/src/Java/gtPlusPlus/core/container/Container_ModularityTable.java
@@ -1,14 +1,18 @@
package gtPlusPlus.core.container;
import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.inventories.modulartable.InventoryModularMain;
+import gtPlusPlus.core.inventories.modulartable.InventoryModularOutput;
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.tileentities.machines.TileEntityProjectTable;
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;
@@ -16,26 +20,21 @@ 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;
+ public final InventoryModularMain inventoryGrid;
+ public final InventoryModularOutput 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[] slotOutputs = new int[3];
private final int[] slotGrid = new int[9];
public Container_ModularityTable(final InventoryPlayer inventory, final TileEntityModularityTable tile){
-
- Utils.LOG_INFO("container created");
-
this.tile_entity = tile;
this.inventoryGrid = tile.inventoryGrid;
this.inventoryOutputs = tile.inventoryOutputs;
@@ -49,29 +48,14 @@ public class Container_ModularityTable extends Container {
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++;
- }
- }
+ this.addSlotToContainer(new SlotModularBauble(this.inventoryOutputs, 0, 26+(18*6), 8));
+ this.addSlotToContainer(new SlotModularBaubleUpgrades(this.inventoryOutputs, 1, 26+(18*5), 8));
+ this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 2, 26+(18*6), 44));
+ int o = 0;
//Player Inventory
for (var6 = 0; var6 < 3; ++var6)
@@ -87,33 +71,33 @@ public class Container_ModularityTable extends Container {
{
this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142));
}
-
- this.onCraftMatrixChanged(this.craftMatrix);
+
+ //this.onCraftMatrixChanged(this.craftMatrix);
}
-
+
/**
- * Callback for when the crafting matrix is changed.
- */
- public void onCraftMatrixChanged(IInventory p_75130_1_)
+ * 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){
+ }*/
+
+ /**
+ * 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){
@@ -124,26 +108,32 @@ public class Container_ModularityTable extends Container {
}
if (aSlotIndex == 0){
- Utils.LOG_INFO("Player Clicked on the Data Stick slot");
+ Utils.LOG_INFO("Player Clicked on the bauble slot");
+ //TODO
+ }
+ else if (aSlotIndex == 1){
+ Utils.LOG_INFO("Player Clicked on the upgrade slot");
//TODO
- }if (aSlotIndex == 1){
+ }
+ else if (aSlotIndex == 2){
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");
+ else {
+ 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){
+ if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockModularTable){
return false;
}
@@ -154,9 +144,9 @@ public class Container_ModularityTable extends Container {
@Override
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2)
{
-
+
return null;
-
+
/*ItemStack var3 = null;
final Slot var4 = (Slot)this.inventorySlots.get(par2);
@@ -214,18 +204,18 @@ public class Container_ModularityTable extends Container {
}
//Can merge Slot
- public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_){
+ /*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(){
+ }*/
+
+ /*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++){
@@ -233,7 +223,7 @@ public class Container_ModularityTable extends Container {
inputs[r] = temp;
}
return inputs;
- }
+ }*/
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java
index a89fd8142c..41ab5cce49 100644
--- a/src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java
+++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java
@@ -7,7 +7,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.container.Container_ModularityTable;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable;
-import gtPlusPlus.core.util.Utils;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -20,12 +19,14 @@ public class GUI_ModularityTable extends GuiContainer {
public GUI_ModularityTable(final InventoryPlayer player_inventory, final TileEntityModularityTable tile){
super(new Container_ModularityTable(player_inventory, tile));
- Utils.LOG_INFO("valid gui created");
}
@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);
+
}
@@ -38,14 +39,25 @@ public class GUI_ModularityTable 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/inventories/modulartable/InventoryModularMain.java b/src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java
new file mode 100644
index 0000000000..5b7d85335b
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java
@@ -0,0 +1,202 @@
+package gtPlusPlus.core.inventories.modulartable;
+
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryModularMain implements IInventory{
+
+ private final String name = "Inventory Grid";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 9;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public InventoryModularMain()
+ {
+
+ }
+
+ public void readFromNBT(final NBTTagCompound nbt)
+ {
+ final NBTTagList list = nbt.getTagList("Items", 10);
+ this.inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ final NBTTagCompound data = list.getCompoundTagAt(i);
+ final int slot = data.getInteger("Slot");
+ if((slot >= 0) && (slot < INV_SIZE))
+ {
+ this.inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(final NBTTagCompound nbt)
+ {
+ final NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ final ItemStack stack = this.inventory[i];
+ if(stack != null)
+ {
+ final NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return this.inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return this.inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot)
+ {
+ //Utils.LOG_INFO("getStackInSlot["+slot+"]");
+ try {
+ if (slot>= this.inventory.length){
+ //Utils.LOG_INFO("Returning invalid slot item.");
+ return null;
+ }
+ return this.inventory[slot];
+ } catch (Throwable t){
+ t.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int amount)
+ {
+ ItemStack stack = this.getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ this.setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot)
+ {
+ final ItemStack stack = this.getStackInSlot(slot);
+ this.setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack)
+ {
+ if (slot >= this.inventory.length){
+ return;
+ }
+ this.inventory[slot] = stack;
+
+ if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit()))
+ {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return this.name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return this.name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < this.getSizeInventory(); ++i)
+ {
+ final ItemStack temp = this.getStackInSlot(i);
+ if (temp != null){
+ //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize);
+ }
+
+ if ((temp != null) && (temp.stackSize == 0)) {
+ this.inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java b/src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java
new file mode 100644
index 0000000000..0a4dc07a39
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java
@@ -0,0 +1,188 @@
+package gtPlusPlus.core.inventories.modulartable;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryModularOutput implements IInventory{
+
+ private final String name = "Inventory Output";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 3;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public InventoryModularOutput()
+ {
+
+ }
+
+ public void readFromNBT(final NBTTagCompound nbt)
+ {
+ final NBTTagList list = nbt.getTagList("Items", 10);
+ this.inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ final NBTTagCompound data = list.getCompoundTagAt(i);
+ final int slot = data.getInteger("Slot");
+ if((slot >= 0) && (slot < INV_SIZE))
+ {
+ this.inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(final NBTTagCompound nbt)
+ {
+ final NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ final ItemStack stack = this.inventory[i];
+ if(stack != null)
+ {
+ final NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return this.inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return this.inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot)
+ {
+ return this.inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int amount)
+ {
+ ItemStack stack = this.getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ this.setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot)
+ {
+ final ItemStack stack = this.getStackInSlot(slot);
+ this.setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack)
+ {
+ this.inventory[slot] = stack;
+
+ if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit()))
+ {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return this.name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return this.name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < this.getSizeInventory(); ++i)
+ {
+ final ItemStack temp = this.getStackInSlot(i);
+ if (temp != null){
+ //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize);
+ }
+
+ if ((temp != null) && (temp.stackSize == 0)) {
+ this.inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java
index 46f290753b..4ba475f4be 100644
--- a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java
+++ b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java
@@ -13,6 +13,7 @@ import gtPlusPlus.core.util.nbt.ModularArmourUtils;
import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT;
import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers;
import gtPlusPlus.core.util.nbt.NBTUtils;
+import gtPlusPlus.core.util.player.PlayerUtils;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
@@ -37,70 +38,70 @@ public class ModularBauble extends BaseBauble{
//Get Stats
int mStatlevel = 0;
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0){
- if (mStatlevel == 1){
+ if (mStatlevel > 0 && mStatlevel < 20){
attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 1, 0));
}
- else if (mStatlevel == 2){
+ else if (mStatlevel > 20 && mStatlevel < 45){
attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 2, 0));
}
- else if (mStatlevel == 3){
+ else if (mStatlevel >= 45 && mStatlevel < 75){
attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 4, 0));
}
- else if (mStatlevel == 4){
+ else if (mStatlevel >= 75 && mStatlevel < 99){
attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "AD"+mStatlevel, 8, 0));
}
- else if (mStatlevel == 5){
+ else if (mStatlevel >= 100){
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){
+ if (mStatlevel > 0 && mStatlevel < 20){
attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 1, 0));
}
- else if (mStatlevel == 2){
+ else if (mStatlevel > 20 && mStatlevel < 45){
attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 2, 0));
}
- else if (mStatlevel == 3){
+ else if (mStatlevel > 45 && mStatlevel < 75){
attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 3, 0));
}
- else if (mStatlevel == 4){
+ else if (mStatlevel > 75 && mStatlevel < 99){
attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "BD"+mStatlevel, 6, 0));
}
- else if (mStatlevel == 5){
+ else if (mStatlevel >= 100){
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){
+ if (mStatlevel > 0 && mStatlevel < 20){
attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 15, 0));
}
- else if (mStatlevel == 2){
+ else if (mStatlevel > 20 && mStatlevel < 45){
attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 20, 0));
}
- else if (mStatlevel == 3){
+ else if (mStatlevel > 45 && mStatlevel < 75){
attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 25, 0));
}
- else if (mStatlevel == 4){
+ else if (mStatlevel > 75 && mStatlevel < 99){
attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "HP"+mStatlevel, 30, 0));
}
- else if (mStatlevel == 5){
+ else if (mStatlevel >= 100){
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){
+ if (mStatlevel > 0 && mStatlevel < 20){
attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 1, 0));
}
- else if (mStatlevel == 2){
+ else if (mStatlevel > 20 && mStatlevel < 45){
attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 2, 0));
}
- else if (mStatlevel == 3){
+ else if (mStatlevel > 45 && mStatlevel < 75){
attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 3, 0));
}
- else if (mStatlevel == 4){
+ else if (mStatlevel > 75 && mStatlevel < 99){
attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 4, 0));
}
- else if (mStatlevel == 5){
+ else if (mStatlevel >= 100){
attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "SP"+mStatlevel, 5, 0));
}
}
@@ -131,23 +132,63 @@ public class ModularBauble extends BaseBauble{
//Get Stats
int mStatlevel = 0;
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0){
- list.add(EnumChatFormatting.GRAY+"Damage Boost: "+EnumChatFormatting.DARK_RED+mStatlevel+EnumChatFormatting.GRAY+".");
- }
- if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0){
- list.add(EnumChatFormatting.GRAY+"Defence Boost: "+EnumChatFormatting.BLUE+mStatlevel+EnumChatFormatting.GRAY+".");
+ list.add(EnumChatFormatting.GRAY+"Damage Boost: "+EnumChatFormatting.DARK_RED+mStatlevel+EnumChatFormatting.GRAY+"/100.");
}
+
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0){
- list.add(EnumChatFormatting.GRAY+"Health Boost: "+EnumChatFormatting.RED+mStatlevel+EnumChatFormatting.GRAY+".");
+ list.add(EnumChatFormatting.GRAY+"Health Boost: "+EnumChatFormatting.RED+mStatlevel+EnumChatFormatting.GRAY+"/100.");
}
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0){
- list.add(EnumChatFormatting.GRAY+"Speed Boost: "+EnumChatFormatting.WHITE+mStatlevel+EnumChatFormatting.GRAY+".");
+ list.add(EnumChatFormatting.GRAY+"Speed Boost: "+EnumChatFormatting.WHITE+mStatlevel+EnumChatFormatting.GRAY+"/100.");
}
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0){
- list.add(EnumChatFormatting.GRAY+"Mining Boost: "+EnumChatFormatting.DARK_GRAY+mStatlevel+EnumChatFormatting.GRAY+".");
+ list.add(EnumChatFormatting.GRAY+"Mining Boost: "+EnumChatFormatting.DARK_GRAY+mStatlevel+EnumChatFormatting.GRAY+"/100.");
}
if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0){
- list.add(EnumChatFormatting.GRAY+"Holy Boost: "+EnumChatFormatting.GOLD+mStatlevel+EnumChatFormatting.GRAY+".");
+ list.add(EnumChatFormatting.GRAY+"Holy Boost: "+EnumChatFormatting.GOLD+mStatlevel+EnumChatFormatting.GRAY+"/100.");
+ }
+
+ //Defence Boost
+ if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0){
+ list.add(EnumChatFormatting.GRAY+"Defence Boost: "+EnumChatFormatting.BLUE+mStatlevel+EnumChatFormatting.GRAY+"/100.");
+
+ if (mStatlevel >= 1){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Cactus"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 10){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Falling Blocks"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 20){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Wall Suffocation"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 35){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Drowning"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 50){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Starvation"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 60){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Falling"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 75){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Lava"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 80){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Magic"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 95){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Wither"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 100){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Fire"+EnumChatFormatting.GRAY+".");
+ }
+ if (mStatlevel >= 100){
+ list.add(EnumChatFormatting.GRAY+"Protected From: "+EnumChatFormatting.BLUE+"Void"+EnumChatFormatting.GRAY+".");
+ }
+
}
+
+
if (NBTUtils.getBotanicaSoulboundOwner(stack) != null){
if (!NBTUtils.getBotanicaSoulboundOwner(stack).equals("")){
list.add(EnumChatFormatting.GRAY+"Relic Owner: "+EnumChatFormatting.GREEN+NBTUtils.getBotanicaSoulboundOwner(stack)+EnumChatFormatting.GRAY+".");
@@ -163,22 +204,42 @@ public class ModularBauble extends BaseBauble{
this.clearDamageNegation();
int mStatlevel = 0;
if ((mStatlevel = ModularArmourUtils.getModifierLevel(aStack, Modifiers.BOOST_HOLY)) > 0){
- addDamageNegation(DamageSource.cactus);
- if (mStatlevel == 1){
+ if (mStatlevel >= 1){
+ addDamageNegation(DamageSource.cactus);
+ }
+ if (mStatlevel >= 10){
+ addDamageNegation(DamageSource.fallingBlock);
+ }
+ if (mStatlevel >= 20){
addDamageNegation(DamageSource.inWall);
}
- else if (mStatlevel == 2){
+ if (mStatlevel >= 35){
addDamageNegation(DamageSource.drown);
}
- else if (mStatlevel == 3){
+ if (mStatlevel >= 50){
addDamageNegation(DamageSource.starve);
}
- else if (mStatlevel == 4){
+ if (mStatlevel >= 60){
addDamageNegation(DamageSource.fall);
}
- else if (mStatlevel == 5){
+ if (mStatlevel >= 75){
addDamageNegation(DamageSource.lava);
}
+ if (mStatlevel >= 80){
+ addDamageNegation(DamageSource.magic);
+ }
+ if (mStatlevel >= 95){
+ addDamageNegation(DamageSource.wither);
+ }
+ if (mStatlevel >= 100){
+ addDamageNegation(DamageSource.inFire);
+ }
+ if (mStatlevel >= 100){
+ addDamageNegation(DamageSource.onFire);
+ }
+ if (mStatlevel >= 100){
+ addDamageNegation(DamageSource.outOfWorld);
+ }
}
return super.addDamageNegation(damageSource, null);
}
@@ -197,6 +258,9 @@ public class ModularBauble extends BaseBauble{
else {
this.SetBaubleType(BT.TYPE_RING);
}
+ if (PlayerUtils.isPlayerOP((EntityPlayer) arg1)){
+ return true; //Let OPs wear other peoples shit.
+ }
String mOwner;
if (NBTUtils.getBotanicaSoulboundOwner(arg0) == null || NBTUtils.getBotanicaSoulboundOwner(arg0).equals("")){
@@ -279,7 +343,7 @@ public class ModularBauble extends BaseBauble{
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
- if (usingItem == null) { return itemIcon; }
+ if (usingItem == null) { return mfallback; }
try {
if (ModularArmourUtils.getBaubleType(stack) == BaubleType.AMULET){
return iconArray[0];
@@ -291,20 +355,22 @@ public class ModularBauble extends BaseBauble{
return iconArray[2];
}
else {
- return iconArray[0];
+ return mfallback;
}
}
catch (Throwable t){
- return itemIcon;
+ return mfallback;
}
}
private IIcon iconArray[] = new IIcon[3];
+ private IIcon mfallback;
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
+ this.mfallback = register.registerIcon("baubles" + ":" + "ring");
// you cannot initialize iconArray when declared nor in the constructor, as it is client-side only, so do it here:
if (LoadedMods.Thaumcraft){
iconArray[0] = register.registerIcon("thaumcraft" + ":" + "bauble_amulet");
diff --git a/src/Java/gtPlusPlus/core/slots/SlotModularBauble.java b/src/Java/gtPlusPlus/core/slots/SlotModularBauble.java
new file mode 100644
index 0000000000..8a87552d0f
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotModularBauble.java
@@ -0,0 +1,31 @@
+package gtPlusPlus.core.slots;
+
+import gtPlusPlus.core.item.bauble.ModularBauble;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotModularBauble extends Slot{
+
+ public SlotModularBauble(final IInventory inventory, final int slot, final int x, final int y) {
+ super(inventory, slot, x, y);
+
+ }
+
+ @Override
+ public boolean isItemValid(final ItemStack itemstack) {
+ boolean isValid = false;
+
+ if (itemstack != null){
+ if (itemstack.getItem() instanceof ModularBauble){
+ isValid = true;
+ }
+ }
+ return isValid;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java
new file mode 100644
index 0000000000..532f3efcfb
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java
@@ -0,0 +1,73 @@
+package gtPlusPlus.core.slots;
+
+import static gtPlusPlus.core.tileentities.machines.TileEntityModularityTable.mValidUpgradeList;
+import static gtPlusPlus.core.tileentities.machines.TileEntityModularityTable.mValidUpgradeListFormChange;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.array.Pair;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotModularBaubleUpgrades extends Slot{
+
+ public SlotModularBaubleUpgrades(final IInventory inventory, final int slot, final int x, final int y) {
+ super(inventory, slot, x, y);
+
+ }
+
+ @Override
+ public boolean isItemValid(final ItemStack itemstack) {
+ boolean isValid = false;
+
+ if (itemstack != null){
+ Utils.LOG_INFO("trying to insert "+itemstack.getDisplayName());
+ Utils.LOG_INFO("Valid Upgrade count: "+mValidUpgradeList.size());
+ if (mValidUpgradeList.containsKey(itemstack)){
+ isValid = true;
+ }
+ else {
+ Iterator<Entry<ItemStack, Pair<Modifiers, Integer>>> it = mValidUpgradeList.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<ItemStack, Pair<Modifiers, Integer>> pair = it.next();
+
+ if (pair.getKey().getItem() == itemstack.getItem()
+ && pair.getKey().getItemDamage() == itemstack.getItemDamage()){
+ isValid = true;
+ }
+
+ //Utils.LOG_INFO("Found "+pair.getKey().getDisplayName()+" giving "+pair.getValue().getKey().name()+".");
+ }
+ }
+ Utils.LOG_INFO("Valid Form Upgrade count: "+mValidUpgradeListFormChange.size());
+ if (mValidUpgradeListFormChange.containsKey(itemstack)){
+ isValid = true;
+ }
+ else {
+ Iterator<Entry<ItemStack, BT>> it = mValidUpgradeListFormChange.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<ItemStack, BT> pair = it.next();
+
+ if (pair.getKey().getItem() == itemstack.getItem()
+ && pair.getKey().getItemDamage() == itemstack.getItemDamage()){
+ isValid = true;
+ }
+
+ //Utils.LOG_INFO("Found "+pair.getKey().getDisplayName()+" giving "+pair.getValue().name()+".");
+ }
+ }
+ }
+ return isValid;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
index 41e4ac7e45..5dd5f57930 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java
@@ -1,32 +1,41 @@
package gtPlusPlus.core.tileentities.machines;
+import static gtPlusPlus.core.tileentities.machines.TileEntityModularityTable.mValidUpgradeListFormChange;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
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.inventories.modulartable.InventoryModularMain;
+import gtPlusPlus.core.inventories.modulartable.InventoryModularOutput;
+import gtPlusPlus.core.item.bauble.ModularBauble;
import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.nbt.NBTUtils;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.InventoryCrafting;
+import gtPlusPlus.core.util.array.Pair;
+import gtPlusPlus.core.util.item.ItemUtils;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers;
+import net.minecraft.init.Items;
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;
+ public InventoryModularMain inventoryGrid;
+ public InventoryModularOutput inventoryOutputs;
private Container_ModularityTable container;
public TileEntityModularityTable(){
Utils.LOG_INFO("I am created.");
- this.inventoryGrid = new InventoryProjectMain();//number of slots - without product slot
- this.inventoryOutputs = new InventoryProjectOutput();//number of slots - without product slot
+ this.inventoryGrid = new InventoryModularMain();//number of slots - without product slot
+ this.inventoryOutputs = new InventoryModularOutput();//number of slots - without product slot
this.canUpdate();
+ generateAllValidUpgrades();
}
public void setContainer(Container_ModularityTable container_ModularityTable){
@@ -45,7 +54,6 @@ public class TileEntityModularityTable extends TileEntity {
@Override
public void writeToNBT(final NBTTagCompound nbt){
super.writeToNBT(nbt);
- this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid"));
this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput"));
}
@@ -53,41 +61,41 @@ public class TileEntityModularityTable extends TileEntity {
@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){
+ boolean removeInputA = false;
+ boolean removeInputB = false;
//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.");
+ ItemStack tBauble = this.inventoryOutputs.getStackInSlot(0);
+ ItemStack tUpgrade = this.inventoryOutputs.getStackInSlot(1);
+ if (tBauble != null && tUpgrade != null && this.container != null){
+ if (tBauble.getItem() instanceof ModularBauble){
+ if (tUpgrade != null && tBauble != null){
+ removeInputA = true;
+
+ Utils.LOG_INFO("found "+tUpgrade.getDisplayName());
+ try {
+ removeInputB = addUpgrade(tUpgrade, tBauble);
+ if (!removeInputB){
+ Utils.LOG_INFO("Failed to add "+tUpgrade.getDisplayName());
+ }
+ }
+ catch (Throwable t){
+
+ }
+
+ Utils.LOG_INFO("set new Modular bauble");
+ if (removeInputA && removeInputB){
+ this.inventoryOutputs.setInventorySlotContents(0, null);
+ this.inventoryOutputs.setInventorySlotContents(1, null);
+ this.inventoryOutputs.setInventorySlotContents(2, tBauble);
+ }
}
- slotm++;
}
- Utils.LOG_WARNING("Encrypting Data Stick.");
- this.inventoryOutputs.setInventorySlotContents(1, newStick);
- this.inventoryOutputs.setInventorySlotContents(0, null);
}
}
super.updateEntity();
@@ -98,8 +106,90 @@ public class TileEntityModularityTable extends TileEntity {
return true;
}
+ public static Map<ItemStack, Pair<Modifiers, Integer>> mValidUpgradeList = new HashMap<ItemStack, Pair<Modifiers, Integer>>();
+ public static Map<ItemStack, BT> mValidUpgradeListFormChange = new HashMap<ItemStack, BT>();
+
+ private static boolean generateAllValidUpgrades(){
+
+ //Form Change
+ generateUpgradeFormData(ItemList.Sensor_MV.get(1), BT.TYPE_RING);
+ generateUpgradeFormData(ItemList.Electric_Piston_MV.get(1), BT.TYPE_BELT);
+ generateUpgradeFormData(ItemList.Emitter_MV.get(1), BT.TYPE_AMULET);
+
+ //Damage Boost
+ generateUpgradeData(ItemList.Electric_Motor_LV.get(1), Modifiers.BOOST_DAMAGE, 1);
+ generateUpgradeData(ItemList.Electric_Motor_MV.get(1), Modifiers.BOOST_DAMAGE, 2);
+ generateUpgradeData(ItemList.Electric_Motor_HV.get(1), Modifiers.BOOST_DAMAGE, 3);
+ generateUpgradeData(ItemList.Electric_Motor_EV.get(1), Modifiers.BOOST_DAMAGE, 4);
+ generateUpgradeData(ItemList.Electric_Motor_IV.get(1), Modifiers.BOOST_DAMAGE, 5);
+
+ //Defence Boost
+ generateUpgradeData(Materials.Aluminium.getPlates(1), Modifiers.BOOST_DEF, 1);
+ generateUpgradeData(Materials.StainlessSteel.getPlates(1), Modifiers.BOOST_DEF, 2);
+ generateUpgradeData(Materials.Tungsten.getPlates(1), Modifiers.BOOST_DEF, 3);
+ generateUpgradeData(Materials.TungstenSteel.getPlates(1), Modifiers.BOOST_DEF, 4);
+ generateUpgradeData(Materials.Naquadah.getPlates(1), Modifiers.BOOST_DEF, 5);
+
+ //Hp Boost
+ generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 0, 1), Modifiers.BOOST_HP, 1);
+ generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), Modifiers.BOOST_HP, 2);
+ generateUpgradeData(ItemUtils.simpleMetaStack(Items.nether_star, 0, 1), Modifiers.BOOST_HP, 3);
+ generateUpgradeData(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32725", 32725, 1), Modifiers.BOOST_HP, 4);
+ generateUpgradeData(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32726", 32726, 1), Modifiers.BOOST_HP, 5);
+ return true;
+ }
+ public static boolean generateUpgradeData(ItemStack tStack, Modifiers tMod, int tLevel){
+ Pair<Modifiers, Integer> tTemp = new Pair<Modifiers, Integer>(tMod, tLevel);
+ if (mValidUpgradeList.put(tStack, tTemp) != null){
+ return true;
+ }
+ return false;
+ }
+ public static boolean generateUpgradeFormData(ItemStack tStack, BT tMod){
+ if (mValidUpgradeListFormChange.put(tStack, tMod) != null){
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean addUpgrade(ItemStack tStack, ItemStack tBauble){
+
+ if (mValidUpgradeListFormChange.containsKey(tStack)){
+ return true;
+ }
+ else {
+ Iterator<Entry<ItemStack, BT>> it = mValidUpgradeListFormChange.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<ItemStack, BT> pair = it.next();
+ if (pair.getKey().getItem() == tStack.getItem()
+ && pair.getKey().getItemDamage() == tStack.getItemDamage()){
+ ModularArmourUtils.setBaubleType(tBauble, mValidUpgradeListFormChange.get(tStack));
+ return true;
+ }
+ }
+ }
+ if (mValidUpgradeList.containsKey(tStack)){
+ return true;
+ }
+ else {
+ Iterator<Entry<ItemStack, Pair<Modifiers, Integer>>> it = mValidUpgradeList.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<ItemStack, Pair<Modifiers, Integer>> pair = it.next();
+ if (pair.getKey().getItem() == tStack.getItem()
+ && pair.getKey().getItemDamage() == tStack.getItemDamage()){
+ Pair<Modifiers, Integer> newPair = pair.getValue();
+ ModularArmourUtils.setModifierLevel(tBauble, newPair);
+ return true;
+ }
+ }
+ }
+ Utils.LOG_INFO("Could not find valid upgrade: "+tStack.getDisplayName()+".");
+ Utils.LOG_INFO("Bool1: "+mValidUpgradeListFormChange.containsKey(tStack));
+ Utils.LOG_INFO("Bool2: "+mValidUpgradeList.containsKey(tStack));
+ return false;
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java
index 644037334d..d209688d99 100644
--- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java
+++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java
@@ -197,6 +197,20 @@ public class TileEntityProjectTable extends TileEntity implements INetworkDataPr
container.inventoryGrid.setInventorySlotContents(i, null);
this.inventoryGrid.setInventorySlotContents(i, null);
}
+ if (tStack[i].getItem() == Items.bed){
+ ModularArmourUtils.setBaubleType(tBauble, BT.TYPE_RING);
+ Utils.LOG_INFO("buffed Modular bauble");
+ tStack[i] = null;
+ container.inventoryGrid.setInventorySlotContents(i, null);
+ this.inventoryGrid.setInventorySlotContents(i, null);
+ }
+ if (tStack[i].getItem() == Items.boat){
+ ModularArmourUtils.setBaubleType(tBauble, BT.TYPE_AMULET);
+ Utils.LOG_INFO("buffed Modular bauble");
+ tStack[i] = null;
+ container.inventoryGrid.setInventorySlotContents(i, null);
+ this.inventoryGrid.setInventorySlotContents(i, null);
+ }
if (tStack[i].getItem() == Items.egg){
ModularArmourUtils.setModifierLevel(tBauble, Modifiers.BOOST_HOLY, ModularArmourUtils.getModifierLevel(tBauble, Modifiers.BOOST_HOLY)+1);
@@ -205,6 +219,14 @@ public class TileEntityProjectTable extends TileEntity implements INetworkDataPr
container.inventoryGrid.setInventorySlotContents(i, null);
this.inventoryGrid.setInventorySlotContents(i, null);
}
+
+ if (tStack[i].getItem() == Items.baked_potato){
+ ModularArmourUtils.setModifierLevel(tBauble, Modifiers.BOOST_DEF, ModularArmourUtils.getModifierLevel(tBauble, Modifiers.BOOST_DEF)+1);
+ Utils.LOG_INFO("buffed Modular bauble");
+ tStack[i] = null;
+ container.inventoryGrid.setInventorySlotContents(i, null);
+ this.inventoryGrid.setInventorySlotContents(i, null);
+ }
if (tStack[i].getItem() == Items.cooked_beef){
ModularArmourUtils.setModifierLevel(tBauble, Modifiers.BOOST_HP, ModularArmourUtils.getModifierLevel(tBauble, Modifiers.BOOST_HP)+1);
diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
index f2e3bc5871..4be8f5dfa2 100644
--- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
+++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java
@@ -2,6 +2,8 @@ package gtPlusPlus.core.util.nbt;
import baubles.api.BaubleType;
import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.array.Pair;
+import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers;
import net.minecraft.block.Block.SoundType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -33,7 +35,7 @@ public class ModularArmourUtils {
return this.MODIFIER_NAME;
}
public boolean isValidLevel(int i){
- if (i >= 0 && i <= 5){
+ if (i >= 0 && i <= 100){
return true;
}
return false;
@@ -79,6 +81,14 @@ public class ModularArmourUtils {
}
}
+ public static void setModifierLevel(ItemStack aStack, Pair<Modifiers, Integer> mPair) {
+ setModifierLevel(aStack, mPair.getKey(), mPair.getValue().intValue());
+ }
+
+ public static void setModifierLevel(ItemStack aStack, Modifiers aMod, Integer aInt) {
+ setModifierLevel(aStack, aMod, aInt.intValue());
+ }
+
public static void setModifierLevel(ItemStack aStack, Modifiers aMod, int aInt) {
NBTTagCompound tNBT = NBTUtils.getNBT(aStack);
if (aMod.isValidLevel(aInt)){
@@ -86,8 +96,8 @@ public class ModularArmourUtils {
GT_Utility.ItemNBT.setNBT(aStack, tNBT);
}
else {
- if (getModifierLevel(aStack, aMod) > 5){
- setModifierLevel(aStack, aMod, 5);
+ if (getModifierLevel(aStack, aMod) > 100){
+ setModifierLevel(aStack, aMod, 100);
}
}
}