Jump to content

Recommended Posts

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!

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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