dee12452 Posted January 27, 2013 Posted January 27, 2013 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! Quote
thebest108 Posted January 27, 2013 Posted January 27, 2013 Why not world.setBlock() ? Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
dee12452 Posted January 27, 2013 Author Posted January 27, 2013 Well just because I've seen setBlockWithNotify more often to be honest. Would setBlock be easier to work with in this case then? Quote
Groxkiller Posted January 30, 2013 Posted January 30, 2013 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. Quote
Recommended Posts
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.