mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Safety checks to fix #2727
This commit is contained in:
1 parent
d10df52b92
commit
bd2c468ba4
1 file changed
+12
-4
@@ -13,6 +13,7 @@ package vazkii.botania.common.network;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -25,6 +26,7 @@ import vazkii.botania.client.gui.box.GuiBaubleBox;
|
||||
import vazkii.botania.client.gui.box.InventoryBaubleBox;
|
||||
import vazkii.botania.client.gui.crafting.ContainerCraftingHalo;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
@@ -32,14 +34,17 @@ public class GuiHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int handId, int unused1, int unused2) {
|
||||
EnumHand hand = handId == 1 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
switch(ID) {
|
||||
case LibGuiIDs.CRAFTING_HALO :
|
||||
return new ContainerCraftingHalo(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new ContainerFlowerBag(player.inventory, new InventoryFlowerBag(player.getHeldItem(hand)));
|
||||
if(stack.getItem() == ModItems.flowerBag)
|
||||
return new ContainerFlowerBag(player.inventory, new InventoryFlowerBag(stack));
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new ContainerBaubleBox(player, new InventoryBaubleBox(player.getHeldItem(hand)));
|
||||
if(stack.getItem() == ModItems.baubleBox)
|
||||
return new ContainerBaubleBox(player, new InventoryBaubleBox(stack));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -48,6 +53,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int handId, int unused1, int unused2) {
|
||||
EnumHand hand = handId == 1 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
switch(ID) {
|
||||
case LibGuiIDs.LEXICON :
|
||||
@@ -55,9 +61,11 @@ public class GuiHandler implements IGuiHandler {
|
||||
case LibGuiIDs.CRAFTING_HALO :
|
||||
return new GuiCrafting(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new GuiFlowerBag(player.inventory, new InventoryFlowerBag(player.getHeldItem(hand)));
|
||||
if(stack.getItem() == ModItems.flowerBag)
|
||||
return new GuiFlowerBag(player.inventory, new InventoryFlowerBag(stack));
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new GuiBaubleBox(player, new InventoryBaubleBox(player.getHeldItem(hand)));
|
||||
if(stack.getItem() == ModItems.baubleBox)
|
||||
return new GuiBaubleBox(player, new InventoryBaubleBox(stack));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user