Posted July 3, 20178 yr I've make a block that will spawn entity and ride to the player when destroy it, but this seem to not work anymore. Code : @Override public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { if (!world.isRemote) { if (world.rand.nextInt(5) == 0) { EntityJuicer juicer = new EntityJuicer(world); juicer.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.0F, 0.0F); world.spawnEntityInWorld(juicer); } if (world.rand.nextInt(10) == 0) { double radiusPlayer = 5.0D; List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() - radiusPlayer, pos.getY() - radiusPlayer, pos.getZ() - radiusPlayer, pos.getX() + radiusPlayer, pos.getY() + radiusPlayer, pos.getZ() + radiusPlayer)); if (!playerList.isEmpty()) { for (EntityPlayer player : playerList) { EntityJuicer juicer = new EntityJuicer(world); juicer.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.0F, 0.0F); world.spawnEntityInWorld(juicer); juicer.startRiding(player); } } } } } Edited July 4, 20178 yr by lamp3345
August 1, 20178 yr Author When break the block, EntityJuicer will ride to the nearby player. This work perfectly in 1.8.9 but its broken in 1.10.2. Current method that I used. @Override public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state) { EntityPlayer player = world.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 5, false); if (!world.isRemote) { // if (world.rand.nextInt(5) == 0) // { // EntityJuicer juicer = new EntityJuicer(world); // juicer.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.0F, 0.0F); // world.spawnEntityInWorld(juicer); // } //if (world.rand.nextInt(10) == 0) { // double radiusPlayer = 5.0D; // List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() - radiusPlayer, pos.getY() - radiusPlayer, pos.getZ() - radiusPlayer, pos.getX() + radiusPlayer, pos.getY() + radiusPlayer, pos.getZ() + radiusPlayer)); // // if (!playerList.isEmpty()) // { // for (EntityPlayer player : playerList) // { // EntityJuicer juicer = new EntityJuicer(world); // juicer.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.0F, 0.0F); // world.spawnEntityInWorld(juicer); // juicer.startRiding(player, true); // } // } EntityJuicer juicer = new EntityJuicer(world); juicer.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, 0.0F, 0.0F); juicer.startRiding(player, true); world.spawnEntityInWorld(juicer); //juicer.startRiding(player, true); } } }
August 1, 20178 yr Author Fake Juicer spawned when break block at the first time (right). Real Juicer spawned normally when break a second block (left). Edited August 1, 20178 yr by lamp3345
August 1, 20178 yr Author This is Galacticraft entity, not my mod. https://github.com/micdoodle8/Galacticraft/blob/MC1.10/src/main/java/micdoodle8/mods/galacticraft/planets/venus/entities/EntityJuicer.java Edited August 1, 20178 yr by lamp3345
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.