Add canOpenGui to IChiselItem

This commit is contained in:
tterrag1098 committed 2015-01-14 21:11:33 -05:00
1 parent b634f654e0
commit b426c847ef
3 files changed
+20 -1

No files matched your search

@@ -1,6 +1,7 @@
package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -10,6 +11,19 @@ import net.minecraft.world.World;
*/
public interface IChiselItem extends IChiselMode {
/**
* Checks whether the chisel can have its GUI opened
*
* @param world
* {@link World} object
* @param player
* The player holding the chisel. It can always be assumed that the player's current item will be this.
* @param chisel
* The {@link ItemStack} representing your chisel
* @return True if the GUI should open. False otherwise.
*/
boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
/**
* Called when an item is chiseled using this chisel
*
@@ -77,7 +77,7 @@ public final class ChiselController {
break;
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
if (!event.world.isRemote) {
if (!event.world.isRemote && chisel.canOpenGui(event.world, event.entityPlayer, held)) {
event.entityPlayer.openGui(Chisel.instance, 0, event.world, 0, 0, 0);
}
break;
@@ -82,6 +82,11 @@ public class ItemChisel extends Item implements IChiselItem {
public ChiselMode getChiselMode(ItemStack itemStack) {
return ChiselMode.SINGLE;
}
@Override
public boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel) {
return true;
}
@Override
public void onChisel(World world, IInventory inv, int slot, ItemStack chisel, ItemStack target) {