diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/core/slots | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/core/slots')
28 files changed, 1203 insertions, 1226 deletions
diff --git a/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java b/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java index 92e9bebe21..8ad0b000bc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java @@ -7,24 +7,23 @@ import net.minecraft.item.ItemStack; public class SlotAirFilter extends Slot { - public SlotAirFilter(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - } + public SlotAirFilter(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack == null) { - return false; - } - if (itemstack.getItem() instanceof ItemAirFilter){ - return true; - } - return false; - } - - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack == null) { + return false; + } + if (itemstack.getItem() instanceof ItemAirFilter) { + return true; + } + return false; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java b/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java index 532f2f0822..56d39233e7 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java @@ -1,31 +1,29 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.interfaces.IItemBlueprint; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.interfaces.IItemBlueprint; - public class SlotBlueprint extends Slot { - public SlotBlueprint(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof IItemBlueprint) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Blueprint."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Blueprint."); - return false; - } + public SlotBlueprint(final IInventory inventory, final int x, final int y, final 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) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Blueprint."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Blueprint."); + return false; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java b/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java index 94b0b9ecc7..0caee5e6d0 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java @@ -1,77 +1,73 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.OrePrefixes; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.GT_MetaGenerated_Item_02; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotBuzzSaw extends Slot { - public SAWTOOL currentTool = SAWTOOL.NONE; - - public SlotBuzzSaw(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } + public SAWTOOL currentTool = SAWTOOL.NONE; - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; + public SlotBuzzSaw(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - if (itemstack != null) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_02) - || (itemstack.getItem() instanceof GT_MetaGenerated_Tool)) { - // Buzzsaw Blade //TODO - /* - * if (OrePrefixes.toolHeadBuzzSaw.contains(itemstack)){ isValid - * = false; } - */ - if (OrePrefixes.craftingTool.contains(itemstack)) { - if (itemstack.getDisplayName().toLowerCase().contains("saw") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.10") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.110") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.112") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.114") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")) { - if (itemstack.getItemDamage() == 10) { - isValid = true; - this.currentTool = SAWTOOL.SAW; - } - else if (itemstack.getItemDamage() == 110) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 112) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 114) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 140) { - isValid = true; - this.currentTool = SAWTOOL.BUZZSAW; - } - return isValid; - } - } - } - } - this.currentTool = SAWTOOL.NONE; - return isValid; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; - @Override - public int getSlotStackLimit() { - return 1; - } + if (itemstack != null) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_02) + || (itemstack.getItem() instanceof GT_MetaGenerated_Tool)) { + // Buzzsaw Blade //TODO + /* + * if (OrePrefixes.toolHeadBuzzSaw.contains(itemstack)){ isValid + * = false; } + */ + if (OrePrefixes.craftingTool.contains(itemstack)) { + if (itemstack.getDisplayName().toLowerCase().contains("saw") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.10") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.110") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.112") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.114") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")) { + if (itemstack.getItemDamage() == 10) { + isValid = true; + this.currentTool = SAWTOOL.SAW; + } else if (itemstack.getItemDamage() == 110) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 112) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 114) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 140) { + isValid = true; + this.currentTool = SAWTOOL.BUZZSAW; + } + return isValid; + } + } + } + } + this.currentTool = SAWTOOL.NONE; + return isValid; + } - public enum SAWTOOL { - NONE, SAW, BUZZSAW, CHAINSAW - } + @Override + public int getSlotStackLimit() { + return 1; + } + public enum SAWTOOL { + NONE, + SAW, + BUZZSAW, + CHAINSAW + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java b/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java index 1029d37a78..4bfda45170 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java @@ -10,36 +10,35 @@ import net.minecraftforge.fluids.FluidStack; public class SlotChemicalPlantInput extends Slot { - public SlotChemicalPlantInput(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - } + public SlotChemicalPlantInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValidForChemicalPlantSlot(itemstack); - } - - public static boolean isItemValidForChemicalPlantSlot(ItemStack aStack) { - boolean validItem = GTPP_Recipe_Map.sChemicalPlantRecipes.containsInput(aStack); - if (!validItem) { - for (GT_Recipe f : GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { - if (f.mFluidInputs.length > 0) { - for (FluidStack g : f.mFluidInputs) { - if (g != null) { - if (FluidContainerRegistry.containsFluid(aStack, g)) { - return true; - } - } - } - } - } - } - return validItem; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValidForChemicalPlantSlot(itemstack); + } - @Override - public int getSlotStackLimit() { - return 64; - } + public static boolean isItemValidForChemicalPlantSlot(ItemStack aStack) { + boolean validItem = GTPP_Recipe_Map.sChemicalPlantRecipes.containsInput(aStack); + if (!validItem) { + for (GT_Recipe f : GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + if (f.mFluidInputs.length > 0) { + for (FluidStack g : f.mFluidInputs) { + if (g != null) { + if (FluidContainerRegistry.containsFluid(aStack, g)) { + return true; + } + } + } + } + } + } + return validItem; + } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java index 42b7b585e2..8d7c0946ec 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java @@ -1,7 +1,6 @@ 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; @@ -9,143 +8,149 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.*; import net.minecraft.stats.AchievementList; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; 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 final 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(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_; - } - - /** - * 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; - } - - /** - * 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_); - } - - /** - * 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_); - } - - /** - * 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); - } - } - - @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); - } - } - } - } - } - } -}
\ No newline at end of file + /** 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; + + private static final String __OBFID = "CL_00001761"; + + 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_; + } + + /** + * 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; + } + + /** + * 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_); + } + + /** + * 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_); + } + + /** + * 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); + } + } + + @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); + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java index 3608c3724c..cf96dd69e2 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java @@ -1,7 +1,6 @@ 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; @@ -10,138 +9,138 @@ import net.minecraft.item.*; import net.minecraft.stats.AchievementList; public class SlotCraftingNoCollect extends SlotCrafting { - /** 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; - - public SlotCraftingNoCollect(EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y, - int z) { - super(player, inventory, inventory2, x, y, z); - this.thePlayer = player; - this.craftMatrix = inventory; - } - - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - 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. - */ - @Override - public ItemStack decrStackSize(int amount) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(amount, this.getStack().stackSize); - } - - return super.decrStackSize(amount); - } - - /** - * 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(ItemStack output, int amount) { - this.amountCrafted += amount; - this.onCrafting(output); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(ItemStack output) { - output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - - if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { - this.thePlayer.addStat(AchievementList.buildWorkBench, 1); - } - - if (output.getItem() instanceof ItemPickaxe) { - this.thePlayer.addStat(AchievementList.buildPickaxe, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) { - this.thePlayer.addStat(AchievementList.buildFurnace, 1); - } - - if (output.getItem() instanceof ItemHoe) { - this.thePlayer.addStat(AchievementList.buildHoe, 1); - } - - if (output.getItem() == Items.bread) { - this.thePlayer.addStat(AchievementList.makeBread, 1); - } - - if (output.getItem() == Items.cake) { - this.thePlayer.addStat(AchievementList.bakeCake, 1); - } - - if (output.getItem() instanceof ItemPickaxe - && ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { - this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); - } - - if (output.getItem() instanceof ItemSword) { - this.thePlayer.addStat(AchievementList.buildSword, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { - this.thePlayer.addStat(AchievementList.enchantments, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { - this.thePlayer.addStat(AchievementList.bookcase, 1); - } - } - - @Override - public void onPickupFromSlot(EntityPlayer player, ItemStack output) { - FMLCommonHandler.instance().firePlayerCraftingEvent(player, output, craftMatrix); - this.onCrafting(output); - - /* - * 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); } } - * } } } - */ - } - - @Override - public boolean canTakeStack(EntityPlayer player) { - return false; - } -}
\ No newline at end of file + /** 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; + + public SlotCraftingNoCollect( + EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y, int z) { + super(player, inventory, inventory2, x, y, z); + this.thePlayer = player; + this.craftMatrix = inventory; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for + * the armor slots. + */ + @Override + 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. + */ + @Override + public ItemStack decrStackSize(int amount) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(amount, this.getStack().stackSize); + } + + return super.decrStackSize(amount); + } + + /** + * 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(ItemStack output, int amount) { + this.amountCrafted += amount; + this.onCrafting(output); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. + */ + @Override + protected void onCrafting(ItemStack output) { + output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (output.getItem() instanceof ItemPickaxe) { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (output.getItem() instanceof ItemHoe) { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (output.getItem() == Items.bread) { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (output.getItem() == Items.cake) { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if (output.getItem() instanceof ItemPickaxe + && ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (output.getItem() instanceof ItemSword) { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack output) { + FMLCommonHandler.instance().firePlayerCraftingEvent(player, output, craftMatrix); + this.onCrafting(output); + + /* + * 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); } } + * } } } + */ + } + + @Override + public boolean canTakeStack(EntityPlayer player) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java index ce97a2fdbf..69feaa3384 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java @@ -1,42 +1,41 @@ package gtPlusPlus.core.slots; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.recipe.common.CI; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.recipe.common.CI; - public class SlotDataStick extends Slot { - public SlotDataStick(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); + public SlotDataStick(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - } + public static ItemStack[] mDataItems = new ItemStack[2]; - public static ItemStack[] mDataItems = new ItemStack[2]; - - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; - if (itemstack != null) { - if (mDataItems[0] == null) { - mDataItems[0] = CI.getDataStick(); - } - if (mDataItems[1] == null) { - mDataItems[1] = CI.getDataOrb(); - } - if (mDataItems[0] != null && mDataItems[1] != null) { - if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true) ) { - isValid = true; - } - } - } - return isValid; - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + if (itemstack != null) { + if (mDataItems[0] == null) { + mDataItems[0] = CI.getDataStick(); + } + if (mDataItems[1] == null) { + mDataItems[1] = CI.getDataOrb(); + } + if (mDataItems[0] != null && mDataItems[1] != null) { + if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) + || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true)) { + isValid = true; + } + } + } + return isValid; + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotElectric.java b/src/main/java/gtPlusPlus/core/slots/SlotElectric.java index a747432a74..9c14afc6cc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotElectric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotElectric.java @@ -1,45 +1,48 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; - import ic2.api.info.Info; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotElectric extends Slot { - - public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - - public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { - this(mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), i, j, k); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if ((accepts(itemstack)) || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { - return true; - } - return false; - } - - public boolean accepts(final ItemStack stack) { - if (stack == null) { - return false; - } - return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) - || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); - } - - @Override - public int getSlotStackLimit() { - return 1; - } + public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { + this( + mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), + i, + j, + k); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((accepts(itemstack)) + || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) + || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotFrame.java b/src/main/java/gtPlusPlus/core/slots/SlotFrame.java index 4168ded5bc..593ec747e8 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotFrame.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotFrame.java @@ -1,26 +1,23 @@ 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 SlotFrame(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem() instanceof IHiveFrame; - } + public SlotFrame(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return itemstack.getItem() instanceof IHiveFrame; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java b/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java index b50b679665..18c5878e35 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java @@ -1,55 +1,51 @@ package gtPlusPlus.core.slots; +import gregtech.api.enums.ItemList; +import ic2.core.Ic2Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.enums.ItemList; - -import ic2.core.Ic2Items; - public class SlotFuelRod extends Slot { - public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean returnValue = false; - // Uranium Rods - if (itemstack.getItem() == Ic2Items.reactorUraniumSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumQuad.getItem()) { - returnValue = true; - } - - // Mox Rods - if (itemstack.getItem() == Ic2Items.reactorMOXSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXQuad.getItem()) { - returnValue = true; - } - - // Thorium Rods - if (itemstack.getItem() == ItemList.ThoriumCell_1.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_2.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_4.getItem()) { - returnValue = true; - } - return returnValue; - } - - @Override - public int getSlotStackLimit() { - return 1; - } - + public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean returnValue = false; + // Uranium Rods + if (itemstack.getItem() == Ic2Items.reactorUraniumSimple.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorUraniumDual.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorUraniumQuad.getItem()) { + returnValue = true; + } + + // Mox Rods + if (itemstack.getItem() == Ic2Items.reactorMOXSimple.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorMOXDual.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorMOXQuad.getItem()) { + returnValue = true; + } + + // Thorium Rods + if (itemstack.getItem() == ItemList.ThoriumCell_1.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == ItemList.ThoriumCell_2.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == ItemList.ThoriumCell_4.getItem()) { + returnValue = true; + } + return returnValue; + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java index 533539d914..bfb384efe8 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java @@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack; public class SlotGeneric extends Slot { - public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { - super(inventory, aSlotID, x, y); - } + public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { + super(inventory, aSlotID, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return true; - } - - @Override - public int getSlotStackLimit() { - return 64; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return true; + } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java b/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java index 54e25362db..ea2d8f3a93 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java @@ -1,33 +1,29 @@ package gtPlusPlus.core.slots; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.api.objects.Logger; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.items.GT_MetaGenerated_Tool; - -import gtPlusPlus.api.objects.Logger; - public class SlotGtTool extends Slot { - public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } - - @Override - public int getSlotStackLimit() { - return 1; - } - + public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java b/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java index c0e3340769..c7013660dc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java @@ -1,94 +1,95 @@ package gtPlusPlus.core.slots; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - import gregtech.api.items.GT_MetaGenerated_Tool; - import gtPlusPlus.api.objects.Logger; import ic2.api.info.Info; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; public class SlotGtToolElectric extends SlotGtTool { - public int tier; - private ItemStack content; - - public SlotGtToolElectric(final IInventory base, final int x, final int y, final int z, final int tier, - final boolean allowRedstoneDust) { - super(base, x, y, z); - this.tier = tier; - this.allowRedstoneDust = allowRedstoneDust; - } - - public boolean accepts(final ItemStack stack) { - if (stack == null) { - return false; - } - 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); - } - - public double discharge(final double amount, final boolean ignoreLimit) { - if (amount <= 0.0D) { - throw new IllegalArgumentException("Amount must be > 0."); - } - final ItemStack stack = this.get(0); - if (stack == null) { - return 0.0D; - } - double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); - 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); - } - } - return realAmount; - } - - public void setTier(final int tier1) { - this.tier = tier1; - } - - public boolean allowRedstoneDust = true; - - public ItemStack get() { - return this.get(0); - } - - public ItemStack get(final int index) { - return this.content; - } - - public void put(final ItemStack content) { - this.put(0, content); - } - - public void put(final int index, final ItemStack content) { - this.content = content; - this.onChanged(); - } - - public void onChanged() { - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } - + public int tier; + private ItemStack content; + + public SlotGtToolElectric( + final IInventory base, + final int x, + final int y, + final int z, + final int tier, + final boolean allowRedstoneDust) { + super(base, x, y, z); + this.tier = tier; + this.allowRedstoneDust = allowRedstoneDust; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + 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); + } + + public double discharge(final double amount, final boolean ignoreLimit) { + if (amount <= 0.0D) { + throw new IllegalArgumentException("Amount must be > 0."); + } + final ItemStack stack = this.get(0); + if (stack == null) { + return 0.0D; + } + double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); + 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); + } + } + return realAmount; + } + + public void setTier(final int tier1) { + this.tier = tier1; + } + + public boolean allowRedstoneDust = true; + + public ItemStack get() { + return this.get(0); + } + + public ItemStack get(final int index) { + return this.content; + } + + public void put(final ItemStack content) { + this.put(0, content); + } + + public void put(final int index, final ItemStack content) { + this.content = content; + this.onChanged(); + } + + public void onChanged() {} + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java index 8c8a118abb..702f678804 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -1,105 +1,104 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.core.recipe.common.CI; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.recipe.common.CI; - public class SlotIntegratedCircuit extends Slot { - public static Item mCircuitItem; - public static Item mCircuitItem2; - public static Item mCircuitItem3; - private final short mCircuitLock; + public static Item mCircuitItem; + public static Item mCircuitItem2; + public static Item mCircuitItem3; + private final short mCircuitLock; - public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { - this(Short.MAX_VALUE+1, inventory, slot, x, y); - } + public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { + this(Short.MAX_VALUE + 1, inventory, slot, x, y); + } - public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { - mCircuitLock = -1; - } - else { - mCircuitLock = (short) mTypeLock; - } - } + public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { + mCircuitLock = -1; + } else { + mCircuitLock = (short) mTypeLock; + } + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(mCircuitLock, itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(mCircuitLock, itemstack); + } - public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { - return isItemValidForSlot(-1, itemstack); - } + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return isItemValidForSlot(-1, itemstack); + } - public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { - boolean isValid = false; - if (mCircuitItem == null) { - mCircuitItem = CI.getNumberedCircuit(0).getItem(); - } - if (mCircuitItem2 == null) { - mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); - } - if (mCircuitItem3 == null) { - mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); - } - if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { - if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 || itemstack.getItem() == mCircuitItem3) { - if (aLockedCircuitNumber == -1) { - isValid = true; - } - else { - if (itemstack.getItemDamage() == aLockedCircuitNumber) { - isValid = true; - } - } - } - } - } - return isValid; - } + public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { + boolean isValid = false; + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem + || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (aLockedCircuitNumber == -1) { + isValid = true; + } else { + if (itemstack.getItemDamage() == aLockedCircuitNumber) { + isValid = true; + } + } + } + } + } + return isValid; + } - /** - * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. - * @param itemstack - the Circuit Stack. - * @return - */ - public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { - if (mCircuitItem == null) { - mCircuitItem = CI.getNumberedCircuit(0).getItem(); - } - if (mCircuitItem2 == null) { - mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); - } - if (mCircuitItem3 == null) { - mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); - } - if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { - if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 || itemstack.getItem() == mCircuitItem3) { - if (itemstack.getItem() == mCircuitItem) { - return 0; - } - else if (itemstack.getItem() == mCircuitItem2) { - return 1; - } - else if (itemstack.getItem() == mCircuitItem3) { - return 2; - } - } - } - } - return -1; - } + /** + * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. + * @param itemstack - the Circuit Stack. + * @return + */ + public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem + || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (itemstack.getItem() == mCircuitItem) { + return 0; + } else if (itemstack.getItem() == mCircuitItem2) { + return 1; + } else if (itemstack.getItem() == mCircuitItem3) { + return 2; + } + } + } + } + return -1; + } - @Override - public int getSlotStackLimit() { - return 64; - } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java b/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java index 3aa551f966..7711858dae 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java @@ -1,26 +1,25 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.core.item.base.BaseItemBackpack; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.item.base.BaseItemBackpack; - public class SlotItemBackpackInv extends Slot { - public SlotItemBackpackInv(final IInventory inv, final int index, final int xPos, final int yPos) { - super(inv, index, xPos, yPos); - } + public SlotItemBackpackInv(final IInventory inv, final int index, final int xPos, final int yPos) { + super(inv, index, xPos, yPos); + } - // This is the only method we need to override so that - // we can't place our inventory-storing Item within - // its own inventory (thus making it permanently inaccessible) - // as well as preventing abuse of storing backpacks within backpacks - /** - * Check if the stack is a valid item for this slot. - */ - @Override - public boolean isItemValid(final ItemStack itemstack) { - // Everything returns true except an instance of our Item - return !(itemstack.getItem() instanceof BaseItemBackpack); - } -}
\ No newline at end of file + // This is the only method we need to override so that + // we can't place our inventory-storing Item within + // its own inventory (thus making it permanently inaccessible) + // as well as preventing abuse of storing backpacks within backpacks + /** + * Check if the stack is a valid item for this slot. + */ + @Override + public boolean isItemValid(final ItemStack itemstack) { + // Everything returns true except an instance of our Item + return !(itemstack.getItem() instanceof BaseItemBackpack); + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java index 0f8af988a1..1351e5c188 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java @@ -7,31 +7,29 @@ import net.minecraft.item.ItemStack; public class SlotJukebox extends SlotGeneric { - private final boolean isDisplay; - - - public SlotJukebox(IInventory inventory, int x, int y, int z) { - this(inventory, x, y, z, false); - } - - public SlotJukebox(IInventory inventory, int x, int y, int z, boolean display) { - super(inventory, x, y, z); - isDisplay = display; - } - - @Override - public boolean isItemValid(ItemStack itemstack) { - return (itemstack != null && itemstack.getItem() instanceof ItemRecord); - } - - @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return !isDisplay; - } - + private final boolean isDisplay; + + public SlotJukebox(IInventory inventory, int x, int y, int z) { + this(inventory, x, y, z, false); + } + + public SlotJukebox(IInventory inventory, int x, int y, int z, boolean display) { + super(inventory, x, y, z); + isDisplay = display; + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return (itemstack != null && itemstack.getItem() instanceof ItemRecord); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return !isDisplay; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java b/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java index c67f8acfeb..41a3236275 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java @@ -1,57 +1,53 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotLockedInput extends Slot { - private ItemStack mLockStack; - private final IGregTechTileEntity mEntity; - private boolean mChecked = false; - - public SlotLockedInput(final IGregTechTileEntity inventory, final int index, final int x, final int y, ItemStack lockStack) { - super(inventory, index, x, y); - mLockStack = lockStack; - mEntity = inventory; - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (mEntity == null) { - return false; - } - else { - if (!mChecked) { - try { - mLockStack = (ItemStack) ReflectionUtils.getField(this.mEntity.getMetaTileEntity().getClass(), "mItemStack").get(this.mEntity.getMetaTileEntity()); - } - catch (Throwable t) { - t.printStackTrace(); - mLockStack = null; - } - mChecked = true; - } - } - - if (mLockStack == null) { - return true; - } - else { - if (ItemStack.areItemStacksEqual(itemstack, mLockStack)) { - return true; - } - } - return false; - } - - @Override - public int getSlotStackLimit() { - return mLockStack == null ? 64 : mLockStack.getMaxStackSize(); - } - + private ItemStack mLockStack; + private final IGregTechTileEntity mEntity; + private boolean mChecked = false; + + public SlotLockedInput( + final IGregTechTileEntity inventory, final int index, final int x, final int y, ItemStack lockStack) { + super(inventory, index, x, y); + mLockStack = lockStack; + mEntity = inventory; + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (mEntity == null) { + return false; + } else { + if (!mChecked) { + try { + mLockStack = (ItemStack) ReflectionUtils.getField( + this.mEntity.getMetaTileEntity().getClass(), "mItemStack") + .get(this.mEntity.getMetaTileEntity()); + } catch (Throwable t) { + t.printStackTrace(); + mLockStack = null; + } + mChecked = true; + } + } + + if (mLockStack == null) { + return true; + } else { + if (ItemStack.areItemStacksEqual(itemstack, mLockStack)) { + return true; + } + } + return false; + } + + @Override + public int getSlotStackLimit() { + return mLockStack == null ? 64 : mLockStack.getMaxStackSize(); + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java b/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java index bb82a28936..341921814f 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java @@ -1,30 +1,28 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FoodUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; - public class SlotLunchBox extends SlotGtTool { - - public SlotLunchBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } + public SlotLunchBox(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java b/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java index d555f10a44..6427dccc69 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java @@ -1,29 +1,28 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FoodUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; public class SlotMagicToolBag extends SlotGtTool { - - public SlotMagicToolBag(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } - + public SlotMagicToolBag(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java b/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java index 4aef5bc877..47a3beb393 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java @@ -1,32 +1,30 @@ 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; -import gtPlusPlus.core.item.bauble.ModularBauble; - 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; - } + 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/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java b/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java index dae62f0415..f73f27b788 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java @@ -2,55 +2,54 @@ package gtPlusPlus.core.slots; import static gtPlusPlus.core.tileentities.machines.TileEntityModularityTable.*; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; import java.util.Iterator; import java.util.Map.Entry; - import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; - 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) { - Logger.INFO("trying to insert " + itemstack.getDisplayName()); - Logger.INFO("Valid Upgrade count: " + mValidUpgradeList.size()); - - 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; - } - } - - Iterator<Entry<ItemStack, Pair<Modifiers, Integer>>> it2 = mValidUpgradeList.entrySet().iterator(); - while (it2.hasNext()) { - Entry<ItemStack, Pair<Modifiers, Integer>> pair = it2.next(); - if (pair.getKey().getItem() == itemstack.getItem() - && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { - isValid = true; - } - } - } - return isValid; - } - - @Override - public int getSlotStackLimit() { - return 64; - } + 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) { + Logger.INFO("trying to insert " + itemstack.getDisplayName()); + Logger.INFO("Valid Upgrade count: " + mValidUpgradeList.size()); + + 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; + } + } + + Iterator<Entry<ItemStack, Pair<Modifiers, Integer>>> it2 = + mValidUpgradeList.entrySet().iterator(); + while (it2.hasNext()) { + Entry<ItemStack, Pair<Modifiers, Integer>> pair = it2.next(); + if (pair.getKey().getItem() == itemstack.getItem() + && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { + isValid = true; + } + } + } + return isValid; + } + + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java index 1a1cf62e2b..d4e8696075 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java @@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack; public class SlotNoInput extends Slot { - public SlotNoInput(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - } + public SlotNoInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return false; - } - - @Override - public int getSlotStackLimit() { - return 0; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return false; + } + @Override + public int getSlotStackLimit() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java b/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java index 762714ac94..230a299d41 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java @@ -8,29 +8,27 @@ import net.minecraft.item.ItemStack; public class SlotNoInputLogging extends SlotNoInput { - private final int aSlotIndex; - - public SlotNoInputLogging(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - aSlotIndex = index; - Logger.INFO("Slot "+index+" is doing logging"); - } + private final int aSlotIndex; - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (ItemUtils.checkForInvalidItems(itemstack)) { - Logger.INFO("Tried Inserting "+ItemUtils.getItemName(itemstack)+" into slot "+aSlotIndex); - Block b = Block.getBlockFromItem(itemstack.getItem()); - Logger.INFO(""+itemstack.getUnlocalizedName()); - if (b != null) { - Logger.INFO(""+b.getLocalizedName()); - Logger.INFO(""+b.getUnlocalizedName()); - } - } - else { - Logger.INFO("Bad Itemstack"); - } - return false; - } + public SlotNoInputLogging(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + aSlotIndex = index; + Logger.INFO("Slot " + index + " is doing logging"); + } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (ItemUtils.checkForInvalidItems(itemstack)) { + Logger.INFO("Tried Inserting " + ItemUtils.getItemName(itemstack) + " into slot " + aSlotIndex); + Block b = Block.getBlockFromItem(itemstack.getItem()); + Logger.INFO("" + itemstack.getUnlocalizedName()); + if (b != null) { + Logger.INFO("" + b.getLocalizedName()); + Logger.INFO("" + b.getUnlocalizedName()); + } + } else { + Logger.INFO("Bad Itemstack"); + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotOutput.java b/src/main/java/gtPlusPlus/core/slots/SlotOutput.java index f22e0645f5..dc469b32a4 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotOutput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotOutput.java @@ -1,96 +1,99 @@ 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; 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) { - super(player, craftingInventory, p_i45790_3_, slotIndex, xPosition, yPosition); - this.thePlayer = player; - this.craftMatrix = craftingInventory; - } + public SlotOutput( + final EntityPlayer player, + final InventoryCrafting craftingInventory, + final IInventory p_i45790_3_, + final int slotIndex, + final int xPosition, + final int yPosition) { + super(player, craftingInventory, p_i45790_3_, slotIndex, xPosition, yPosition); + this.thePlayer = player; + this.craftMatrix = craftingInventory; + } - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } + /** + * Check if the stack is a valid item for this slot. Always true beside for + * the armor slots. + */ + @Override + public boolean isItemValid(final 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(final int par1) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(par1, this.getStack().stackSize); - } - return super.decrStackSize(par1); - } + /** + * 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 par1) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(par1, this.getStack().stackSize); + } + return super.decrStackSize(par1); + } - /** - * 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); - } + /** + * 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); + } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(final 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. + */ + @Override + protected void onCrafting(final ItemStack stack) { + stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + } - @Override - public void onPickupFromSlot(final EntityPlayer playerIn, final ItemStack stack) { - { - FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); - this.onCrafting(stack); - 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)) { - ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - if (itemstack2.isItemStackDamageable() - && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); - itemstack2 = null; - } - if (!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 + @Override + public void onPickupFromSlot(final EntityPlayer playerIn, final ItemStack stack) { + { + FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); + this.onCrafting(stack); + 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)) { + ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + if (itemstack2.isItemStackDamageable() + && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); + itemstack2 = null; + } + if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + if (this.craftMatrix.getStackInSlot(i) == null) { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } else { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java b/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java index 6dd3745d09..7025943908 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java @@ -1,66 +1,67 @@ package gtPlusPlus.core.slots; -import java.util.HashMap; - import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import java.util.HashMap; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotPollutionScrubber extends Slot { - private final int mType; - private final int mTier; - - private static HashMap<Integer, ItemStack> mConveyorMap = new HashMap<Integer, ItemStack>(); - - static { - for (int i=0; i<(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) { - mConveyorMap.put(i, CI.getConveyor(i, 1)); - } - } + private final int mType; + private final int mTier; + + private static HashMap<Integer, ItemStack> mConveyorMap = new HashMap<Integer, ItemStack>(); + + static { + for (int i = 0; i < (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) { + mConveyorMap.put(i, CI.getConveyor(i, 1)); + } + } - public SlotPollutionScrubber(final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - mType = aType; - mTier = aTier; - } + public SlotPollutionScrubber( + final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + mType = aType; + mTier = aTier; + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(this, itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(this, itemstack); + } - public static synchronized boolean isItemValidForSlot(final SlotPollutionScrubber aSlot, final ItemStack itemstack) { - if (aSlot.mType == 0) { - if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool && itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 179){ - return true; - } - } - else if (aSlot.mType == 1) { - if (itemstack.getItem() instanceof ItemAirFilter) { - return true; - } - } - else if (aSlot.mType == 2) { - ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier); - if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) { - return true; - } - } - return false; - } + public static synchronized boolean isItemValidForSlot( + final SlotPollutionScrubber aSlot, final ItemStack itemstack) { + if (aSlot.mType == 0) { + if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool + && itemstack.getItemDamage() >= 170 + && itemstack.getItemDamage() <= 179) { + return true; + } + } else if (aSlot.mType == 1) { + if (itemstack.getItem() instanceof ItemAirFilter) { + return true; + } + } else if (aSlot.mType == 2) { + ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier); + if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) { + return true; + } + } + return false; + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotRTG.java b/src/main/java/gtPlusPlus/core/slots/SlotRTG.java index 181052cc57..f07fdd2894 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotRTG.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotRTG.java @@ -1,26 +1,23 @@ package gtPlusPlus.core.slots; +import ic2.core.Ic2Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import ic2.core.Ic2Items; - public class SlotRTG extends Slot { - public SlotRTG(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); - } + public SlotRTG(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java b/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java index 87967b75b5..54b8f0bd92 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java @@ -1,113 +1,119 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; import gregtech.api.items.GT_MetaGenerated_Tool; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; public class SlotToolBox extends SlotGtTool { - - private static final AutoMap<Class> mSupportedCustomTools = new AutoMap<Class>(); - - static { - //Look for Supported custom tool types - Class temp; - //IHL Pumps - temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } + private static final AutoMap<Class> mSupportedCustomTools = new AutoMap<Class>(); + + static { + // Look for Supported custom tool types + Class temp; + + // IHL Pumps + temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // IC2 Electrics + temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // IC2 Boxables + temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // Tinkers Tools + temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + // BattleGear Weapons + temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // OpenMods + String[] OpenModsContent = new String[] { + "openblocks.common.item.ItemDevNull", + "openblocks.common.item.ItemHangGlider", + "openblocks.common.item.ItemWrench", + "openblocks.common.item.ItemSleepingBag" + }; + for (String t : OpenModsContent) { + temp = ReflectionUtils.getClass(t); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } + + // GC Wrench + temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // EIO + String[] EioContent = new String[] { + "crazypants.enderio.api.tool.ITool", + "crazypants.enderio.item.ItemMagnet", + "crazypants.enderio.item.ItemConduitProbe" + }; + for (String t : EioContent) { + temp = ReflectionUtils.getClass(t); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } - //IC2 Electrics - temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //IC2 Boxables - temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //Tinkers Tools - temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - //BattleGear Weapons - temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - - //OpenMods - String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"}; - for (String t : OpenModsContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } + // Forestry + temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } - //GC Wrench - temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //EIO - String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"}; - for (String t : EioContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - //Forestry - temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - public SlotToolBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } + public SlotToolBox(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - for (Class C : mSupportedCustomTools) { - if (C.isInstance(itemstack.getItem())) { - return true; - } - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + for (Class C : mSupportedCustomTools) { + if (C.isInstance(itemstack.getItem())) { + return true; + } + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java index b8955f6dc8..0decde112d 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java @@ -8,23 +8,23 @@ import net.minecraft.item.ItemStack; public class SlotVolumetricFlask extends Slot { - public static Item mFlask; + public static Item mFlask; - public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - } + public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(itemstack); + } - public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { - return VolumetricFlaskHelper.isVolumetricFlask(itemstack); - } + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } - @Override - public int getSlotStackLimit() { - return 16; - } + @Override + public int getSlotStackLimit() { + return 16; + } } |