Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by lamp3345

  • 4 weeks later...
  • 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);
            }
        }
    }

 

  • Author

Fake Juicer spawned when break block at the first time (right).

Real Juicer spawned normally when break a second block (left).

MsQfqqp.png

Edited 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.