public static TileEntity getTileEntity(IBlockAccess blockaccess, int x, int y, int z) { HashSet<ChunkCoordinates> visited = Sets.newHashSet(); Block block = blockaccess.getBlock(x, y, z); while (block != NailedBlocks.portalController) { if (isValidLinkPortalBlock(block) == 0) { return null; } ChunkCoordinates pos = new ChunkCoordinates(x, y, z); if (!visited.add(pos)) { return null; } int meta = blockaccess.getBlockMetadata(x, y, z); if (meta == 0) { return null; } if (meta == 1) { y--; } else if (meta == 2) { y++; } else if (meta == 3) { z--; } else if (meta == 4) { z++; } else if (meta == 5) { x--; } else if (meta == 6) { x++; } else { return null; } block = blockaccess.getBlock(x, y, z); } return blockaccess.getTileEntity(x, y, z); }
private boolean RenderMachineInWorld( RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block) { if (world.getBlockMetadata(x, y, z) < 4) { block.setBlockBounds(0.0F, 0.0F, 0.0F, 1F, 1F, 1F); renderer.renderStandardBlock(block, x, y, z); } else if (world.getBlockMetadata(x, y, z) == 4) { block.setBlockBounds(0, 0, 0, 1, 0.5f, 1); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.25f, 0.5f, 0.25f, 0.75f, 0.625f, 0.75f); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.625f, 0.625f, 0.625f, 0.375f, 1, 0.375f); renderer.renderStandardBlock(block, x, y, z); } else if (world.getBlockMetadata(x, y, z) == 5) { block.setBlockBounds(0, 0, 0, 1, 0.125f, 1); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.625f, .125f, 0.625f, 0.375f, 0.375f, 0.375f); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0, 0.375f, 0, 1, 0.5f, 1); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0, 0.5f, 0.875f, 1, 0.875f, 1); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0, 0.5f, 0, 1, 0.875f, 0.125f); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0, 0.5f, 0.875f, 1, 0.875f, 1); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0, 0.5f, 0.125f, 0.125f, 0.875f, 0.875f); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.875f, 0.5f, 0.125f, 1, 0.875f, 0.875f); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.375f, 0.5f, 0.375f, 0.625f, 1, 0.625f); renderer.renderStandardBlock(block, x, y, z); } return true; }
private boolean RenderWarheadInWorld( RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block) { if (world.getBlockMetadata(x, y, z) != 12 && world.getBlockMetadata(x, y, z) != 0 && world.getBlockMetadata(x, y, z) != 15) { block.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.7F, .9F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.2F, 0.7F, 0.2F, 0.8F, 0.9F, 0.8F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.3F, 0.9F, 0.3F, 0.7F, 1F, 0.7F); renderer.renderStandardBlock(block, x, y, z); } else { block.setBlockBounds(0.0F, 0.0F, 0F, 1F, 0.1F, 1F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0F, 0.1F, 0F, 1F, 1F, .1F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0F, 0.1F, 0.9F, 1F, 1F, 1F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0F, 0.1F, 0.1F, 0.1F, 1F, 0.9F); renderer.renderStandardBlock(block, x, y, z); block.setBlockBounds(0.9F, 0.1F, 0.1F, 1F, 1F, .9F); renderer.renderStandardBlock(block, x, y, z); } block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); return true; }
public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) { if (!wiresProvidePower) { return false; } if (iblockaccess.getBlockMetadata(i, j, k) == 0) { return false; } if (l == 1) { return true; } boolean flag = isPowerProviderOrWire(iblockaccess, i - 1, j, k) || !iblockaccess.isBlockOpaqueCube(i - 1, j, k) && isPowerProviderOrWire(iblockaccess, i - 1, j - 1, k); boolean flag1 = isPowerProviderOrWire(iblockaccess, i + 1, j, k) || !iblockaccess.isBlockOpaqueCube(i + 1, j, k) && isPowerProviderOrWire(iblockaccess, i + 1, j - 1, k); boolean flag2 = isPowerProviderOrWire(iblockaccess, i, j, k - 1) || !iblockaccess.isBlockOpaqueCube(i, j, k - 1) && isPowerProviderOrWire(iblockaccess, i, j - 1, k - 1); boolean flag3 = isPowerProviderOrWire(iblockaccess, i, j, k + 1) || !iblockaccess.isBlockOpaqueCube(i, j, k + 1) && isPowerProviderOrWire(iblockaccess, i, j - 1, k + 1); if (!iblockaccess.isBlockOpaqueCube(i, j + 1, k)) { if (iblockaccess.isBlockOpaqueCube(i - 1, j, k) && isPowerProviderOrWire(iblockaccess, i - 1, j + 1, k)) { flag = true; } if (iblockaccess.isBlockOpaqueCube(i + 1, j, k) && isPowerProviderOrWire(iblockaccess, i + 1, j + 1, k)) { flag1 = true; } if (iblockaccess.isBlockOpaqueCube(i, j, k - 1) && isPowerProviderOrWire(iblockaccess, i, j + 1, k - 1)) { flag2 = true; } if (iblockaccess.isBlockOpaqueCube(i, j, k + 1) && isPowerProviderOrWire(iblockaccess, i, j + 1, k + 1)) { flag3 = true; } } if (!flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5) { return true; } if (l == 2 && flag2 && !flag && !flag1) { return true; } if (l == 3 && flag3 && !flag && !flag1) { return true; } if (l == 4 && flag && !flag2 && !flag3) { return true; } return l == 5 && flag1 && !flag2 && !flag3; }
@Override public void setBlockBoundsBasedOnState( IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { int i = par1IBlockAccess.getBlockMetadata(par2, par3, par4); float f = 0.375F; setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.375F); if (i == 0) { setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F); } if (i == 1) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); } if (i == 2) { setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); } if (i == 3) { setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); } if (i == 4) { setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } if (i == 5) { setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); } }
public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) { int meta = iblockaccess.getBlockMetadata(i, j, k); if (!globalToLocal.containsKey(l)) return false; if (globalToLocal.get(l) == getPositionMetadata(meta)) return getInternalPowerState(meta); return false; }
public static boolean isPowerProviderOrWire(IBlockAccess iblockaccess, int i, int j, int k) { int l = iblockaccess.getBlockId(i, j, k); if (l == Block.redstoneWire.blockID) { return true; } if (l == 0) { return false; } return Block.blocksList[l].canProvidePower(); }
public static boolean renderBlockRedstoneWire( RenderBlocks r, IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, Icon override) { Tessellator tessellator = Tessellator.instance; int i = blockAccess.getBlockMetadata(par2, par3, par4); Icon icon = BlockRedstoneWire.func_94409_b("cross"); Icon icon1 = BlockRedstoneWire.func_94409_b("line"); Icon icon2 = BlockRedstoneWire.func_94409_b("cross_overlay"); Icon icon3 = BlockRedstoneWire.func_94409_b("line_overlay"); if (!Minecraft.oldlighting) { tessellator.setBrightness( par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4)); } float f = Minecraft.oldlighting ? par1Block.getBlockBrightness(blockAccess, par2, par3, par4) : 1.0F; float f1 = (float) i / 15F; float f2 = f1 * 0.6F + 0.4F; if (i == 0) { f2 = 0.3F; } float f3 = f1 * f1 * 0.7F - 0.5F; float f4 = f1 * f1 * 0.6F - 0.7F; if (f3 < 0.0F) { f3 = 0.0F; } if (f4 < 0.0F) { f4 = 0.0F; } tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); boolean flag = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2 - 1, par3, par4, 1) || !blockAccess.isBlockNormalCube(par2 - 1, par3, par4) && BlockRedstoneWire.isPowerProviderOrWire( blockAccess, par2 - 1, par3 - 1, par4, -1); boolean flag1 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2 + 1, par3, par4, 3) || !blockAccess.isBlockNormalCube(par2 + 1, par3, par4) && BlockRedstoneWire.isPowerProviderOrWire( blockAccess, par2 + 1, par3 - 1, par4, -1); boolean flag2 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2, par3, par4 - 1, 2) || !blockAccess.isBlockNormalCube(par2, par3, par4 - 1) && BlockRedstoneWire.isPowerProviderOrWire( blockAccess, par2, par3 - 1, par4 - 1, -1); boolean flag3 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2, par3, par4 + 1, 0) || !blockAccess.isBlockNormalCube(par2, par3, par4 + 1) && BlockRedstoneWire.isPowerProviderOrWire( blockAccess, par2, par3 - 1, par4 + 1, -1); if (!blockAccess.isBlockNormalCube(par2, par3 + 1, par4)) { if (blockAccess.isBlockNormalCube(par2 - 1, par3, par4) && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2 - 1, par3 + 1, par4, -1)) { flag = true; } if (blockAccess.isBlockNormalCube(par2 + 1, par3, par4) && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2 + 1, par3 + 1, par4, -1)) { flag1 = true; } if (blockAccess.isBlockNormalCube(par2, par3, par4 - 1) && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2, par3 + 1, par4 - 1, -1)) { flag2 = true; } if (blockAccess.isBlockNormalCube(par2, par3, par4 + 1) && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, par2, par3 + 1, par4 + 1, -1)) { flag3 = true; } } float f5 = par2 + 0; float f6 = par2 + 1; float f7 = par4 + 0; float f8 = par4 + 1; byte byte0 = 0; if ((flag || flag1) && !flag2 && !flag3) { byte0 = 1; } if ((flag2 || flag3) && !flag1 && !flag) { byte0 = 2; } if (byte0 == 0) { int j = 0; int k = 0; int l = 16; int i1 = 16; if (flag1 || flag2 || flag3 || flag) { if (!flag) { f5 += 0.3125F; } if (!flag) { j += 5; } if (!flag1) { f6 -= 0.3125F; } if (!flag1) { l -= 5; } if (!flag2) { f7 += 0.3125F; } if (!flag2) { k += 5; } if (!flag3) { f8 -= 0.3125F; } if (!flag3) { i1 -= 5; } } tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon.getInterpolatedU(l), icon.getInterpolatedV(i1)); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon.getInterpolatedU(l), icon.getInterpolatedV(k)); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon.getInterpolatedU(j), icon.getInterpolatedV(k)); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon.getInterpolatedU(j), icon.getInterpolatedV(i1)); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon2.getInterpolatedU(l), icon2.getInterpolatedV(i1)); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon2.getInterpolatedU(l), icon2.getInterpolatedV(k)); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon2.getInterpolatedU(j), icon2.getInterpolatedV(k)); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon2.getInterpolatedU(j), icon2.getInterpolatedV(i1)); } else if (byte0 == 1) { tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon1.getMaxU(), icon1.getMaxV()); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon1.getMaxU(), icon1.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon1.getMinU(), icon1.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon1.getMinU(), icon1.getMaxV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon3.getMaxU(), icon3.getMaxV()); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon3.getMaxU(), icon3.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon3.getMinU(), icon3.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon3.getMinU(), icon3.getMaxV()); } else { tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon1.getMaxU(), icon1.getMaxV()); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon1.getMinU(), icon1.getMaxV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon1.getMinU(), icon1.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon1.getMaxU(), icon1.getMinV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f8, icon3.getMaxU(), icon3.getMaxV()); tessellator.addVertexWithUV( f6, (double) par3 + 0.015625D, f7, icon3.getMinU(), icon3.getMaxV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f7, icon3.getMinU(), icon3.getMinV()); tessellator.addVertexWithUV( f5, (double) par3 + 0.015625D, f8, icon3.getMaxU(), icon3.getMinV()); } if (!blockAccess.isBlockNormalCube(par2, par3 + 1, par4)) { if (blockAccess.isBlockNormalCube(par2 - 1, par3, par4) && blockAccess.getBlockId(par2 - 1, par3 + 1, par4) == Block.redstoneWire.blockID) { tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); tessellator.addVertexWithUV( (double) par2 + 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 1, icon1.getMaxU(), icon1.getMinV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, par3 + 0, par4 + 1, icon1.getMinU(), icon1.getMinV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, par3 + 0, par4 + 0, icon1.getMinU(), icon1.getMaxV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 0, icon1.getMaxU(), icon1.getMaxV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( (double) par2 + 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 1, icon3.getMaxU(), icon3.getMinV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, par3 + 0, par4 + 1, icon3.getMinU(), icon3.getMinV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, par3 + 0, par4 + 0, icon3.getMinU(), icon3.getMaxV()); tessellator.addVertexWithUV( (double) par2 + 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 0, icon3.getMaxU(), icon3.getMaxV()); } if (blockAccess.isBlockNormalCube(par2 + 1, par3, par4) && blockAccess.getBlockId(par2 + 1, par3 + 1, par4) == Block.redstoneWire.blockID) { tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, par3 + 0, par4 + 1, icon1.getMinU(), icon1.getMaxV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 1, icon1.getMaxU(), icon1.getMaxV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 0, icon1.getMaxU(), icon1.getMinV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, par3 + 0, par4 + 0, icon1.getMinU(), icon1.getMinV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, par3 + 0, par4 + 1, icon3.getMinU(), icon3.getMaxV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 1, icon3.getMaxU(), icon3.getMaxV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, (float) (par3 + 1) + 0.021875F, par4 + 0, icon3.getMaxU(), icon3.getMinV()); tessellator.addVertexWithUV( (double) (par2 + 1) - 0.015625D, par3 + 0, par4 + 0, icon3.getMinU(), icon3.getMinV()); } if (blockAccess.isBlockNormalCube(par2, par3, par4 - 1) && blockAccess.getBlockId(par2, par3 + 1, par4 - 1) == Block.redstoneWire.blockID) { tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); tessellator.addVertexWithUV( par2 + 1, par3 + 0, (double) par4 + 0.015625D, icon1.getMinU(), icon1.getMaxV()); tessellator.addVertexWithUV( par2 + 1, (float) (par3 + 1) + 0.021875F, (double) par4 + 0.015625D, icon1.getMaxU(), icon1.getMaxV()); tessellator.addVertexWithUV( par2 + 0, (float) (par3 + 1) + 0.021875F, (double) par4 + 0.015625D, icon1.getMaxU(), icon1.getMinV()); tessellator.addVertexWithUV( par2 + 0, par3 + 0, (double) par4 + 0.015625D, icon1.getMinU(), icon1.getMinV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( par2 + 1, par3 + 0, (double) par4 + 0.015625D, icon3.getMinU(), icon3.getMaxV()); tessellator.addVertexWithUV( par2 + 1, (float) (par3 + 1) + 0.021875F, (double) par4 + 0.015625D, icon3.getMaxU(), icon3.getMaxV()); tessellator.addVertexWithUV( par2 + 0, (float) (par3 + 1) + 0.021875F, (double) par4 + 0.015625D, icon3.getMaxU(), icon3.getMinV()); tessellator.addVertexWithUV( par2 + 0, par3 + 0, (double) par4 + 0.015625D, icon3.getMinU(), icon3.getMinV()); } if (blockAccess.isBlockNormalCube(par2, par3, par4 + 1) && blockAccess.getBlockId(par2, par3 + 1, par4 + 1) == Block.redstoneWire.blockID) { tessellator.setColorOpaque_F(f * f2, f * f3, f * f4); tessellator.addVertexWithUV( par2 + 1, (float) (par3 + 1) + 0.021875F, (double) (par4 + 1) - 0.015625D, icon1.getMaxU(), icon1.getMinV()); tessellator.addVertexWithUV( par2 + 1, par3 + 0, (double) (par4 + 1) - 0.015625D, icon1.getMinU(), icon1.getMinV()); tessellator.addVertexWithUV( par2 + 0, par3 + 0, (double) (par4 + 1) - 0.015625D, icon1.getMinU(), icon1.getMaxV()); tessellator.addVertexWithUV( par2 + 0, (float) (par3 + 1) + 0.021875F, (double) (par4 + 1) - 0.015625D, icon1.getMaxU(), icon1.getMaxV()); tessellator.setColorOpaque_F(f, f, f); tessellator.addVertexWithUV( par2 + 1, (float) (par3 + 1) + 0.021875F, (double) (par4 + 1) - 0.015625D, icon3.getMaxU(), icon3.getMinV()); tessellator.addVertexWithUV( par2 + 1, par3 + 0, (double) (par4 + 1) - 0.015625D, icon3.getMinU(), icon3.getMinV()); tessellator.addVertexWithUV( par2 + 0, par3 + 0, (double) (par4 + 1) - 0.015625D, icon3.getMinU(), icon3.getMaxV()); tessellator.addVertexWithUV( par2 + 0, (float) (par3 + 1) + 0.021875F, (double) (par4 + 1) - 0.015625D, icon3.getMaxU(), icon3.getMaxV()); } } return true; }