Moved facade adding to onItemUseFirst() in order to be able to add them to pipes with gates

This commit is contained in:
Krapht 2012-07-15 01:37:50 +02:00
parent ebe9e3a020
commit 9840c0e406

View file

@ -54,32 +54,23 @@ public class ItemFacade extends ItemBuildCraft {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side) {
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side) {
if (worldObj.isRemote) return false;
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) return false;
TileGenericPipe pipeTile = (TileGenericPipe)tile;
if (player.isSneaking()) { //Strip facade
if (!pipeTile.hasFacade(Orientations.dirs()[side])) return false;
pipeTile.dropFacade(Orientations.dirs()[side]);
return true;
} else {
if (((TileGenericPipe)tile).addFacade(Orientations.values()[side], ItemFacade.getBlockId(stack.getItemDamage()), ItemFacade.getMetaData(stack.getItemDamage()))){
stack.stackSize--;
return true;
}
return false;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side) {
if (worldObj.isRemote) return false;
if (!player.isSneaking()) return false;
TileEntity tile = worldObj.getBlockTileEntity(x, y, z);
if (!(tile instanceof TileGenericPipe)) return false;
TileGenericPipe pipeTile = (TileGenericPipe)tile;
if (!pipeTile.hasFacade(Orientations.dirs()[side])) return false;
pipeTile.dropFacade(Orientations.dirs()[side]);
return true;
}
@SuppressWarnings("rawtypes")