use of com.tntmodders.takumi.tileentity.TileEntityDarkBoard in project takumicraft by TNTModders.
the class BlockTakumiDarkBoard method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (worldIn.getTileEntity(pos) instanceof TileEntityDarkBoard) {
if (playerIn.getHeldItem(hand).getItem() instanceof ItemBlock && ((ItemBlock) playerIn.getHeldItem(hand).getItem()).getBlock() instanceof BlockTakumiMonsterBomb && ((BlockTakumiMonsterBomb) ((ItemBlock) playerIn.getHeldItem(hand).getItem()).getBlock()).getName().contains(((TileEntityDarkBoard) worldIn.getTileEntity(pos)).name)) {
worldIn.setBlockState(pos, TakumiBlockCore.DARKBOARD_ON.getDefaultState());
if (playerIn instanceof EntityPlayerMP) {
TakumiUtils.giveAdvancementImpossible((EntityPlayerMP) playerIn, new ResourceLocation(TakumiCraftCore.MODID, "creeperbomb"), new ResourceLocation(TakumiCraftCore.MODID, "darkshrine"));
}
worldIn.createExplosion(playerIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 3f, true);
} else {
worldIn.addBlockEvent(pos, state.getBlock(), 0, 0);
}
}
return true;
}
use of com.tntmodders.takumi.tileentity.TileEntityDarkBoard in project takumicraft by TNTModders.
the class BlockTakumiDarkBoard method onBlockAdded.
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
super.onBlockAdded(worldIn, pos, state);
if (worldIn.getTileEntity(pos) instanceof TileEntityDarkBoard) {
Random random = new Random();
random.setSeed(System.currentTimeMillis() + pos.getX() + pos.getZ());
if (((TileEntityDarkBoard) worldIn.getTileEntity(pos)).name == null || ((TileEntityDarkBoard) worldIn.getTileEntity(pos)).name.isEmpty()) {
Class clazz = ((Class) TakumiBlockCore.BOMB_MAP.keySet().toArray()[random.nextInt(TakumiBlockCore.BOMB_MAP.size())]);
try {
EntityTakumiAbstractCreeper creeper = (EntityTakumiAbstractCreeper) clazz.getConstructor(World.class).newInstance(worldIn);
((TileEntityDarkBoard) worldIn.getTileEntity(pos)).name = creeper.getRegisterName();
} catch (Exception e) {
e.printStackTrace();
}
}
TakumiCraftCore.LOGGER.info(((TileEntityDarkBoard) worldIn.getTileEntity(pos)).name);
}
}
Aggregations