@Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) { world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2); EntityBlaze blaze = new EntityBlaze(world); blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F); blaze.deathLootTable = LOOT_TABLE; blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null); world.spawnEntity(blaze); world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false); } }
@SubtargetedModuleMethod.Inject( module = PlethoraModules.KINETIC_S, target = EntityBlaze.class, name = "shoot", doc = "function(yaw:number, pitch:number) -- Fire a fireball in the specified direction." ) @Nonnull public static MethodResult shootBlaze(@Nonnull final IUnbakedContext<IModuleContainer> unbaked, @Nonnull final Object[] args) throws LuaException { final double yaw = getReal(args, 0) % 360; double pitch = getReal(args, 1) % 360; final double motionX = -Math.sin(yaw / 180.0f * (float) Math.PI) * Math.cos(pitch / 180.0f * (float) Math.PI); final double motionZ = Math.cos(yaw / 180.0f * (float) Math.PI) * Math.cos(pitch / 180.0f * (float) Math.PI); final double motionY = -Math.sin(pitch / 180.0f * (float) Math.PI); return unbaked.getCostHandler().await(Kinetic.shootCost, MethodResult.nextTick(() -> { IContext<IModuleContainer> context = unbaked.bake(); EntityBlaze blaze = context.getContext(ContextKeys.ORIGIN, EntityBlaze.class); World world = blaze.getEntityWorld(); world.playEvent(null, 1018, new BlockPos((int) blaze.posX, (int) blaze.posY, (int) blaze.posZ), 0); // ENTITY_BLAZE_SHOOT EntitySmallFireball fireball = new EntitySmallFireball(world, blaze, motionX, motionY, motionZ); fireball.posY = blaze.posY + (blaze.height / 2.0F) + 0.5D; world.spawnEntity(fireball); return MethodResult.empty(); })); }
@SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { if(restrictToNetherrack && !event.isSpawner() && event.getEntityLiving() instanceof EntityBlaze && event.getResult() != Result.DENY && event.getEntityLiving().world instanceof WorldServer) { EntityBlaze blaze = (EntityBlaze) event.getEntityLiving(); WorldServer world = (WorldServer) blaze.world; BlockPos pos = blaze.getPosition(); Block block = world.getBlockState(pos.down()).getBlock(); ResourceLocation res = block.getRegistryName(); if(res != null) { boolean allowedBlock = allowedBlocks.contains(res.toString()); boolean fortress = world.getChunkProvider().isInsideStructure(world, "Fortress", pos); if(!fortress && !allowedBlock) event.setResult(Result.DENY); } } }