void extrudeBlock(Coord at, int extrusions) { // Lamer alternative: at.set(toSpawn, true); IBlockState pistonState = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, EnumFacing.UP); IBlockState toSpawn = toExtrude(extrusions); at.set(pistonState, true); at.setTE(BlockPistonMoving.newTileEntity(toSpawn, EnumFacing.UP, true /* extending */, true /* renderHead */)); Sound.extruderExtrude.playAt(at); if (!at.w.isRemote) { at.w.addBlockEvent(at.toBlockPos().down(), this, extrusions, 0); } }
private static void registerVanillaVariantProps() { // TODO: omit similar blocks registerVariantProperty(BlockStone.VARIANT); registerVariantProperty(BlockPlanks.VARIANT); registerVariantProperty(BlockSapling.TYPE); registerVariantProperty(BlockDirt.VARIANT); registerVariantProperty(BlockSand.VARIANT); registerVariantProperty(BlockOldLog.VARIANT); registerVariantProperty(BlockNewLog.VARIANT); registerVariantProperty(BlockOldLeaf.VARIANT); registerVariantProperty(BlockNewLeaf.VARIANT); registerVariantProperty(BlockSandStone.TYPE); registerVariantProperty(BlockTallGrass.TYPE); registerVariantProperty(BlockPistonExtension.TYPE); registerVariantProperty(BlockColored.COLOR); registerVariantProperty(BlockPistonMoving.TYPE); registerVariantProperty(Blocks.YELLOW_FLOWER.getTypeProperty()); registerVariantProperty(Blocks.RED_FLOWER.getTypeProperty()); registerVariantProperty(BlockStoneSlab.VARIANT); registerVariantProperty(BlockWoodSlab.VARIANT); registerVariantProperty(BlockAnvil.DAMAGE); registerVariantProperty(BlockQuartz.VARIANT); registerVariantProperty(BlockCarpet.COLOR); registerVariantProperty(BlockDoublePlant.VARIANT); registerVariantProperty(BlockStainedGlass.COLOR); registerVariantProperty(BlockStainedGlassPane.COLOR); registerVariantProperty(BlockPrismarine.VARIANT); registerVariantProperty(BlockRedSandstone.TYPE); registerVariantProperty(BlockStoneSlabNew.VARIANT); }
public boolean tryExtend(World w, int x, int y, int z, int direction, boolean simulate) { Chunk c0 = ChunkCache.getChunk(w, x >> 4, z >> 4, true); int meta = c0.getBlockMetadata(x & 15, y, z & 15); if (isExtended(meta)) return false; //System.out.println("Extending: " + Util.xyzString(x, y, z)); int dx = Facing.offsetsXForSide[direction]; int dy = Facing.offsetsYForSide[direction]; int dz = Facing.offsetsZForSide[direction]; /** The number of blocks that will be pushed */ int steps; for (steps = 0; steps < 256; steps++) { int x2 = x + dx * (steps + 1); int y2 = y + dy * (steps + 1); int z2 = z + dz * (steps + 1); if (y2 < 0 || y2 > 255) continue; Chunk c = ChunkCache.getChunk(w, x2 >> 4, z2 >> 4, true); int id = c.getBlockID(x2 & 15, y2, z2 & 15); if (id == 0 || Fluids.isLiquid[id] || Gases.isGas[id]) break; } if (steps == 256) return false; if (simulate) return true; /* Now, start shifting the blocks to the end */ int step2; for (step2 = steps; step2 > 0; step2--) { int xD = x + dx * (step2 + 1); int yD = y + dy * (step2 + 1); int zD = z + dz * (step2 + 1); int xS = x + dx * step2; int yS = y + dy * step2; int zS = z + dz * step2; if (yD < 0 || yD > 255) return true; FysiksFun.moveBlock(w, xD, yD, zD, xS, yS, zS, true, false); } int x1 = x + dx; int y1 = y + dy; int z1 = z + dz; Chunk c1 = ChunkCache.getChunk(w, x1 >> 4, z1 >> 4, true); c1.setBlockIDWithMetadata(x1 & 15, y1, z1 & 15, Block.pistonMoving.blockID, direction | (isSticky ? 8 : 0)); ChunkMarkUpdater.scheduleBlockMark(w, x1, y1, z1, -1, -1); // w.setBlock(x1, y1, z1, Block.pistonMoving.blockID, direction | (isSticky // ? 8 : 0), 4); w.setBlockTileEntity(x1, y1, z1, BlockPistonMoving.getTileEntity(Block.pistonExtension.blockID, direction | (isSticky ? 8 : 0), direction, true, true)); return true; }
public boolean func_71883_b(World p_71883_1_, int p_71883_2_, int p_71883_3_, int p_71883_4_, int p_71883_5_, int p_71883_6_) { if(!p_71883_1_.field_72995_K) { boolean var7 = this.func_72113_e(p_71883_1_, p_71883_2_, p_71883_3_, p_71883_4_, p_71883_6_); if(var7 && p_71883_5_ == 1) { p_71883_1_.func_72921_c(p_71883_2_, p_71883_3_, p_71883_4_, p_71883_6_ | 8, 2); return false; } if(!var7 && p_71883_5_ == 0) { return false; } } if(p_71883_5_ == 0) { if(!this.func_72115_j(p_71883_1_, p_71883_2_, p_71883_3_, p_71883_4_, p_71883_6_)) { return false; } p_71883_1_.func_72921_c(p_71883_2_, p_71883_3_, p_71883_4_, p_71883_6_ | 8, 2); p_71883_1_.func_72908_a((double)p_71883_2_ + 0.5D, (double)p_71883_3_ + 0.5D, (double)p_71883_4_ + 0.5D, "tile.piston.out", 0.5F, p_71883_1_.field_73012_v.nextFloat() * 0.25F + 0.6F); } else if(p_71883_5_ == 1) { TileEntity var16 = p_71883_1_.func_72796_p(p_71883_2_ + Facing.field_71586_b[p_71883_6_], p_71883_3_ + Facing.field_71587_c[p_71883_6_], p_71883_4_ + Facing.field_71585_d[p_71883_6_]); if(var16 instanceof TileEntityPiston) { ((TileEntityPiston)var16).func_70339_i(); } p_71883_1_.func_72832_d(p_71883_2_, p_71883_3_, p_71883_4_, Block.field_72095_ac.field_71990_ca, p_71883_6_, 3); p_71883_1_.func_72837_a(p_71883_2_, p_71883_3_, p_71883_4_, BlockPistonMoving.func_72297_a(this.field_71990_ca, p_71883_6_, p_71883_6_, false, true)); if(this.field_72119_a) { int var8 = p_71883_2_ + Facing.field_71586_b[p_71883_6_] * 2; int var9 = p_71883_3_ + Facing.field_71587_c[p_71883_6_] * 2; int var10 = p_71883_4_ + Facing.field_71585_d[p_71883_6_] * 2; int var11 = p_71883_1_.func_72798_a(var8, var9, var10); int var12 = p_71883_1_.func_72805_g(var8, var9, var10); boolean var13 = false; if(var11 == Block.field_72095_ac.field_71990_ca) { TileEntity var14 = p_71883_1_.func_72796_p(var8, var9, var10); if(var14 instanceof TileEntityPiston) { TileEntityPiston var15 = (TileEntityPiston)var14; if(var15.func_70336_c() == p_71883_6_ && var15.func_70341_b()) { var15.func_70339_i(); var11 = var15.func_70340_a(); var12 = var15.func_70322_n(); var13 = true; } } } if(!var13 && var11 > 0 && func_72111_a(var11, p_71883_1_, var8, var9, var10, false) && (Block.field_71973_m[var11].func_71915_e() == 0 || var11 == Block.field_71963_Z.field_71990_ca || var11 == Block.field_71956_V.field_71990_ca)) { p_71883_2_ += Facing.field_71586_b[p_71883_6_]; p_71883_3_ += Facing.field_71587_c[p_71883_6_]; p_71883_4_ += Facing.field_71585_d[p_71883_6_]; p_71883_1_.func_72832_d(p_71883_2_, p_71883_3_, p_71883_4_, Block.field_72095_ac.field_71990_ca, var12, 3); p_71883_1_.func_72837_a(p_71883_2_, p_71883_3_, p_71883_4_, BlockPistonMoving.func_72297_a(var11, var12, p_71883_6_, false, false)); p_71883_1_.func_94571_i(var8, var9, var10); } else if(!var13) { p_71883_1_.func_94571_i(p_71883_2_ + Facing.field_71586_b[p_71883_6_], p_71883_3_ + Facing.field_71587_c[p_71883_6_], p_71883_4_ + Facing.field_71585_d[p_71883_6_]); } } else { p_71883_1_.func_94571_i(p_71883_2_ + Facing.field_71586_b[p_71883_6_], p_71883_3_ + Facing.field_71587_c[p_71883_6_], p_71883_4_ + Facing.field_71585_d[p_71883_6_]); } p_71883_1_.func_72908_a((double)p_71883_2_ + 0.5D, (double)p_71883_3_ + 0.5D, (double)p_71883_4_ + 0.5D, "tile.piston.in", 0.5F, p_71883_1_.field_73012_v.nextFloat() * 0.15F + 0.6F); } return true; }
private boolean func_72115_j(World p_72115_1_, int p_72115_2_, int p_72115_3_, int p_72115_4_, int p_72115_5_) { int var6 = p_72115_2_ + Facing.field_71586_b[p_72115_5_]; int var7 = p_72115_3_ + Facing.field_71587_c[p_72115_5_]; int var8 = p_72115_4_ + Facing.field_71585_d[p_72115_5_]; int var9 = 0; while(true) { int var10; if(var9 < 13) { if(var7 <= 0 || var7 >= 255) { return false; } var10 = p_72115_1_.func_72798_a(var6, var7, var8); if(var10 != 0) { if(!func_72111_a(var10, p_72115_1_, var6, var7, var8, true)) { return false; } if(Block.field_71973_m[var10].func_71915_e() != 1) { if(var9 == 12) { return false; } var6 += Facing.field_71586_b[p_72115_5_]; var7 += Facing.field_71587_c[p_72115_5_]; var8 += Facing.field_71585_d[p_72115_5_]; ++var9; continue; } Block.field_71973_m[var10].func_71897_c(p_72115_1_, var6, var7, var8, p_72115_1_.func_72805_g(var6, var7, var8), 0); p_72115_1_.func_94571_i(var6, var7, var8); } } var9 = var6; var10 = var7; int var11 = var8; int var12 = 0; int[] var13; int var14; int var15; int var16; for(var13 = new int[13]; var6 != p_72115_2_ || var7 != p_72115_3_ || var8 != p_72115_4_; var8 = var16) { var14 = var6 - Facing.field_71586_b[p_72115_5_]; var15 = var7 - Facing.field_71587_c[p_72115_5_]; var16 = var8 - Facing.field_71585_d[p_72115_5_]; int var17 = p_72115_1_.func_72798_a(var14, var15, var16); int var18 = p_72115_1_.func_72805_g(var14, var15, var16); if(var17 == this.field_71990_ca && var14 == p_72115_2_ && var15 == p_72115_3_ && var16 == p_72115_4_) { p_72115_1_.func_72832_d(var6, var7, var8, Block.field_72095_ac.field_71990_ca, p_72115_5_ | (this.field_72119_a?8:0), 4); p_72115_1_.func_72837_a(var6, var7, var8, BlockPistonMoving.func_72297_a(Block.field_72099_aa.field_71990_ca, p_72115_5_ | (this.field_72119_a?8:0), p_72115_5_, true, false)); } else { p_72115_1_.func_72832_d(var6, var7, var8, Block.field_72095_ac.field_71990_ca, var18, 4); p_72115_1_.func_72837_a(var6, var7, var8, BlockPistonMoving.func_72297_a(var17, var18, p_72115_5_, true, false)); } var13[var12++] = var17; var6 = var14; var7 = var15; } var6 = var9; var7 = var10; var8 = var11; for(var12 = 0; var6 != p_72115_2_ || var7 != p_72115_3_ || var8 != p_72115_4_; var8 = var16) { var14 = var6 - Facing.field_71586_b[p_72115_5_]; var15 = var7 - Facing.field_71587_c[p_72115_5_]; var16 = var8 - Facing.field_71585_d[p_72115_5_]; p_72115_1_.func_72898_h(var14, var15, var16, var13[var12++]); var6 = var14; var7 = var15; } return true; } }