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

So I've got some simple code that should spawn in a zombie in the onBlockActivated method of my block, but it doesn't seem to be doing anything, even though I could spawn in item entities just fine.

 

                EntityZombie mobEntity = new EntityZombie(world);
                mobEntity.setPosition(pos.getX(), pos.getZ(), pos.getZ());
                world.spawnEntity(mobEntity);

 

Also, if someone could tell me how to properly post code, that would be great.

Edited by MrDireball

  • Author
5 hours ago, diesieben07 said:

Show more of your code.

 

You can do the following to post code (ordered from best to "worst"):

  1. Create a Git repository of your code.
  2. Use Github Gists.
  3. Use pastebin.com or similar.
  4. Use the Code-Button on the forum editor (opening and closing angle bracket icon).
    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
                EnumFacing side, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
            if (side == state.getValue(FACING)) {
                //world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.DIAMOND)));
                                                                                       
    		    EntityZombie mobEntity = new EntityZombie(world);
    		    mobEntity.setPosition(pos.getX(), pos.getZ(), pos.getZ());
    		    world.spawnEntity(mobEntity);
            }
        }
        return true;
    }

 

  • Author

Idiot me. If you look closely at line 9, you'll see that I accidentally set y to z, hence why they were falling from the sky just now, and presumably being teleported under the world before.

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.