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 am trying to make an item that checks to see if there is water(still water) in front of the player and place an ice carpet so the player can "walk" on water. Only thing is I'm having trouble with making this carpet.

 

Here is the code so far

 

	public void onUpdate(ItemStack par1ItemStack, World worldObj, Entity player, int par4, boolean par5)
    {
        if (player instanceof EntityPlayer)
        {
            EntityPlayer thePlayer = (EntityPlayer)player;
            worldObj.playerEntities.add(thePlayer);
            worldObj.updateAllPlayersSleepingFlag();
            if(worldObj.getBlockId((int) thePlayer.posX + 1, (int) thePlayer.posY - 2, (int) thePlayer.posZ + 1) == Block.waterStill.blockID)
            {
            	worldObj.setBlockWithNotify((int) thePlayer.posX - 1, (int) thePlayer.posY - 2, (int) thePlayer.posZ - 1, Block.ice.blockID);
            	worldObj.setBlockWithNotify((int) thePlayer.posX, (int) thePlayer.posY - 2, (int) thePlayer.posZ, Block.ice.blockID);
            	worldObj.setBlockWithNotify((int) thePlayer.posX - 2, (int) thePlayer.posY - 2, (int) thePlayer.posZ - 2, Block.ice.blockID);
            	worldObj.setBlockWithNotify((int) thePlayer.posX + 1, (int) thePlayer.posY - 2, (int) thePlayer.posZ + 1, Block.ice.blockID);
            	worldObj.setBlockWithNotify((int) thePlayer.posX + 2, (int) thePlayer.posY - 2, (int) thePlayer.posZ + 2, Block.ice.blockID);
            }
        }
    }

 

Obviously the carpet isn't anywhere near good.

the Ice isn't being placed properly near the player. I've been messing around with it for about an hour now and was wondering if there was a specific set of coordinates I could use rather than trial and error over and over again. Thanks in advance!

  • Author

Well just because I've seen setBlockWithNotify more often to be honest. Would setBlock be easier to work with in this case then?

Your not compensating for the rotation of the player; this will always place it in a specific corner instead of where the player happens to be looking when he/she right clicks. I would post code but it's getting late, but I reccomend you to find a way to convert the rotation of the player into proper coordinates.

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.