@Override public boolean func_71903_a( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { int i = par1World.getBlockMetadata(par2, par3, par4); if (isFenceGateOpen(i)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, i & -5); } else { int j = (MathHelper.floor_double(((par5EntityPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3) % 4; int k = getDirection(i); if (k == (j + 2) % 4) { i = j; } par1World.setBlockMetadataWithNotify(par2, par3, par4, i | 4); } par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); return true; }
/** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (!par1World.isRemote) { int var6 = par1World.getBlockMetadata(par2, par3, par4); boolean var7 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4); if (var7 || par5 > 0 && Block.blocksList[par5].canProvidePower()) { if (var7 && !isFenceGateOpen(var6)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 | 4, 2); par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); } else if (!var7 && isFenceGateOpen(var6)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 & -5, 2); par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); } } } }
/** Called upon block activation (right click on the block.) */ public boolean onBlockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { int var10 = par1World.getBlockMetadata(par2, par3, par4); if (isFenceGateOpen(var10)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 & -5, 2); } else { int var11 = (MathHelper.floor_double((double) (par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4; int var12 = getDirection(var10); if (var12 == (var11 + 2) % 4) { var10 = var11; } par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 | 4, 2); } par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); return true; }
/** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ @Override public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (par1World.isRemote) { return; } int i = par1World.getBlockMetadata(par2, par3, par4); boolean flag = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4); if (flag || par5 > 0 && Block.blocksList[par5].canProvidePower() || par5 == 0) { if (flag && !isFenceGateOpen(i)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, i | 4); par1World.playAuxSFXAtEntity(null, 1003, par2, par3, par4, 0); } else if (!flag && isFenceGateOpen(i)) { par1World.setBlockMetadataWithNotify(par2, par3, par4, i & -5); par1World.playAuxSFXAtEntity(null, 1003, par2, par3, par4, 0); } } }
/** * Called upon block activation (left or right click on the block.). The three integers represent * x,y,z of the block. */ public boolean blockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (blockMaterial == Material.iron) { return true; } else { int i = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, i ^ 4); par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); return true; } }
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) { int i = par1World.getBlockMetadata(par2, par3, par4); boolean flag = (i & 4) > 0; if (flag == par5) { return; } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, i ^ 4); par1World.playAuxSFXAtEntity(null, 1003, par2, par3, par4, 0); return; } }
/** A function to open a door. */ public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) { int var6 = this.getFullMetadata(par1World, par2, par3, par4); boolean var7 = (var6 & 4) != 0; if (var7 != par5) { int var8 = var6 & 7; var8 ^= 4; if ((var6 & 8) != 0) { par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8); par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4); } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, var8); par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4); } par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); } }
/** * Called upon block activation (left or right click on the block.). The three integers represent * x,y,z of the block. */ public boolean blockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (this.blockMaterial == Material.iron) { return false; } else { int var6 = this.getFullMetadata(par1World, par2, par3, par4); int var7 = var6 & 7; var7 ^= 4; if ((var6 & 8) != 0) { par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var7); par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4); } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, var7); par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4); } par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); return true; } }
/** A function to open a door. */ public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) { int i = getFullMetadata(par1World, par2, par3, par4); boolean flag = (i & 4) != 0; if (flag == par5) { return; } int j = i & 7; j ^= 4; if ((i & 8) != 0) { par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, j); par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4); } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, j); par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4); } par1World.playAuxSFXAtEntity(null, 1003, par2, par3, par4, 0); }
/** * Called upon block activation (left or right click on the block.). The three integers represent * x,y,z of the block. */ public boolean blockActivated( World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (blockMaterial == Material.iron) { return true; } int i = getFullMetadata(par1World, par2, par3, par4); int j = i & 7; j ^= 4; if ((i & 8) != 0) { par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, j); par1World.markBlocksDirty(par2, par3 - 1, par4, par2, par3, par4); } else { par1World.setBlockMetadataWithNotify(par2, par3, par4, j); par1World.markBlocksDirty(par2, par3, par4, par2, par3, par4); } par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0); return true; }