use of net.darkhax.bookshelf.block.BlockBasicChest in project Bookshelf by Darkhax-Minecraft.
the class ItemBlockChest method placeBlockAt.
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
int typeCnt = 0;
final BlockPos posN = pos.north();
final BlockPos posS = pos.south();
final BlockPos posW = pos.west();
final BlockPos posE = pos.east();
final BlockBasicChest cChest = (BlockBasicChest) this.getBlock();
final IChestType myType = cChest.getCustomType(stack);
if (world.getBlockState(posN).getBlock() == this.block && cChest.getCustomType(world, posN) == myType) {
typeCnt += cChest.isDoubleChest(world, posN, myType) ? 2 : 1;
}
if (world.getBlockState(posS).getBlock() == this.block && cChest.getCustomType(world, posS) == myType) {
typeCnt += cChest.isDoubleChest(world, posS, myType) ? 2 : 1;
}
if (world.getBlockState(posW).getBlock() == this.block && cChest.getCustomType(world, posW) == myType) {
typeCnt += cChest.isDoubleChest(world, posW, myType) ? 2 : 1;
}
if (world.getBlockState(posE).getBlock() == this.block && cChest.getCustomType(world, posE) == myType) {
typeCnt += cChest.isDoubleChest(world, posE, myType) ? 2 : 1;
}
if (typeCnt <= 1 && super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) {
final TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityBasicChest) {
((TileEntityBasicChest) te).setType(myType);
return true;
}
}
return false;
}
use of net.darkhax.bookshelf.block.BlockBasicChest in project Bookshelf by Darkhax-Minecraft.
the class ItemBlockChest method getUnlocalizedName.
@Override
public String getUnlocalizedName(ItemStack stack) {
final BlockBasicChest cChest = (BlockBasicChest) this.getBlock();
final IChestType myType = cChest.getCustomType(stack);
return myType != null ? this.block.getUnlocalizedName() + "." + myType.getName() + (cChest.isTrapChest() ? ".trap" : "") : this.block.getUnlocalizedName();
}
Aggregations