Search in sources :

Example 1 with TileEntityDarkBoard

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;
}
Also used : TileEntityDarkBoard(com.tntmodders.takumi.tileentity.TileEntityDarkBoard) ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemBlock(net.minecraft.item.ItemBlock)

Example 2 with TileEntityDarkBoard

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);
    }
}
Also used : Random(java.util.Random) TileEntityDarkBoard(com.tntmodders.takumi.tileentity.TileEntityDarkBoard) InvocationTargetException(java.lang.reflect.InvocationTargetException) EntityTakumiAbstractCreeper(com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper)

Aggregations

TileEntityDarkBoard (com.tntmodders.takumi.tileentity.TileEntityDarkBoard)2 EntityTakumiAbstractCreeper (com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemBlock (net.minecraft.item.ItemBlock)1 ResourceLocation (net.minecraft.util.ResourceLocation)1