diff --git a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java deleted file mode 100644 index 5160afa2a..000000000 --- a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Mar 16, 2015, 6:42:40 PM (GMT)] - */ -package vazkii.botania.client.gui.bag; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import vazkii.botania.client.gui.SlotLocked; - -public class ContainerFlowerBag extends Container { - - InventoryFlowerBag flowerBagInv; - - public ContainerFlowerBag(EntityPlayer player) { - int i; - int j; - - int slot = player.inventory.currentItem; - IInventory playerInv = player.inventory; - flowerBagInv = new InventoryFlowerBag(player, slot); - - for(i = 0; i < 2; ++i) - for(j = 0; j < 8; ++j) { - int k = j + i * 8; - addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k)); - } - - for(i = 0; i < 3; ++i) - for(j = 0; j < 9; ++j) - addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - - for(i = 0; i < 9; ++i) { - if(player.inventory.currentItem == i) - addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); - else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); - } - - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - boolean can = flowerBagInv.isUseableByPlayer(player); - if(!can) - onContainerClosed(player); - - return can; - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - flowerBagInv.pushInventory(); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - Slot slot = (Slot)inventorySlots.get(p_82846_2_); - - if(slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - if(p_82846_2_ < 16) { - if(!mergeItemStack(itemstack1, 16, 52, true)) - return null; - } else { - int i = itemstack.getItemDamage(); - if(i < 16) { - Slot slot1 = (Slot)inventorySlots.get(i); - if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) - return null; - } - } - - if(itemstack1.stackSize == 0) - slot.putStack((ItemStack)null); - else slot.onSlotChanged(); - - if(itemstack1.stackSize == itemstack.stackSize) - return null; - - slot.onPickupFromSlot(p_82846_1_, itemstack1); - } - - return itemstack; - } - -} diff --git a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java deleted file mode 100644 index b3cee8997..000000000 --- a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Mar 16, 2015, 6:42:43 PM (GMT)] - */ -package vazkii.botania.client.gui.bag; - -import java.util.List; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; - -import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.block.ModBlocks; - -public class GuiFlowerBag extends GuiContainer { - - private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); - - public GuiFlowerBag(EntityPlayer player) { - super(new ContainerFlowerBag(player)); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String s = StatCollector.translateToLocal("item.botania:flowerBag.name"); - fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); - fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int k = (width - xSize) / 2; - int l = (height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); - - List slotList = inventorySlots.inventorySlots; - for(Slot slot : slotList) - if(slot instanceof SlotFlower) { - SlotFlower slotf = (SlotFlower) slot; - if(!slotf.getHasStack()) { - ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color); - int x = guiLeft + slotf.xDisplayPosition; - int y = guiTop + slotf.yDisplayPosition; - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); - } - } - } - - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } - -} diff --git a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java deleted file mode 100644 index 10fcb06f9..000000000 --- a/src/main/java/vazkii/botania/client/gui/bag/InventoryFlowerBag.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Mar 16, 2015, 6:42:56 PM (GMT)] - */ -package vazkii.botania.client.gui.bag; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import vazkii.botania.common.item.ItemFlowerBag; -import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.lib.LibItemNames; - -public class InventoryFlowerBag implements IInventory { - - private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; - - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - - boolean invPushed = false; - ItemStack storedInv = null; - - public InventoryFlowerBag(EntityPlayer player, int slot) { - this.player = player; - this.slot = slot; - } - - public static boolean isFlowerBag(ItemStack stack) { - return stack != null && stack.getItem() == ModItems.flowerBag; - } - - ItemStack getStack() { - ItemStack stack = player.inventory.getStackInSlot(slot); - if(stack != null) - storedInv = stack; - return stack; - } - - ItemStack[] getInventory() { - if(stacks != null) - return stacks; - - ItemStack stack = getStack(); - if(isFlowerBag(getStack())) { - stacks = ItemFlowerBag.loadStacks(stack); - return stacks; - } - - return FALLBACK_INVENTORY; - } - - public void pushInventory() { - if(invPushed) - return; - - ItemStack stack = getStack(); - if(stack == null) - stack = storedInv; - - if(stack != null) { - ItemStack[] inv = getInventory(); - ItemFlowerBag.setStacks(stack, inv); - } - - invPushed = true; - } - - @Override - public int getSizeInventory() { - return 16; - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if (inventorySlots[i] != null) { - ItemStack stackAt; - - if (inventorySlots[i].stackSize <= j) { - stackAt = inventorySlots[i]; - inventorySlots[i] = null; - return stackAt; - } else { - stackAt = inventorySlots[i].splitStack(j); - - if (inventorySlots[i].stackSize == 0) - inventorySlots[i] = null; - - return stackAt; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[i] = itemstack; - } - - @Override - public int getInventoryStackLimit() { - return isFlowerBag(getStack()) ? 64 : 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isFlowerBag(getStack()); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isFlowerBag(getStack()); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void openInventory() { - // NO-OP - } - - @Override - public void closeInventory() { - // NO-OP - } - - @Override - public String getInventoryName() { - return LibItemNames.FLOWER_BAG; - } - - @Override - public void markDirty() { - // NO-OP - } - -} diff --git a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java b/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java deleted file mode 100644 index ba4c32378..000000000 --- a/src/main/java/vazkii/botania/client/gui/bag/SlotFlower.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Mar 16, 2015, 7:20:05 PM (GMT)] - */ -package vazkii.botania.client.gui.bag; - -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import vazkii.botania.common.block.ModBlocks; - -public class SlotFlower extends Slot { - - InventoryFlowerBag inv; - int color; - - public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - this.color = color; - inv = p_i1824_1_; - } - - @Override - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - inv.setInventorySlotContents(color, newStack); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color; - } - -} diff --git a/src/main/java/vazkii/botania/client/gui/bags/ContainerMagicPlantBag.java b/src/main/java/vazkii/botania/client/gui/bags/ContainerMagicPlantBag.java new file mode 100644 index 000000000..c0179d6d6 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/ContainerMagicPlantBag.java @@ -0,0 +1,89 @@ +package vazkii.botania.client.gui.bags; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import vazkii.botania.client.gui.SlotLocked; + +public abstract class ContainerMagicPlantBag extends Container { + + protected InventoryMagicPlantBag magicPlantInv; + public ContainerMagicPlantBag(EntityPlayer player) { + int i; + int j; + + IInventory playerInv = player.inventory; + + addMagicPlantSlots(player); + + for(i = 0; i < 3; ++i) { + for(j = 0; j < 9; ++j) { + addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + + for(i = 0; i < 9; ++i) { + if(player.inventory.currentItem == i) { + addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142)); + } + else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); + } + } + + public abstract void addMagicPlantSlots(EntityPlayer player); + + @Override + public boolean canInteractWith(EntityPlayer player) { + boolean can = magicPlantInv.isUseableByPlayer(player); + if(!can) + onContainerClosed(player); + + return can; + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + magicPlantInv.pushInventory(); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + ItemStack itemstack = null; + Slot slot = (Slot)inventorySlots.get(p_82846_2_); + + if(slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if(p_82846_2_ < 16) { + if(!mergeItemStack(itemstack1, 16, 52, true)) + return null; + } else { + int i = itemstack.getItemDamage(); + if(i < 16) { + Slot slot1 = (Slot)inventorySlots.get(i); + if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) + return null; + } + } + + if(itemstack1.stackSize == 0) + slot.putStack((ItemStack)null); + else slot.onSlotChanged(); + + if(itemstack1.stackSize == itemstack.stackSize) + return null; + + slot.onPickupFromSlot(p_82846_1_, itemstack1); + } + + return itemstack; + } + +} + + diff --git a/src/main/java/vazkii/botania/client/gui/bags/GuiMagicPlantBag.java b/src/main/java/vazkii/botania/client/gui/bags/GuiMagicPlantBag.java new file mode 100644 index 000000000..92c65bce7 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/GuiMagicPlantBag.java @@ -0,0 +1,65 @@ +package vazkii.botania.client.gui.bags; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +public abstract class GuiMagicPlantBag extends GuiContainer { + + private final ResourceLocation texture; + public GuiMagicPlantBag(ContainerMagicPlantBag container, ResourceLocation texture) { + super(container); + this.texture = texture; + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + String s = StatCollector.translateToLocal(getLocalizedNameKey()); + fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int k = (width - xSize) / 2; + int l = (height - ySize) / 2; + drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + + List slotList = inventorySlots.inventorySlots; + for(Slot slot : slotList) + if(slot instanceof SlotMagicPlant) { + SlotMagicPlant slotf = (SlotMagicPlant) slot; + if(!slotf.getHasStack()) { + ItemStack stack = new ItemStack(itemTypeAllowed(), 0, slotf.color); + int x = guiLeft + slotf.xDisplayPosition; + int y = guiTop + slotf.yDisplayPosition; + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); + } + } + } + + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } + + protected abstract Block itemTypeAllowed(); + + protected abstract String getLocalizedNameKey(); +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/gui/bags/InventoryMagicPlantBag.java b/src/main/java/vazkii/botania/client/gui/bags/InventoryMagicPlantBag.java new file mode 100644 index 000000000..ffea63b75 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/InventoryMagicPlantBag.java @@ -0,0 +1,148 @@ +package vazkii.botania.client.gui.bags; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import vazkii.botania.common.item.bag.ItemBagBase; + +public abstract class InventoryMagicPlantBag implements IInventory { + + private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16]; + + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + + boolean invPushed = false; + ItemStack storedInv = null; + + public InventoryMagicPlantBag(EntityPlayer player, int slot) { + this.player = player; + this.slot = slot; + } + + ItemStack getStack() { + ItemStack stack = player.inventory.getStackInSlot(slot); + if(stack != null) + storedInv = stack; + return stack; + } + + + public void pushInventory() { + if(invPushed) + return; + + ItemStack stack = getStack(); + if(stack == null) + stack = storedInv; + + if(stack != null) { + ItemStack[] inv = getInventory(); + ItemBagBase.setStacks(stack, inv); + } + + invPushed = true; + } + + ItemStack[] getInventory() { + if(stacks != null) + return stacks; + + ItemStack stack = getStack(); + if(isMagicPlantBag(getStack())) { + stacks = ItemBagBase.loadStacks(stack); + return stacks; + } + + return FALLBACK_INVENTORY; + } + + @Override + public int getSizeInventory() { + return 16; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + return getInventory()[slotIn]; + } + + @Override + public ItemStack decrStackSize(int index, int count) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[index] != null) { + ItemStack stackAt; + + if (inventorySlots[index].stackSize <= count) { + stackAt = inventorySlots[index]; + inventorySlots[index] = null; + return stackAt; + } else { + stackAt = inventorySlots[index].splitStack(count); + + if (inventorySlots[index].stackSize == 0) + inventorySlots[index] = null; + + return stackAt; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + return getStackInSlot(index); + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[index] = stack; + } + + @Override + public String getInventoryName() { + return getBagName(); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return isMagicPlantBag(getStack()) ? 64 : 0; + } + + @Override + public void markDirty() { + // NO-OP + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return isMagicPlantBag(getStack()); + } + + @Override + public void openInventory() { + // NO-OP + } + + @Override + public void closeInventory() { + // NO-OP + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + return isMagicPlantBag(getStack()); + } + + protected abstract String getBagName(); + + public abstract boolean isMagicPlantBag(ItemStack stack); +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/SlotMagicPlant.java b/src/main/java/vazkii/botania/client/gui/bags/SlotMagicPlant.java new file mode 100644 index 000000000..6f8b351ec --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/SlotMagicPlant.java @@ -0,0 +1,32 @@ + +package vazkii.botania.client.gui.bags; + +import net.minecraft.block.Block; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import vazkii.botania.common.block.ModBlocks; + +public abstract class SlotMagicPlant extends Slot { + + InventoryMagicPlantBag inv; + int color; + + public SlotMagicPlant(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + this.color = color; + inv = p_i1824_1_; + } + + @Override + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + inv.setInventorySlotContents(color, newStack); + } + + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem() == Item.getItemFromBlock(getValidBlock()) && stack.getItemDamage() == color; + } + + protected abstract Block getValidBlock(); +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/client/gui/bags/flowerBag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/ContainerFlowerBag.java new file mode 100644 index 000000000..73e1e580a --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/ContainerFlowerBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.client.gui.bags.flowerBag; + +import net.minecraft.entity.player.EntityPlayer; +import vazkii.botania.client.gui.bags.ContainerMagicPlantBag; + +public class ContainerFlowerBag extends ContainerMagicPlantBag { + public ContainerFlowerBag(EntityPlayer player) { + super(player); + } + + @Override + public void addMagicPlantSlots(EntityPlayer player) { + int slot = player.inventory.currentItem; + magicPlantInv = new InventoryFlowerBag(player, slot); + + for(int i = 0; i < 2; ++i) { + for (int j = 0; j < 8; ++j) { + int k = j + i * 8; + addSlotToContainer(new SlotFlower(magicPlantInv, k, 17 + j * 18, 26 + i * 18, k)); + } + } + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/flowerBag/GuiFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/GuiFlowerBag.java new file mode 100644 index 000000000..aaeb2c132 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/GuiFlowerBag.java @@ -0,0 +1,27 @@ +package vazkii.botania.client.gui.bags.flowerBag; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.client.gui.bags.GuiMagicPlantBag; +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.block.ModBlocks; + +public class GuiFlowerBag extends GuiMagicPlantBag { + + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG); + + public GuiFlowerBag(EntityPlayer player) { + super(new ContainerFlowerBag(player), texture); + } + + @Override + protected Block itemTypeAllowed() { + return ModBlocks.flower; + } + + @Override + protected String getLocalizedNameKey() { + return "item.botania:flowerBag.name"; + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/flowerBag/InventoryFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/InventoryFlowerBag.java new file mode 100644 index 000000000..20867ae42 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/InventoryFlowerBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.client.gui.bags.flowerBag; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import vazkii.botania.client.gui.bags.InventoryMagicPlantBag; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.lib.LibItemNames; + +public class InventoryFlowerBag extends InventoryMagicPlantBag { + public InventoryFlowerBag(EntityPlayer player, int slot) { + super(player, slot); + } + + @Override + public boolean isMagicPlantBag(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.flowerBag; + } + + @Override + protected String getBagName() { + return LibItemNames.FLOWER_BAG; + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/flowerBag/SlotFlower.java b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/SlotFlower.java new file mode 100644 index 000000000..cb5082608 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/flowerBag/SlotFlower.java @@ -0,0 +1,18 @@ +package vazkii.botania.client.gui.bags.flowerBag; + +import net.minecraft.block.Block; +import vazkii.botania.client.gui.bags.InventoryMagicPlantBag; +import vazkii.botania.client.gui.bags.SlotMagicPlant; +import vazkii.botania.common.block.ModBlocks; + +public class SlotFlower extends SlotMagicPlant { + public SlotFlower(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_, color); + } + + @Override + protected Block getValidBlock() { + return ModBlocks.flower; + } + +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/shroomBag/ContainerShroomBag.java b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/ContainerShroomBag.java new file mode 100644 index 000000000..bc59c08df --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/ContainerShroomBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.client.gui.bags.shroomBag; + +import net.minecraft.entity.player.EntityPlayer; +import vazkii.botania.client.gui.bags.ContainerMagicPlantBag; + +public class ContainerShroomBag extends ContainerMagicPlantBag { + public ContainerShroomBag(EntityPlayer player) { + super(player); + } + + @Override + public void addMagicPlantSlots(EntityPlayer player) { + int slot = player.inventory.currentItem; + magicPlantInv = new InventoryShroomBag(player, slot); + + for(int i = 0; i < 2; ++i) { + for (int j = 0; j < 8; ++j) { + int k = j + i * 8; + addSlotToContainer(new SlotShroom(magicPlantInv, k, 17 + j * 18, 26 + i * 18, k)); + } + } + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/shroomBag/GuiShroomBag.java b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/GuiShroomBag.java new file mode 100644 index 000000000..763f679b7 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/GuiShroomBag.java @@ -0,0 +1,27 @@ +package vazkii.botania.client.gui.bags.shroomBag; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.client.gui.bags.GuiMagicPlantBag; +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.block.ModBlocks; + +public class GuiShroomBag extends GuiMagicPlantBag { + + private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_SHROOM_BAG); + + public GuiShroomBag(EntityPlayer player) { + super(new ContainerShroomBag(player), texture); + } + + @Override + protected Block itemTypeAllowed() { + return ModBlocks.mushroom; + } + + @Override + protected String getLocalizedNameKey() { + return "item.botania:shroomBag.name"; + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/shroomBag/InventoryShroomBag.java b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/InventoryShroomBag.java new file mode 100644 index 000000000..37d99a41a --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/InventoryShroomBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.client.gui.bags.shroomBag; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import vazkii.botania.client.gui.bags.InventoryMagicPlantBag; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.lib.LibItemNames; + +public class InventoryShroomBag extends InventoryMagicPlantBag { + public InventoryShroomBag(EntityPlayer player, int slot) { + super(player, slot); + } + + @Override + public boolean isMagicPlantBag(ItemStack stack) { + return stack != null && stack.getItem() == ModItems.shroomBag; + } + + @Override + protected String getBagName() { + return LibItemNames.SHROOM_BAG; + } +} diff --git a/src/main/java/vazkii/botania/client/gui/bags/shroomBag/SlotShroom.java b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/SlotShroom.java new file mode 100644 index 000000000..da8d6e087 --- /dev/null +++ b/src/main/java/vazkii/botania/client/gui/bags/shroomBag/SlotShroom.java @@ -0,0 +1,18 @@ +package vazkii.botania.client.gui.bags.shroomBag; + +import net.minecraft.block.Block; +import vazkii.botania.client.gui.bags.InventoryMagicPlantBag; +import vazkii.botania.client.gui.bags.SlotMagicPlant; +import vazkii.botania.common.block.ModBlocks; + +public class SlotShroom extends SlotMagicPlant { + public SlotShroom(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_, color); + } + + @Override + protected Block getValidBlock() { + return ModBlocks.mushroom; + } + +} diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index 584d12181..f16c2c172 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -44,6 +44,7 @@ public final class LibResources { public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png"; public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png"; public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png"; + public static final String GUI_SHROOM_BAG = PREFIX_GUI + "shroomBag.png"; public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png"; public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png"; public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png"; diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index 1737229ce..bb226a4f7 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -257,6 +257,7 @@ public final class ModCraftingRecipes { public static IRecipe recipeSwapRing; public static IRecipe recipeSnowHorn; public static IRecipe recipeFlowerBag; + public static IRecipe recipeShroomBag; public static IRecipe recipePhantomInk; public static IRecipe recipePoolCart; public static IRecipe recipePump; @@ -1768,6 +1769,13 @@ public final class ModCraftingRecipes { 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe(); + // Mushroom Pouch Recipe + GameRegistry.addShapedRecipe(new ItemStack(ModItems.shroomBag), + "WPW", "W W", " W ", + 'P', new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE), + 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE)); + recipeShroomBag = BotaniaAPI.getLatestAddedRecipe(); + // Phantom Ink Recipe addShapelessOreDictRecipe(new ItemStack(ModItems.phantomInk, 4), LibOreDict.MANA_PEARL, "dye", "blockGlass", new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle)); recipePhantomInk = BotaniaAPI.getLatestAddedRecipe(); diff --git a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java deleted file mode 100644 index a57e00bfb..000000000 --- a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - * - * File Created @ [Mar 16, 2015, 6:43:33 PM (GMT)] - */ -package vazkii.botania.common.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.core.helper.InventoryHelper; -import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.lib.LibGuiIDs; -import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class ItemFlowerBag extends ItemMod { - - private static final String TAG_ITEMS = "InvItems"; - private static final String TAG_SLOT = "Slot"; - - public ItemFlowerBag() { - setUnlocalizedName(LibItemNames.FLOWER_BAG); - setMaxStackSize(1); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPickupItem(EntityItemPickupEvent event) { - ItemStack stack = event.item.getEntityItem(); - if(stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) { - int color = stack.getItemDamage(); - if(color > 15) - return; - - for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { - if(i == event.entityPlayer.inventory.currentItem) - continue; // prevent item deletion - - ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); - if(invStack != null && invStack.getItem() == this) { - ItemStack[] bagInv = loadStacks(invStack); - ItemStack stackAt = bagInv[color]; - boolean didChange = false; - if(stackAt == null) { - bagInv[color] = stack.copy(); - stack.stackSize = 0; - didChange = true; - } else { - int stackAtSize = stackAt.stackSize; - int stackSize = stack.stackSize; - int spare = 64 - stackAtSize; - int pass = Math.min(spare, stackSize); - if(pass > 0) { - stackAt.stackSize += pass; - stack.stackSize -= pass; - didChange = true; - } - } - - if(didChange) - setStacks(invStack, bagInv); - } - - if(stack.stackSize == 0) - return; - } - } - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0); - return stack; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { - TileEntity tile = world.getTileEntity(x, y, z); - if(tile != null && tile instanceof IInventory) { - if(!world.isRemote) { - ForgeDirection side = ForgeDirection.getOrientation(s); - IInventory inv = (IInventory) tile; - ItemStack[] stacks = loadStacks(stack); - ItemStack[] newStacks = new ItemStack[stacks.length]; - boolean putAny = false; - - int i = 0; - for(ItemStack petal : stacks) { - if(petal != null) { - int count = InventoryHelper.testInventoryInsertion(inv, petal, side); - InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); - - ItemStack newPetal = petal.copy(); - if(newPetal.stackSize == 0) - newPetal = null; - - newStacks[i] = newPetal; - putAny |= count > 0; - } - - i++; - } - - setStacks(stack, newStacks); - if(putAny && inv instanceof TileEntityChest) { - inv = InventoryHelper.getInventory(inv); - player.displayGUIChest(inv); - } - } - - return true; - } - return false; - } - - public static ItemStack[] loadStacks(ItemStack stack) { - NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); - ItemStack[] inventorySlots = new ItemStack[16]; - for(int var3 = 0; var3 < var2.tagCount(); ++var3) { - NBTTagCompound var4 = var2.getCompoundTagAt(var3); - byte var5 = var4.getByte(TAG_SLOT); - if(var5 >= 0 && var5 < inventorySlots.length) - inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - - return inventorySlots; - } - - public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { - NBTTagList var2 = new NBTTagList(); - for(int var3 = 0; var3 < inventorySlots.length; ++var3) - if(inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte(TAG_SLOT, (byte)var3); - inventorySlots[var3].writeToNBT(var4); - var2.appendTag(var4); - } - - ItemNBTHelper.setList(stack, TAG_ITEMS, var2); - } - -} diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index d029d5a93..43b8f5f53 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -15,6 +15,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.common.item.bag.ItemFlowerBag; +import vazkii.botania.common.item.bag.ItemShroomBag; import vazkii.botania.common.item.brew.ItemBrewFlask; import vazkii.botania.common.item.brew.ItemBrewVial; import vazkii.botania.common.item.brew.ItemIncenseStick; @@ -232,6 +234,7 @@ public final class ModItems { public static Item cosmetic; public static Item swapRing; public static Item flowerBag; + public static Item shroomBag; public static Item phantomInk; public static Item poolMinecart; public static Item pinkinator; @@ -381,6 +384,7 @@ public final class ModItems { cosmetic = new ItemBaubleCosmetic(); swapRing = new ItemSwapRing(); flowerBag = new ItemFlowerBag(); + shroomBag = new ItemShroomBag(); phantomInk = new ItemPhantomInk(); poolMinecart = new ItemPoolMinecart(); pinkinator = new ItemPinkinator(); diff --git a/src/main/java/vazkii/botania/common/item/bag/ItemBagBase.java b/src/main/java/vazkii/botania/common/item/bag/ItemBagBase.java new file mode 100644 index 000000000..d842f6bc3 --- /dev/null +++ b/src/main/java/vazkii/botania/common/item/bag/ItemBagBase.java @@ -0,0 +1,154 @@ +package vazkii.botania.common.item.bag; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import vazkii.botania.common.Botania; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.core.helper.InventoryHelper; +import vazkii.botania.common.core.helper.ItemNBTHelper; +import vazkii.botania.common.item.ItemMod; +import vazkii.botania.common.lib.LibGuiIDs; +import vazkii.botania.common.lib.LibItemNames; + +public abstract class ItemBagBase extends ItemMod { + + private static final String TAG_ITEMS = "InvItems"; + private static final String TAG_SLOT = "Slot"; + + public ItemBagBase(String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPickupItem(EntityItemPickupEvent event) { + ItemStack stack = event.item.getEntityItem(); + if(stack.getItem() == Item.getItemFromBlock(getValidPickUp()) && stack.stackSize > 0) { + int color = stack.getItemDamage(); + if(color > 15) + return; + + for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) { + if(i == event.entityPlayer.inventory.currentItem) + continue; // prevent item deletion + + ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i); + if(invStack != null && invStack.getItem() == this) { + ItemStack[] bagInv = loadStacks(invStack); + ItemStack stackAt = bagInv[color]; + boolean didChange = false; + if(stackAt == null) { + bagInv[color] = stack.copy(); + stack.stackSize = 0; + didChange = true; + } else { + int stackAtSize = stackAt.stackSize; + int stackSize = stack.stackSize; + int spare = 64 - stackAtSize; + int pass = Math.min(spare, stackSize); + if(pass > 0) { + stackAt.stackSize += pass; + stack.stackSize -= pass; + didChange = true; + } + } + + if(didChange) + setStacks(invStack, bagInv); + } + + if(stack.stackSize == 0) + return; + } + } + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.openGui(Botania.instance, getGuiID(), world, 0, 0, 0); + return stack; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null && tile instanceof IInventory) { + if(!world.isRemote) { + ForgeDirection side = ForgeDirection.getOrientation(s); + IInventory inv = (IInventory) tile; + ItemStack[] stacks = loadStacks(stack); + ItemStack[] newStacks = new ItemStack[stacks.length]; + boolean putAny = false; + + int i = 0; + for(ItemStack petal : stacks) { + if(petal != null) { + int count = InventoryHelper.testInventoryInsertion(inv, petal, side); + InventoryHelper.insertItemIntoInventory(inv, petal, side, -1); + + ItemStack newPetal = petal.copy(); + if(newPetal.stackSize == 0) + newPetal = null; + + newStacks[i] = newPetal; + putAny |= count > 0; + } + + i++; + } + + setStacks(stack, newStacks); + if(putAny && inv instanceof TileEntityChest) { + inv = InventoryHelper.getInventory(inv); + player.displayGUIChest(inv); + } + } + + return true; + } + return false; + } + + public static ItemStack[] loadStacks(ItemStack stack) { + NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false); + ItemStack[] inventorySlots = new ItemStack[16]; + for(int var3 = 0; var3 < var2.tagCount(); ++var3) { + NBTTagCompound var4 = var2.getCompoundTagAt(var3); + byte var5 = var4.getByte(TAG_SLOT); + if(var5 >= 0 && var5 < inventorySlots.length) + inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + + return inventorySlots; + } + + public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) { + NBTTagList var2 = new NBTTagList(); + for(int var3 = 0; var3 < inventorySlots.length; ++var3) + if(inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte(TAG_SLOT, (byte)var3); + inventorySlots[var3].writeToNBT(var4); + var2.appendTag(var4); + } + + ItemNBTHelper.setList(stack, TAG_ITEMS, var2); + } + + protected abstract Block getValidPickUp(); + + protected abstract int getGuiID(); +} diff --git a/src/main/java/vazkii/botania/common/item/bag/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/bag/ItemFlowerBag.java new file mode 100644 index 000000000..f63de4478 --- /dev/null +++ b/src/main/java/vazkii/botania/common/item/bag/ItemFlowerBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.common.item.bag; + +import net.minecraft.block.Block; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.lib.LibGuiIDs; +import vazkii.botania.common.lib.LibItemNames; + +public class ItemFlowerBag extends ItemBagBase { + + public ItemFlowerBag() { + super(LibItemNames.FLOWER_BAG); + } + + @Override + protected Block getValidPickUp() { + return ModBlocks.flower; + } + + @Override + protected int getGuiID() { + return LibGuiIDs.FLOWER_BAG; + } +} diff --git a/src/main/java/vazkii/botania/common/item/bag/ItemShroomBag.java b/src/main/java/vazkii/botania/common/item/bag/ItemShroomBag.java new file mode 100644 index 000000000..395ba703e --- /dev/null +++ b/src/main/java/vazkii/botania/common/item/bag/ItemShroomBag.java @@ -0,0 +1,23 @@ +package vazkii.botania.common.item.bag; + +import net.minecraft.block.Block; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.lib.LibGuiIDs; +import vazkii.botania.common.lib.LibItemNames; + +public class ItemShroomBag extends ItemBagBase{ + + public ItemShroomBag() { + super(LibItemNames.SHROOM_BAG); + } + + @Override + protected Block getValidPickUp() { + return ModBlocks.mushroom; + } + + @Override + protected int getGuiID() { + return LibGuiIDs.SHROOM_BAG; + } +} diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 2c291d353..be7a30ed0 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -69,6 +69,7 @@ public final class LexiconData { public static LexiconEntry terrasteel; public static LexiconEntry blackLotus; public static LexiconEntry flowerBag; + public static LexiconEntry shroomBag; public static LexiconEntry gardenOfGlass; public static LexiconEntry manaIntro; @@ -395,6 +396,10 @@ public final class LexiconData { flowerBag.setLexiconPages(new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); + shroomBag = new BLexiconEntry(LibLexicon.BASICS_SHROOM_BAG, categoryBasics); + shroomBag.setLexiconPages(new PageText("0"), + new PageCraftingRecipe("1", ModCraftingRecipes.recipeShroomBag)); + if (Botania.gardenOfGlassLoaded) { gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); gardenOfGlass.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), diff --git a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java index fefcb749a..98a5d2205 100644 --- a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java +++ b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java @@ -17,4 +17,6 @@ public final class LibGuiIDs { public static final int FLOWER_BAG = 2; public static final int BAUBLE_BOX = 3; + public static final int SHROOM_BAG = 4; + } diff --git a/src/main/java/vazkii/botania/common/lib/LibItemNames.java b/src/main/java/vazkii/botania/common/lib/LibItemNames.java index 98f2643f7..3e27e8103 100644 --- a/src/main/java/vazkii/botania/common/lib/LibItemNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibItemNames.java @@ -126,6 +126,7 @@ public final class LibItemNames { public static final String COSMETIC = "cosmetic"; public static final String SWAP_RING = "swapRing"; public static final String FLOWER_BAG = "flowerBag"; + public static final String SHROOM_BAG = "shroomBag"; public static final String PHANTOM_INK = "phantomInk"; public static final String POOL_MINECART = "poolMinecart"; public static final String PINKINATOR = "pinkinator"; diff --git a/src/main/java/vazkii/botania/common/lib/LibLexicon.java b/src/main/java/vazkii/botania/common/lib/LibLexicon.java index 8b6013961..a2c0cee51 100644 --- a/src/main/java/vazkii/botania/common/lib/LibLexicon.java +++ b/src/main/java/vazkii/botania/common/lib/LibLexicon.java @@ -38,6 +38,7 @@ public final class LibLexicon { public static final String BASICS_TERRASTEEL = "terrasteel"; public static final String BASICS_BLACK_LOTUS = "blackLotus"; public static final String BASICS_FLOWER_BAG = "flowerBag"; + public static final String BASICS_SHROOM_BAG = "shroomBag"; public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass"; public static final String MANA_INTRO = "mIntro"; diff --git a/src/main/java/vazkii/botania/common/network/GuiHandler.java b/src/main/java/vazkii/botania/common/network/GuiHandler.java index 0dd9fea9f..1d08bad85 100644 --- a/src/main/java/vazkii/botania/common/network/GuiHandler.java +++ b/src/main/java/vazkii/botania/common/network/GuiHandler.java @@ -12,8 +12,10 @@ package vazkii.botania.common.network; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import vazkii.botania.client.gui.bag.ContainerFlowerBag; -import vazkii.botania.client.gui.bag.GuiFlowerBag; +import vazkii.botania.client.gui.bags.flowerBag.ContainerFlowerBag; +import vazkii.botania.client.gui.bags.flowerBag.GuiFlowerBag; +import vazkii.botania.client.gui.bags.shroomBag.ContainerShroomBag; +import vazkii.botania.client.gui.bags.shroomBag.GuiShroomBag; import vazkii.botania.client.gui.box.ContainerBaubleBox; import vazkii.botania.client.gui.box.GuiBaubleBox; import vazkii.botania.client.gui.crafting.ContainerCraftingHalo; @@ -31,6 +33,8 @@ public class GuiHandler implements IGuiHandler { return new ContainerCraftingHalo(player.inventory, world); case LibGuiIDs.FLOWER_BAG : return new ContainerFlowerBag(player); + case LibGuiIDs.SHROOM_BAG: + return new ContainerShroomBag(player); case LibGuiIDs.BAUBLE_BOX : return new ContainerBaubleBox(player); } @@ -48,6 +52,8 @@ public class GuiHandler implements IGuiHandler { return new GuiCraftingHalo(player.inventory, world); case LibGuiIDs.FLOWER_BAG : return new GuiFlowerBag(player); + case LibGuiIDs.SHROOM_BAG: + return new GuiShroomBag(player); case LibGuiIDs.BAUBLE_BOX : return new GuiBaubleBox(player); } diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index 017d4c38c..7ae72e4c7 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -1630,6 +1630,7 @@ item.botania:cosmetic31.name=Questgiver Mark item.botania:manaString.name=Mana Infused String item.botania:swapRing.name=Ring of Correction item.botania:flowerBag.name=Flower Pouch +item.botania:shroomBag.name=Mushroom Pouch item.botania:phantomInk.name=Phantom Ink item.botania:poolMinecart.name=Minecart with Mana Pool item.botania:pinkinator.name=The Pinkinator @@ -2121,6 +2122,12 @@ botania.page.flowerBag0=The laws of physics regarding one's &4Inventory&0 are so botania.page.flowerBag2=Items won't be added automatically to the pouch if that's the item being held.
Furthermore, shift-right clicking the pouch into a &1Chest&0 or other inventory will store the flowers it contains into said inventory. botania.page.flowerBag1=Pull a copter out of it (any colors work) +# -- MUSHROOM POUCH +botania.entry.shroomBag=Mushroom Pouch +botania.tagline.shroomBag=A trusty pouch to hold your mushroom goodness +botania.page.shroomBag0=Similar to the &1Flower Pouch&0, the mushroom pouch will hold all of those pesky &1Mystical Mushrooms&0 that have been clogging up your inventory.
Remember the bag will not pick up items if you are holding it in your hand.
Furthermore, shift-right clicking the pouch into a &1Chest&0 or other inventory will store the flowers it contains into said inventory. +botania.page.shroomBag1=Any colors work + # -- WRAP botania.entry.wrap=Wrap botania.tagline.wrap=It's a wrap diff --git a/src/main/resources/assets/botania/textures/gui/flowerBag.png b/src/main/resources/assets/botania/textures/gui/flowerBag.png index 8933ac78b..b6433bc9b 100644 Binary files a/src/main/resources/assets/botania/textures/gui/flowerBag.png and b/src/main/resources/assets/botania/textures/gui/flowerBag.png differ diff --git a/src/main/resources/assets/botania/textures/gui/shroomBag.png b/src/main/resources/assets/botania/textures/gui/shroomBag.png new file mode 100644 index 000000000..fdea8bf77 Binary files /dev/null and b/src/main/resources/assets/botania/textures/gui/shroomBag.png differ diff --git a/src/main/resources/assets/botania/textures/items/shroomBag.png b/src/main/resources/assets/botania/textures/items/shroomBag.png new file mode 100644 index 000000000..c7f61bb76 Binary files /dev/null and b/src/main/resources/assets/botania/textures/items/shroomBag.png differ