Posted October 12, 20169 yr hello guys, i got a small problem, i cannot find a small solution for "setBlock" ... and for int x = par1MovingObjectPosition.blockX; int y = par1MovingObjectPosition.blockY; int z = par1MovingObjectPosition.blockZ; also not ... x.x public class IceBall extends EntityThrowable { public IceBall(World par1World) { super(par1World); } public IceBall(World par1World, EntityPlayer par3EntityPlayer) { super(par1World, par3EntityPlayer); } public IceBall(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } public int ticks = 20; public void onEntityUpdate() { if (this.ticks <= 0) { this.ticks = 20; setDead(); } else { this.ticks -= 1; } } protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { double x = 0.0D; double y = 0.0D; double z = 0.0D; EntityLivingBase living = (EntityLivingBase)par1MovingObjectPosition.entityHit; living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 300, 3000)); x = par1MovingObjectPosition.entityHit.posX; y = par1MovingObjectPosition.entityHit.posY; z = par1MovingObjectPosition.entityHit.posZ; this.worldObj.setBlock((int)x, (int)y + 2, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y + 2, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y + 2, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y + 2, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y + 2, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y + 2, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y + 2, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y + 2, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y + 2, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y + 1, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y + 1, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y, (int)z, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y + 1, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y + 1, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x, (int)y, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y + 1, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y + 1, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y + 1, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y + 1, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y + 1, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y, (int)z + 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y + 1, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y, (int)z - 1, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y + 1, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 1, (int)y, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y + 1, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 1, (int)y, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y + 1, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y + 1, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y, (int)z + 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y + 1, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x + 2, (int)y, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y + 1, (int)z - 2, Blocks.packed_ice); this.worldObj.setBlock((int)x - 2, (int)y, (int)z - 2, Blocks.packed_ice); par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 5.0F); } if (!this.worldObj.isRemote) { int x = par1MovingObjectPosition.blockX; int y = par1MovingObjectPosition.blockY; int z = par1MovingObjectPosition.blockZ; this.worldObj.setBlock(x, y + 2, z, Blocks.packed_ice); this.worldObj.setBlock(x, y + 2, z, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y + 2, z, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y + 2, z, Blocks.packed_ice); this.worldObj.setBlock(x, y + 2, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x, y + 2, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y + 2, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y + 2, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y + 2, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y + 2, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y + 1, z, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y, z, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y + 1, z, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y, z, Blocks.packed_ice); this.worldObj.setBlock(x, y + 1, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x, y, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x, y + 1, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x, y, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y + 1, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y + 1, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y + 1, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y + 1, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y + 1, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y, z + 1, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y + 1, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y, z - 1, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y + 1, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x - 1, y, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y + 1, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x + 1, y, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y + 1, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y + 1, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y, z + 2, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y + 1, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x + 2, y, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y + 1, z - 2, Blocks.packed_ice); this.worldObj.setBlock(x - 2, y, z - 2, Blocks.packed_ice); setDead(); } } }
October 12, 20169 yr That's because setBlock(x, y, z, block) is now setBlockState(BlockPos, IBlockState) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 12, 20169 yr Individual x/y/z block coordinates have been replaced by BlockPos objects. Block and metadata arguments have been replaced by IBlockState arguments. Use World#setBlockState to set a block in the world. Use Block#getDefaultState to get the default IBlockState of a Block and then chain IBlockState#withProperty calls to get an IBlockState with each IProperty set to the appropriate value. Use MovingObjectPosition#getBlockPos to get the BlockPos that was hit by the raytrace. Forge's documentation has an introduction to block states here. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.