diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-08-15 13:48:36 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-08-15 13:48:36 +1000 |
commit | 8a3abd42c21677c2873771868beb09c1487bd448 (patch) | |
tree | 24573b9a15ecde281c430e50dda1e46f9c0b2c44 /src/Java | |
parent | f38c45d27bbccda65cba941887e4c6dbb303df10 (diff) | |
download | GT5-Unofficial-8a3abd42c21677c2873771868beb09c1487bd448.tar.gz GT5-Unofficial-8a3abd42c21677c2873771868beb09c1487bd448.tar.bz2 GT5-Unofficial-8a3abd42c21677c2873771868beb09c1487bd448.zip |
$ Fixed an issue where the Fish Catcher would duplicate one of it's slots visually.
$ Fixed Fish Catcher trying to give seaweed loot without Pam's Harvest Craft, it now gives dirt as a fallback.
$ Fixed Fish Catcher not giving out all the various Minecraft fish. (Still needs work)
Diffstat (limited to 'src/Java')
3 files changed, 118 insertions, 97 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_FishTrap.java b/src/Java/gtPlusPlus/core/container/Container_FishTrap.java index 46b9a0c523..34cfdf9bf3 100644 --- a/src/Java/gtPlusPlus/core/container/Container_FishTrap.java +++ b/src/Java/gtPlusPlus/core/container/Container_FishTrap.java @@ -21,14 +21,15 @@ public class Container_FishTrap extends Container { private final int posY; private final int posZ; - - public static int StorageSlotNumber = 15; //Number of slots in storage area - public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; //All slots + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots private final int[] slotStorage = new int[15]; - public Container_FishTrap(final InventoryPlayer inventory, final TileEntityFishTrap te){ + public Container_FishTrap(final InventoryPlayer inventory, final TileEntityFishTrap te) { this.tile_entity = te; this.inventoryChest = te.getInventory(); @@ -39,120 +40,87 @@ public class Container_FishTrap extends Container { this.posY = te.yCoord; this.posZ = te.zCoord; - int o=0; + int o = 0; - //Storage Side - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 5; ++var7) - { - //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, var7 + (var6 * 4), 36+ 8 + (var7 * 18), 8 + 7 + (var6 * 18))); + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { this.slotStorage[o] = o; - o++; + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); } } - o=0; - - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); } } - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); } } @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){ + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { - if (!aPlayer.worldObj.isRemote){ - if ((aSlotIndex == 999) || (aSlotIndex == -999)){ - //Utils.LOG_WARNING("??? - "+aSlotIndex); + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); } } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - - - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer){ + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); } - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockFishTrap){ + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockFishTrap) { return false; } return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; } - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) - { + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { ItemStack var3 = null; - final Slot var4 = (Slot)this.inventorySlots.get(par2); + final Slot var4 = (Slot) this.inventorySlots.get(par2); - if ((var4 != null) && var4.getHasStack()) - { + if ((var4 != null) && var4.getHasStack()) { final ItemStack var5 = var4.getStack(); var3 = var5.copy(); - /*if (par2 == 0) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) - { - return null; - } - - var4.onSlotChange(var5, var3); - } - else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber) - { - if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) - { - return null; - } - } - else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) - { - return null; - } - } - else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) - { - return null; - }*/ - - if (var5.stackSize == 0) - { - var4.putStack((ItemStack)null); - } - else - { + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { var4.onSlotChanged(); } - if (var5.stackSize == var3.stackSize) - { + if (var5.stackSize == var3.stackSize) { return null; } @@ -162,11 +130,10 @@ public class Container_FishTrap extends Container { return var3; } - //Can merge Slot + // Can merge Slot @Override public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { return super.func_94530_a(p_94530_1_, p_94530_2_); } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/slots/SlotNoInput.java b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java index 3177c24868..db0630c4cd 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotNoInput.java +++ b/src/Java/gtPlusPlus/core/slots/SlotNoInput.java @@ -6,8 +6,8 @@ import net.minecraft.item.ItemStack; public class SlotNoInput extends Slot{ - public SlotNoInput(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); + public SlotNoInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); } @Override diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index 5e1bd73a51..c066a27b1f 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -95,19 +95,64 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { int checkingSlot = 0; final ItemStack loot = this.generateLootForFishTrap(); try { + Utils.LOG_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); for (final ItemStack contents : this.getInventory().getInventory()) { + if (contents == null) { + Utils.LOG_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); this.getInventory().setInventorySlotContents(checkingSlot, loot); this.markDirty(); return true; } + else if (contents.getItem() == loot.getItem() && contents.stackSize <= contents.getMaxStackSize() - 1) { if (contents.stackSize < contents.getMaxStackSize()) { - contents.stackSize++; - this.markDirty(); - return true; + if (contents.getHasSubtypes()){ + if (contents.getItemDamage() == loot.getItemDamage()){ + Utils.LOG_INFO("1-Trying to add one more "+loot.getDisplayName()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + contents.stackSize++; + this.markDirty(); + return true; + } + else { + Utils.LOG_INFO("2-Trying to add one more "+loot.getDisplayName()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + // + } + } + else { + Utils.LOG_INFO("3-Trying to add one more "+loot.getDisplayName()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + contents.stackSize++; + this.markDirty(); + return true; + } + } } + + /*if (ItemUtils.simpleMetaStack(loot.getItem(), loot.getItemDamage(), 1) == ItemUtils.simpleMetaStack(contents.getItem(), contents.getItemDamage(), 1)){ + Utils.LOG_INFO("Found Item With Existing Stack & Meta."); + if (contents.stackSize <= contents.getMaxStackSize() - 1){ + Utils.LOG_INFO("Existing stack is not max stack size."); + if (contents.stackSize < contents.getMaxStackSize()) { + Utils.LOG_INFO("Adding Item To partially filled Slot."); + contents.stackSize++; + this.markDirty(); + return true; + } + } + } + else if (contents.getItem() == loot.getItem() && contents.getItemDamage() != loot.getItemDamage()) { + Utils.LOG_INFO("Found Item With Existing Stack & Different Meta."); + if (contents.stackSize <= contents.getMaxStackSize() - 1){ + Utils.LOG_INFO("Existing stack is not max stack size."); + if (contents.stackSize < contents.getMaxStackSize()) { + Utils.LOG_INFO("Adding Item To partially filled Slot."); + contents.stackSize++; + this.markDirty(); + return true; + } + } + }*/ checkingSlot++; } } @@ -130,23 +175,27 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { else if (lootWeight <= 20) { loot = ItemUtils.getSimpleStack(Blocks.sand); } + // Junk Loot else if (lootWeight <= 30) { - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1); + if (LoadedMods.PamsHarvestcraft) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1); + } + else { + loot = ItemUtils.getSimpleStack(Blocks.dirt); + } } // Pam Fish - else if (lootWeight <= 60) { - if (LoadedMods.PamsHarvestcraft) { + else if (lootWeight <= 99) { + int lootSwitch = MathUtils.randInt(0, 1); + if (LoadedMods.PamsHarvestcraft && lootSwitch==0) { loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken( prefix + harvestcraftFish[MathUtils.randInt(0, harvestcraftFish.length - 1)] + suffix, 1); } else { - loot = ItemUtils.getSimpleStack(minecraftFish[MathUtils.randInt(0, minecraftFish.length - 1)], 1); + int fishID = MathUtils.randInt(0, minecraftFish.length - 1); + loot = minecraftFish[fishID]; } } - // Minecraft Fish - else if (lootWeight <= 99) { - loot = ItemUtils.getSimpleStack(minecraftFish[MathUtils.randInt(0, minecraftFish.length - 1)], 1); - } else if (lootWeight == 100){ int rareLoot = MathUtils.randInt(1, 10); @@ -172,6 +221,8 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { else { loot = ItemUtils.getSimpleStack(Blocks.diamond_ore); } + loot.stackSize=1; + Utils.LOG_INFO("Adding x"+loot.stackSize+" "+loot.getDisplayName()+"."); return loot; } @@ -230,7 +281,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { calculateTickrate = 2000; } else if (this.waterSides == 6) { - calculateTickrate = 900; + calculateTickrate = 100; } this.baseTickRate = calculateTickrate; } @@ -270,9 +321,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; - private static final ItemStack[] minecraftFish = { ItemUtils.getItemStack("minecraft:fish", 1), - ItemUtils.getItemStack("minecraft:fish:1", 1), ItemUtils.getItemStack("minecraft:fish:2", 1), - ItemUtils.getItemStack("minecraft:fish:3", 1) }; + private static final ItemStack[] minecraftFish = { + ItemUtils.simpleMetaStack(Items.fish, 0, 1).copy(), + ItemUtils.simpleMetaStack(Items.fish, 1, 1).copy(), + ItemUtils.simpleMetaStack(Items.fish, 2, 1).copy(), + ItemUtils.simpleMetaStack(Items.fish, 3, 1).copy() + }; public static void pamsHarvestCraftCompat() { for (int i = 0; i < harvestcraftFish.length; i++) { |