Search in sources :

Example 1 with EntityTakumiAbstractCreeper

use of com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper 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)

Example 2 with EntityTakumiAbstractCreeper

use of com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper in project takumicraft by TNTModders.

the class TakumiASMHooks method TakumiExplodeHook.

public static void TakumiExplodeHook(EntityCreeper creeper) {
    try {
        if (creeper instanceof EntityTakumiAbstractCreeper) {
            int i = ((ITakumiEntity) creeper).getExplosionPower();
            Field field = TakumiASMNameMap.getField(EntityCreeper.class, "explosionRadius");
            field.setAccessible(true);
            field.set(creeper, i);
            ((ITakumiEntity) creeper).takumiExplode();
        }
    } catch (IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityTakumiAbstractCreeper(com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper)

Aggregations

EntityTakumiAbstractCreeper (com.tntmodders.takumi.entity.EntityTakumiAbstractCreeper)2 ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)1 TileEntityDarkBoard (com.tntmodders.takumi.tileentity.TileEntityDarkBoard)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1