diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-11-06 19:32:27 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-11-06 19:32:27 +1000 |
commit | cbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch) | |
tree | b85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/core/slots | |
parent | c40416b036c0e89451e1558253ccf07bbee028d0 (diff) | |
download | GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2 GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip |
Revert "$ Cleaned up the entire project."
This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747.
# Conflicts:
# src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java
# src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java
Revert "% Cleaned up Imports."
This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966.
Diffstat (limited to 'src/Java/gtPlusPlus/core/slots')
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotBlueprint.java | 22 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotCrafting.java | 290 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotFrame.java | 14 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotGeneric.java | 12 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotGtTool.java | 22 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotGtToolElectric.java | 74 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java | 9 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotNoInput.java | 12 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotOutput.java | 94 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotRTG.java | 12 |
10 files changed, 295 insertions, 266 deletions
diff --git a/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java b/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java index 2a97b82d4a..3c5c30966e 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java +++ b/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java @@ -6,25 +6,25 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotBlueprint extends Slot { +public class SlotBlueprint extends Slot{ - public SlotBlueprint(final IInventory inventory, final int x, final int y, final int z) { + public SlotBlueprint(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof IItemBlueprint) { - Utils.LOG_WARNING(itemstack.getDisplayName() + " is a valid Blueprint."); + public boolean isItemValid(ItemStack itemstack) { + if (itemstack.getItem() instanceof IItemBlueprint){ + Utils.LOG_WARNING(itemstack.getDisplayName()+" is a valid Blueprint."); return true; } - Utils.LOG_WARNING(itemstack.getDisplayName() + " is not a valid Blueprint."); + Utils.LOG_WARNING(itemstack.getDisplayName()+" is not a valid Blueprint."); return false; } + @Override + public int getSlotStackLimit() { + return 1; + } + } diff --git a/src/Java/gtPlusPlus/core/slots/SlotCrafting.java b/src/Java/gtPlusPlus/core/slots/SlotCrafting.java index 498748cf94..0c9989158d 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotCrafting.java +++ b/src/Java/gtPlusPlus/core/slots/SlotCrafting.java @@ -1,150 +1,164 @@ package gtPlusPlus.core.slots; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -import net.minecraft.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.stats.AchievementList; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import cpw.mods.fml.common.FMLCommonHandler; -public class SlotCrafting extends Slot { - private static final String __OBFID = "CL_00001761"; - /** The craft matrix inventory linked to this result slot. */ - private final IInventory craftMatrix; - /** The player that is using the GUI where this slot resides. */ - private final EntityPlayer thePlayer; - /** - * The number of items that have been crafted so far. Gets passed to - * ItemStack.onCrafting before being reset. - */ - private int amountCrafted; - - public SlotCrafting(final EntityPlayer p_i1823_1_, final IInventory p_i1823_2_, final IInventory p_i1823_3_, - final int p_i1823_4_, final int p_i1823_5_, final int p_i1823_6_) { - super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_); - this.thePlayer = p_i1823_1_; - this.craftMatrix = p_i1823_2_; - } - - /** - * Decrease the size of the stack in slot (first int arg) by the amount of - * the second int arg. Returns the new stack. - */ - @Override - public ItemStack decrStackSize(final int p_75209_1_) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize); - } - - return super.decrStackSize(p_75209_1_); - } - - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - public boolean isItemValid(final ItemStack p_75214_1_) { - return false; - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(final ItemStack p_75208_1_) { - p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { - this.thePlayer.addStat(AchievementList.buildWorkBench, 1); - } - - if (p_75208_1_.getItem() instanceof ItemPickaxe) { - this.thePlayer.addStat(AchievementList.buildPickaxe, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace)) { - this.thePlayer.addStat(AchievementList.buildFurnace, 1); - } - - if (p_75208_1_.getItem() instanceof ItemHoe) { - this.thePlayer.addStat(AchievementList.buildHoe, 1); - } - - if (p_75208_1_.getItem() == Items.bread) { - this.thePlayer.addStat(AchievementList.makeBread, 1); - } - - if (p_75208_1_.getItem() == Items.cake) { - this.thePlayer.addStat(AchievementList.bakeCake, 1); - } - - if (p_75208_1_.getItem() instanceof ItemPickaxe - && ((ItemPickaxe) p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { - this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); - } - - if (p_75208_1_.getItem() instanceof ItemSword) { - this.thePlayer.addStat(AchievementList.buildSword, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { - this.thePlayer.addStat(AchievementList.enchantments, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { - this.thePlayer.addStat(AchievementList.bookcase, 1); - } - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. Typically increases an internal count then calls - * onCrafting(item). - */ - @Override - protected void onCrafting(final ItemStack p_75210_1_, final int p_75210_2_) { - this.amountCrafted += p_75210_2_; - this.onCrafting(p_75210_1_); - } - - @Override - public void onPickupFromSlot(final EntityPlayer p_82870_1_, final ItemStack p_82870_2_) { - FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, this.craftMatrix); - this.onCrafting(p_82870_2_); - - for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - - if (itemstack1 != null) { - this.craftMatrix.decrStackSize(i, 1); - - if (itemstack1.getItem().hasContainerItem(itemstack1)) { - final ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - - if (itemstack2 != null && itemstack2.isItemStackDamageable() - && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); - continue; - } - - if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) - || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - if (this.craftMatrix.getStackInSlot(i) == null) { - this.craftMatrix.setInventorySlotContents(i, itemstack2); - } - else { - this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); - } - } - } - } - } - } +public class SlotCrafting extends Slot +{ + /** The craft matrix inventory linked to this result slot. */ + private final IInventory craftMatrix; + /** The player that is using the GUI where this slot resides. */ + private EntityPlayer thePlayer; + /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ + private int amountCrafted; + private static final String __OBFID = "CL_00001761"; + + public SlotCrafting(EntityPlayer p_i1823_1_, IInventory p_i1823_2_, IInventory p_i1823_3_, int p_i1823_4_, int p_i1823_5_, int p_i1823_6_) + { + super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_); + this.thePlayer = p_i1823_1_; + this.craftMatrix = p_i1823_2_; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid(ItemStack p_75214_1_) + { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int p_75209_1_) + { + if (this.getHasStack()) + { + this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize); + } + + return super.decrStackSize(p_75209_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). + */ + protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_) + { + this.amountCrafted += p_75210_2_; + this.onCrafting(p_75210_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. + */ + protected void onCrafting(ItemStack p_75208_1_) + { + p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) + { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (p_75208_1_.getItem() instanceof ItemPickaxe) + { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace)) + { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (p_75208_1_.getItem() instanceof ItemHoe) + { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (p_75208_1_.getItem() == Items.bread) + { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (p_75208_1_.getItem() == Items.cake) + { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if (p_75208_1_.getItem() instanceof ItemPickaxe && ((ItemPickaxe)p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) + { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (p_75208_1_.getItem() instanceof ItemSword) + { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) + { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) + { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) + { + FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix); + this.onCrafting(p_82870_2_); + + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) + { + ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + + if (itemstack1 != null) + { + this.craftMatrix.decrStackSize(i, 1); + + if (itemstack1.getItem().hasContainerItem(itemstack1)) + { + ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + + if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) + { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2)); + continue; + } + + if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) + { + if (this.craftMatrix.getStackInSlot(i) == null) + { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } + else + { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotFrame.java b/src/Java/gtPlusPlus/core/slots/SlotFrame.java index cd38611847..13bc8fa717 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotFrame.java +++ b/src/Java/gtPlusPlus/core/slots/SlotFrame.java @@ -1,25 +1,25 @@ package gtPlusPlus.core.slots; -import forestry.api.apiculture.IHiveFrame; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import forestry.api.apiculture.IHiveFrame; -public class SlotFrame extends Slot { +public class SlotFrame extends Slot{ - public SlotFrame(final IInventory inventory, final int x, final int y, final int z) { + public SlotFrame(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 1; + public boolean isItemValid(ItemStack itemstack) { + return itemstack.getItem() instanceof IHiveFrame; } @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem() instanceof IHiveFrame; + public int getSlotStackLimit() { + return 1; } } diff --git a/src/Java/gtPlusPlus/core/slots/SlotGeneric.java b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java index 4cfd6ced49..bf7dc1fff5 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotGeneric.java +++ b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java @@ -4,21 +4,21 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotGeneric extends Slot { +public class SlotGeneric extends Slot{ - public SlotGeneric(final IInventory inventory, final int x, final int y, final int z) { + public SlotGeneric(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 64; + public boolean isItemValid(ItemStack itemstack) { + return true; } @Override - public boolean isItemValid(final ItemStack itemstack) { - return true; + public int getSlotStackLimit() { + return 64; } } diff --git a/src/Java/gtPlusPlus/core/slots/SlotGtTool.java b/src/Java/gtPlusPlus/core/slots/SlotGtTool.java index 011fcee9a4..cdea2fa43f 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotGtTool.java +++ b/src/Java/gtPlusPlus/core/slots/SlotGtTool.java @@ -6,26 +6,26 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotGtTool extends Slot { +public class SlotGtTool extends Slot{ - public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { + public SlotGtTool(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { - Utils.LOG_WARNING(itemstack.getDisplayName() + " is a valid Tool."); + public boolean isItemValid(ItemStack itemstack) { + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool){ + Utils.LOG_WARNING(itemstack.getDisplayName()+" is a valid Tool."); return true; } - Utils.LOG_WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + Utils.LOG_WARNING(itemstack.getDisplayName()+" is not a valid Tool."); return false; } + @Override + public int getSlotStackLimit() { + return 1; + } + } diff --git a/src/Java/gtPlusPlus/core/slots/SlotGtToolElectric.java b/src/Java/gtPlusPlus/core/slots/SlotGtToolElectric.java index c4efbb4995..461fa6ff04 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotGtToolElectric.java +++ b/src/Java/gtPlusPlus/core/slots/SlotGtToolElectric.java @@ -10,83 +10,89 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class SlotGtToolElectric extends SlotGtTool { - public int tier; - private ItemStack content; + public int tier; + private ItemStack content; - public boolean allowRedstoneDust = true; - - public SlotGtToolElectric(final IInventory base, final int x, final int y, final int z, final int tier, - final boolean allowRedstoneDust) { + public SlotGtToolElectric(IInventory base, int x, int y, int z, int tier, boolean allowRedstoneDust) + { super(base, x, y, z); this.tier = tier; this.allowRedstoneDust = allowRedstoneDust; } - public boolean accepts(final ItemStack stack) { + public boolean accepts(ItemStack stack) + { if (stack == null) { return false; } - if (stack.getItem() == Items.redstone && !this.allowRedstoneDust) { + if ((stack.getItem() == Items.redstone) && (!this.allowRedstoneDust)) { return false; } - return Info.itemEnergy.getEnergyValue(stack) > 0.0D - || ElectricItem.manager.discharge(stack, 1.0D / 0.0D, this.tier, true, true, true) > 0.0D; + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), this.tier, true, true, true) > 0.0D); } - public double discharge(final double amount, final boolean ignoreLimit) { + public double discharge(double amount, boolean ignoreLimit) + { if (amount <= 0.0D) { throw new IllegalArgumentException("Amount must be > 0."); } - final ItemStack stack = this.get(0); + ItemStack stack = get(0); if (stack == null) { return 0.0D; } double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); - if (realAmount <= 0.0D) { + if (realAmount <= 0.0D) + { realAmount = Info.itemEnergy.getEnergyValue(stack); if (realAmount <= 0.0D) { return 0.0D; } stack.stackSize -= 1; if (stack.stackSize <= 0) { - this.put(0, null); + put(0, null); } } return realAmount; } - public ItemStack get() { - return this.get(0); + public void setTier(int tier1) + { + this.tier = tier1; } - public ItemStack get(final int index) { - return this.content; + public boolean allowRedstoneDust = true; + + public ItemStack get() + { + return get(0); } - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool || itemstack.getItem() instanceof IElectricItem) { - Utils.LOG_WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Utils.LOG_WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; + public ItemStack get(int index) + { + return this.content; } - public void onChanged() { + public void put(ItemStack content) + { + put(0, content); } - public void put(final int index, final ItemStack content) { + public void put(int index, ItemStack content) + { this.content = content; - this.onChanged(); + onChanged(); } - public void put(final ItemStack content) { - this.put(0, content); - } + public void onChanged() {} - public void setTier(final int tier1) { - this.tier = tier1; + @Override + public boolean isItemValid(ItemStack itemstack) { + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool || itemstack.getItem() instanceof IElectricItem){ + Utils.LOG_WARNING(itemstack.getDisplayName()+" is a valid Tool."); + return true; + } + Utils.LOG_WARNING(itemstack.getDisplayName()+" is not a valid Tool."); + return false; } } diff --git a/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java b/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java index bc74e65844..7a22086949 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java +++ b/src/Java/gtPlusPlus/core/slots/SlotItemBackpackInv.java @@ -5,8 +5,10 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotItemBackpackInv extends Slot { - public SlotItemBackpackInv(final IInventory inv, final int index, final int xPos, final int yPos) { +public class SlotItemBackpackInv extends Slot +{ + public SlotItemBackpackInv(IInventory inv, int index, int xPos, int yPos) + { super(inv, index, xPos, yPos); } @@ -18,7 +20,8 @@ public class SlotItemBackpackInv extends Slot { * Check if the stack is a valid item for this slot. */ @Override - public boolean isItemValid(final ItemStack itemstack) { + public boolean isItemValid(ItemStack itemstack) + { // Everything returns true except an instance of our Item return !(itemstack.getItem() instanceof BaseItemBackpack); } diff --git a/src/Java/gtPlusPlus/core/slots/SlotNoInput.java b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java index 7af4570eff..fe51631a5d 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotNoInput.java +++ b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java @@ -4,20 +4,20 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotNoInput extends Slot { +public class SlotNoInput extends Slot{ - public SlotNoInput(final IInventory inventory, final int x, final int y, final int z) { + public SlotNoInput(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 0; + public boolean isItemValid(ItemStack itemstack) { + return false; } @Override - public boolean isItemValid(final ItemStack itemstack) { - return false; + public int getSlotStackLimit() { + return 0; } } diff --git a/src/Java/gtPlusPlus/core/slots/SlotOutput.java b/src/Java/gtPlusPlus/core/slots/SlotOutput.java index e5eb310068..a0f895d554 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotOutput.java +++ b/src/Java/gtPlusPlus/core/slots/SlotOutput.java @@ -1,89 +1,95 @@ package gtPlusPlus.core.slots; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import cpw.mods.fml.common.FMLCommonHandler; + +public class SlotOutput extends SlotCrafting{ -public class SlotOutput extends SlotCrafting { + private final IInventory craftMatrix; + private final EntityPlayer thePlayer; + private int amountCrafted; - private final IInventory craftMatrix; - private final EntityPlayer thePlayer; - private int amountCrafted; - public SlotOutput(final EntityPlayer player, final InventoryCrafting craftingInventory, - final IInventory p_i45790_3_, final int slotIndex, final int xPosition, final int yPosition) { + public SlotOutput(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition) + { super(player, craftingInventory, p_i45790_3_, slotIndex, xPosition, yPosition); this.thePlayer = player; this.craftMatrix = craftingInventory; } - /** - * Decrease the size of the stack in slot (first int arg) by the amount of - * the second int arg. Returns the new stack. + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override - public ItemStack decrStackSize(final int par1) { - if (this.getHasStack()) { + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + @Override + public ItemStack decrStackSize(int par1) + { + if (this.getHasStack()) + { this.amountCrafted += Math.min(par1, this.getStack().stackSize); } return super.decrStackSize(par1); } - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). */ @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; + protected void onCrafting(ItemStack par1ItemStack, int par2) + { + this.amountCrafted += par2; + this.onCrafting(par1ItemStack); } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ @Override - protected void onCrafting(final ItemStack stack) { + protected void onCrafting(ItemStack stack) + { stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); this.amountCrafted = 0; } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. Typically increases an internal count then calls - * onCrafting(item). - */ - @Override - protected void onCrafting(final ItemStack par1ItemStack, final int par2) { - this.amountCrafted += par2; - this.onCrafting(par1ItemStack); - } - @Override - public void onPickupFromSlot(final EntityPlayer playerIn, final ItemStack stack) { + public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) + { { - FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); + FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix); this.onCrafting(stack); - for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - if (itemstack1 != null) { + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) + { + ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + if (itemstack1 != null) + { this.craftMatrix.decrStackSize(i, 1); - if (itemstack1.getItem().hasContainerItem(itemstack1)) { + if (itemstack1.getItem().hasContainerItem(itemstack1)) + { ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - if (itemstack2.isItemStackDamageable() - && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); + if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) + { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2)); itemstack2 = null; } - if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - if (this.craftMatrix.getStackInSlot(i) == null) { + if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) + { + if (this.craftMatrix.getStackInSlot(i) == null) + { this.craftMatrix.setInventorySlotContents(i, itemstack2); } - else { + else + { this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } diff --git a/src/Java/gtPlusPlus/core/slots/SlotRTG.java b/src/Java/gtPlusPlus/core/slots/SlotRTG.java index 31c176d4f9..1f16463de2 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotRTG.java +++ b/src/Java/gtPlusPlus/core/slots/SlotRTG.java @@ -5,21 +5,21 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotRTG extends Slot { +public class SlotRTG extends Slot{ - public SlotRTG(final IInventory inventory, final int x, final int y, final int z) { + public SlotRTG(IInventory inventory, int x, int y, int z) { super(inventory, x, y, z); } @Override - public int getSlotStackLimit() { - return 1; + public boolean isItemValid(ItemStack itemstack) { + return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); } @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); + public int getSlotStackLimit() { + return 1; } } |