public class BlockSkull extends BlockContainer { public static final BlockStateDirection FACING = BlockStateDirection.of("facing"); public static final BlockStateBoolean NODROP = BlockStateBoolean.of("nodrop"); private static final Predicate M = new BlockSkullInnerClass1(); private ShapeDetector N; private ShapeDetector O; protected BlockSkull() { super(Material.ORIENTABLE); this.j( this.blockStateList .getBlockData() .set(BlockSkull.FACING, EnumDirection.NORTH) .set(BlockSkull.NODROP, Boolean.valueOf(false))); this.a(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); } public boolean c() { return false; } public boolean d() { return false; } public void updateShape(IBlockAccess iblockaccess, BlockPosition blockposition) { switch (SwitchHelperDirection15.a[ ((EnumDirection) iblockaccess.getType(blockposition).get(BlockSkull.FACING)).ordinal()]) { case 1: default: this.a(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); break; case 2: this.a(0.25F, 0.25F, 0.5F, 0.75F, 0.75F, 1.0F); break; case 3: this.a(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 0.5F); break; case 4: this.a(0.5F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); break; case 5: this.a(0.0F, 0.25F, 0.25F, 0.5F, 0.75F, 0.75F); } } public AxisAlignedBB a(World world, BlockPosition blockposition, IBlockData iblockdata) { this.updateShape(world, blockposition); return super.a(world, blockposition, iblockdata); } public IBlockData getPlacedState( World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) { return this.getBlockData() .set(BlockSkull.FACING, entityliving.getDirection()) .set(BlockSkull.NODROP, Boolean.valueOf(false)); } public TileEntity a(World world, int i) { return new TileEntitySkull(); } public int getDropData(World world, BlockPosition blockposition) { TileEntity tileentity = world.getTileEntity(blockposition); return tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).getSkullType() : super.getDropData(world, blockposition); } // CraftBukkit start - Special case dropping so we can get info from the tile entity public void dropNaturally( World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { if (world.random.nextFloat() < f) { ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition)); TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition); if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { itemstack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); itemstack.getTag().set("SkullOwner", nbttagcompound); } a(world, blockposition, itemstack); } } // CraftBukkit end public void a( World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { if (entityhuman.abilities.canInstantlyBuild) { iblockdata = iblockdata.set(BlockSkull.NODROP, Boolean.valueOf(true)); world.setTypeAndData(blockposition, iblockdata, 4); } super.a(world, blockposition, iblockdata, entityhuman); } public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { if (!world.isStatic) { // CraftBukkit start - Drop item in code above, not here // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { if (false) { // CraftBukkit end TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity instanceof TileEntitySkull) { TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition)); if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { itemstack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); itemstack.getTag().set("SkullOwner", nbttagcompound); } a(world, blockposition, itemstack); } } super.remove(world, blockposition, iblockdata); } } public Item getDropType(IBlockData iblockdata, Random random, int i) { return Items.SKULL; } public boolean b(World world, BlockPosition blockposition, ItemStack itemstack) { return itemstack.getData() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isStatic ? this.j().a(world, blockposition) != null : false; } public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { if (world.captureBlockStates) return; // CraftBukkit if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isStatic) { ShapeDetector shapedetector = this.l(); ShapeDetectorCollection shapedetectorcollection = shapedetector.a(world, blockposition); if (shapedetectorcollection != null) { // CraftBukkit start - Use BlockStateListPopulator BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); int i; for (i = 0; i < 3; ++i) { ShapeDetectorBlock shapedetectorblock = shapedetectorcollection.a(i, 0, 0); // CraftBukkit start // world.setTypeAndData(shapedetectorblock.d(), // shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2); BlockPosition pos = shapedetectorblock.d(); IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)); blockList.setTypeAndData( pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2); // CraftBukkit end } for (i = 0; i < shapedetector.c(); ++i) { for (int j = 0; j < shapedetector.b(); ++j) { ShapeDetectorBlock shapedetectorblock1 = shapedetectorcollection.a(i, j, 0); // CraftBukkit start // world.setTypeAndData(shapedetectorblock1.d(), Blocks.AIR.getBlockData(), 2); BlockPosition pos = shapedetectorblock1.d(); blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2); // CraftBukkit end } } BlockPosition blockposition1 = shapedetectorcollection.a(1, 0, 0).d(); EntityWither entitywither = new EntityWither(world); BlockPosition blockposition2 = shapedetectorcollection.a(1, 2, 0).d(); entitywither.setPositionRotation( (double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetectorcollection.b().k() == EnumAxis.X ? 0.0F : 90.0F, 0.0F); entitywither.aG = shapedetectorcollection.b().k() == EnumAxis.X ? 0.0F : 90.0F; entitywither.n(); Iterator iterator = world .a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D)) .iterator(); // CraftBukkit start if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { while (iterator.hasNext()) { EntityHuman entityhuman = (EntityHuman) iterator.next(); entityhuman.b((Statistic) AchievementList.I); } blockList.updateList(); int k; for (k = 0; k < 120; ++k) { world.addParticle( EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (k = 0; k < shapedetector.c(); ++k) { for (int l = 0; l < shapedetector.b(); ++l) { ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(k, l, 0); world.update(shapedetectorblock2.d(), Blocks.AIR); } } } // CraftBukkit end } } } public IBlockData fromLegacyData(int i) { return this.getBlockData() .set(BlockSkull.FACING, EnumDirection.fromType1(i & 7)) .set(BlockSkull.NODROP, Boolean.valueOf((i & 8) > 0)); } public int toLegacyData(IBlockData iblockdata) { byte b0 = 0; int i = b0 | ((EnumDirection) iblockdata.get(BlockSkull.FACING)).a(); if (((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { i |= 8; } return i; } protected BlockStateList getStateList() { return new BlockStateList(this, new IBlockState[] {BlockSkull.FACING, BlockSkull.NODROP}); } protected ShapeDetector j() { if (this.N == null) { this.N = ShapeDetectorBuilder.a() .a(new String[] {" ", "###", "~#~"}) .a('#', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.SOUL_SAND))) .a('~', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.AIR))) .b(); } return this.N; } protected ShapeDetector l() { if (this.O == null) { this.O = ShapeDetectorBuilder.a() .a(new String[] {"^^^", "###", "~#~"}) .a('#', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.SOUL_SAND))) .a('^', BlockSkull.M) .a('~', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.AIR))) .b(); } return this.O; } }
public class BlockTNT extends Block { public static final BlockStateBoolean EXPLODE = BlockStateBoolean.of("explode"); public BlockTNT() { super(Material.TNT); this.y(this.blockStateList.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(false))); this.a(CreativeModeTab.d); } public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) { super.onPlace(world, blockposition, iblockdata); if (world.isBlockIndirectlyPowered(blockposition)) { this.postBreak(world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true))); world.setAir(blockposition); } } public void a( IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) { if (world.isBlockIndirectlyPowered(blockposition)) { this.postBreak(world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true))); world.setAir(blockposition); } } public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) { if (!world.isClientSide) { EntityTNTPrimed entitytntprimed = new EntityTNTPrimed( world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), explosion.getSource()); entitytntprimed.setFuseTicks( (short) (world.random.nextInt(entitytntprimed.getFuseTicks() / 4) + entitytntprimed.getFuseTicks() / 8)); world.addEntity(entitytntprimed); } } public void postBreak(World world, BlockPosition blockposition, IBlockData iblockdata) { this.a(world, blockposition, iblockdata, (EntityLiving) null); } public void a( World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) { if (!world.isClientSide) { if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) { EntityTNTPrimed entitytntprimed = new EntityTNTPrimed( world, (double) ((float) blockposition.getX() + 0.5F), (double) blockposition.getY(), (double) ((float) blockposition.getZ() + 0.5F), entityliving); world.addEntity(entitytntprimed); world.a( (EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gV, SoundCategory.BLOCKS, 1.0F, 1.0F); } } } public boolean interact( World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { ItemStack itemstack = entityhuman.b(enumhand); if (!itemstack.isEmpty() && (itemstack.getItem() == Items.FLINT_AND_STEEL || itemstack.getItem() == Items.FIRE_CHARGE)) { this.a( world, blockposition, iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true)), (EntityLiving) entityhuman); world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); if (itemstack.getItem() == Items.FLINT_AND_STEEL) { itemstack.damage(1, entityhuman); } else if (!entityhuman.abilities.canInstantlyBuild) { itemstack.subtract(1); } return true; } else { return super.interact( world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2); } } public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!world.isClientSide && entity instanceof EntityArrow) { EntityArrow entityarrow = (EntityArrow) entity; if (entityarrow.isBurning()) { // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( entityarrow, blockposition, Blocks.AIR, 0) .isCancelled()) { return; } // CraftBukkit end this.a( world, blockposition, world.getType(blockposition).set(BlockTNT.EXPLODE, Boolean.valueOf(true)), entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null); world.setAir(blockposition); } } } public boolean a(Explosion explosion) { return false; } public IBlockData fromLegacyData(int i) { return this.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf((i & 1) > 0)); } public int toLegacyData(IBlockData iblockdata) { return ((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue() ? 1 : 0; } protected BlockStateList getStateList() { return new BlockStateList(this, new IBlockState[] {BlockTNT.EXPLODE}); } }
public class BlockLever extends Block { public static final BlockStateEnum<EnumLeverPosition> FACING = BlockStateEnum.of("facing", EnumLeverPosition.class); public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); protected BlockLever() { super(Material.ORIENTABLE); j( this.blockStateList .getBlockData() .set(FACING, EnumLeverPosition.NORTH) .set(POWERED, Boolean.valueOf(false))); a(CreativeModeTab.d); } public AxisAlignedBB a(World world, BlockPosition blockposition, IBlockData iblockdata) { return null; } public boolean c() { return false; } public boolean d() { return false; } public boolean canPlace(World world, BlockPosition blockposition, EnumDirection enumdirection) { return a(world, blockposition, enumdirection.opposite()); } public boolean canPlace(World world, BlockPosition blockposition) { EnumDirection[] aenumdirection = EnumDirection.values(); int i = aenumdirection.length; for (int j = 0; j < i; j++) { EnumDirection enumdirection = aenumdirection[j]; if (a(world, blockposition, enumdirection)) { return true; } } return false; } protected static boolean a( World world, BlockPosition blockposition, EnumDirection enumdirection) { return BlockButtonAbstract.a(world, blockposition, enumdirection); } public IBlockData getPlacedState( World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) { IBlockData iblockdata = getBlockData().set(POWERED, Boolean.valueOf(false)); if (a(world, blockposition, enumdirection.opposite())) { return iblockdata.set( FACING, EnumLeverPosition.a(enumdirection, entityliving.getDirection())); } Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator(); EnumDirection enumdirection1; do { if (!iterator.hasNext()) { if (World.a(world, blockposition.down())) { return iblockdata.set( FACING, EnumLeverPosition.a(EnumDirection.UP, entityliving.getDirection())); } return iblockdata; } enumdirection1 = (EnumDirection) iterator.next(); } while ((enumdirection1 == enumdirection) || (!a(world, blockposition, enumdirection1.opposite()))); return iblockdata.set(FACING, EnumLeverPosition.a(enumdirection1, entityliving.getDirection())); } public static int a(EnumDirection enumdirection) { switch (SyntheticClass_1.a[enumdirection.ordinal()]) { case 1: return 0; case 2: return 5; case 3: return 4; case 4: return 3; case 5: return 2; case 6: return 1; } return -1; } public void doPhysics( World world, BlockPosition blockposition, IBlockData iblockdata, Block block) { if ((e(world, blockposition, iblockdata)) && (!a( world, blockposition, ((EnumLeverPosition) iblockdata.get(FACING)).c().opposite()))) { b(world, blockposition, iblockdata, 0); world.setAir(blockposition); } } private boolean e(World world, BlockPosition blockposition, IBlockData iblockdata) { if (canPlace(world, blockposition)) { return true; } b(world, blockposition, iblockdata, 0); world.setAir(blockposition); return false; } public void updateShape(IBlockAccess iblockaccess, BlockPosition blockposition) { float f = 0.1875F; switch (SyntheticClass_1.b[ ((EnumLeverPosition) iblockaccess.getType(blockposition).get(FACING)).ordinal()]) { case 1: a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); break; case 2: a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); break; case 3: a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); break; case 4: a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); break; case 5: case 6: f = 0.25F; a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); break; case 7: case 8: f = 0.25F; a(0.5F - f, 0.4F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); } } public boolean interact( World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumDirection enumdirection, float f, float f1, float f2) { if (world.isClientSide) { return true; } boolean powered = ((Boolean) iblockdata.get(POWERED)).booleanValue(); org.bukkit.block.Block block = world .getWorld() .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); int old = powered ? 15 : 0; int current = !powered ? 15 : 0; BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); world.getServer().getPluginManager().callEvent(eventRedstone); if ((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1)) { return true; } iblockdata = iblockdata.a(POWERED); world.setTypeAndData(blockposition, iblockdata, 3); world.makeSound( blockposition.getX() + 0.5D, blockposition.getY() + 0.5D, blockposition.getZ() + 0.5D, "random.click", 0.3F, ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0.6F : 0.5F); world.applyPhysics(blockposition, this); EnumDirection enumdirection1 = ((EnumLeverPosition) iblockdata.get(FACING)).c(); world.applyPhysics(blockposition.shift(enumdirection1.opposite()), this); return true; } public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { if (((Boolean) iblockdata.get(POWERED)).booleanValue()) { world.applyPhysics(blockposition, this); EnumDirection enumdirection = ((EnumLeverPosition) iblockdata.get(FACING)).c(); world.applyPhysics(blockposition.shift(enumdirection.opposite()), this); } super.remove(world, blockposition, iblockdata); } public int a( IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata, EnumDirection enumdirection) { return ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 15 : 0; } public int b( IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata, EnumDirection enumdirection) { return ((EnumLeverPosition) iblockdata.get(FACING)).c() == enumdirection ? 15 : !((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0 : 0; } public boolean isPowerSource() { return true; } public IBlockData fromLegacyData(int i) { return getBlockData() .set(FACING, EnumLeverPosition.a(i & 0x7)) .set(POWERED, Boolean.valueOf((i & 0x8) > 0)); } public int toLegacyData(IBlockData iblockdata) { byte b0 = 0; int i = b0 | ((EnumLeverPosition) iblockdata.get(FACING)).a(); if (((Boolean) iblockdata.get(POWERED)).booleanValue()) { i |= 0x8; } return i; } protected BlockStateList getStateList() { return new BlockStateList(this, new IBlockState[] {FACING, POWERED}); } static class SyntheticClass_1 { static final int[] a; static final int[] b; static final int[] c = new int[EnumDirection.EnumAxis.values().length]; static { try { c[EnumDirection.EnumAxis.X.ordinal()] = 1; } catch (NoSuchFieldError localNoSuchFieldError1) { } try { c[EnumDirection.EnumAxis.Z.ordinal()] = 2; } catch (NoSuchFieldError localNoSuchFieldError2) { } b = new int[BlockLever.EnumLeverPosition.values().length]; try { b[BlockLever.EnumLeverPosition.EAST.ordinal()] = 1; } catch (NoSuchFieldError localNoSuchFieldError3) { } try { b[BlockLever.EnumLeverPosition.WEST.ordinal()] = 2; } catch (NoSuchFieldError localNoSuchFieldError4) { } try { b[BlockLever.EnumLeverPosition.SOUTH.ordinal()] = 3; } catch (NoSuchFieldError localNoSuchFieldError5) { } try { b[BlockLever.EnumLeverPosition.NORTH.ordinal()] = 4; } catch (NoSuchFieldError localNoSuchFieldError6) { } try { b[BlockLever.EnumLeverPosition.UP_Z.ordinal()] = 5; } catch (NoSuchFieldError localNoSuchFieldError7) { } try { b[BlockLever.EnumLeverPosition.UP_X.ordinal()] = 6; } catch (NoSuchFieldError localNoSuchFieldError8) { } try { b[BlockLever.EnumLeverPosition.DOWN_X.ordinal()] = 7; } catch (NoSuchFieldError localNoSuchFieldError9) { } try { b[BlockLever.EnumLeverPosition.DOWN_Z.ordinal()] = 8; } catch (NoSuchFieldError localNoSuchFieldError10) { } a = new int[EnumDirection.values().length]; try { a[EnumDirection.DOWN.ordinal()] = 1; } catch (NoSuchFieldError localNoSuchFieldError11) { } try { a[EnumDirection.UP.ordinal()] = 2; } catch (NoSuchFieldError localNoSuchFieldError12) { } try { a[EnumDirection.NORTH.ordinal()] = 3; } catch (NoSuchFieldError localNoSuchFieldError13) { } try { a[EnumDirection.SOUTH.ordinal()] = 4; } catch (NoSuchFieldError localNoSuchFieldError14) { } try { a[EnumDirection.WEST.ordinal()] = 5; } catch (NoSuchFieldError localNoSuchFieldError15) { } try { a[EnumDirection.EAST.ordinal()] = 6; } catch (NoSuchFieldError localNoSuchFieldError16) { } } } public static enum EnumLeverPosition implements INamable { DOWN_X(0, "down_x", EnumDirection.DOWN), EAST(1, "east", EnumDirection.EAST), WEST(2, "west", EnumDirection.WEST), SOUTH(3, "south", EnumDirection.SOUTH), NORTH(4, "north", EnumDirection.NORTH), UP_Z(5, "up_z", EnumDirection.UP), UP_X(6, "up_x", EnumDirection.UP), DOWN_Z(7, "down_z", EnumDirection.DOWN); private static final EnumLeverPosition[] i; private final int j; private final String k; private final EnumDirection l; private EnumLeverPosition(int i, String s, EnumDirection enumdirection) { this.j = i; this.k = s; this.l = enumdirection; } public int a() { return this.j; } public EnumDirection c() { return this.l; } public String toString() { return this.k; } public static EnumLeverPosition a(int i) { if ((i < 0) || (i >= i.length)) { i = 0; } return i[i]; } public static EnumLeverPosition a(EnumDirection enumdirection, EnumDirection enumdirection1) { switch (BlockLever.SyntheticClass_1.a[enumdirection.ordinal()]) { case 1: switch (BlockLever.SyntheticClass_1.c[enumdirection1.k().ordinal()]) { case 1: return DOWN_X; case 2: return DOWN_Z; } throw new IllegalArgumentException( "Invalid entityFacing " + enumdirection1 + " for facing " + enumdirection); case 2: switch (BlockLever.SyntheticClass_1.c[enumdirection1.k().ordinal()]) { case 1: return UP_X; case 2: return UP_Z; } throw new IllegalArgumentException( "Invalid entityFacing " + enumdirection1 + " for facing " + enumdirection); case 3: return NORTH; case 4: return SOUTH; case 5: return WEST; case 6: return EAST; } throw new IllegalArgumentException("Invalid facing: " + enumdirection); } public String getName() { return this.k; } static { i = new EnumLeverPosition[values().length]; EnumLeverPosition[] ablocklever_enumleverposition = values(); int i = ablocklever_enumleverposition.length; for (int j = 0; j < i; j++) { EnumLeverPosition blocklever_enumleverposition = ablocklever_enumleverposition[j]; i[blocklever_enumleverposition.a()] = blocklever_enumleverposition; } } } }
public class BlockSkull extends BlockTileEntity { public static final BlockStateDirection FACING = BlockDirectional.FACING; public static final BlockStateBoolean NODROP = BlockStateBoolean.of("nodrop"); private static final Predicate<ShapeDetectorBlock> B = new Predicate() { public boolean a(@Nullable ShapeDetectorBlock shapedetectorblock) { return shapedetectorblock.a() != null && shapedetectorblock.a().getBlock() == Blocks.SKULL && shapedetectorblock.b() instanceof TileEntitySkull && ((TileEntitySkull) shapedetectorblock.b()).getSkullType() == 1; } public boolean apply(@Nullable Object object) { return this.a((ShapeDetectorBlock) object); } }; protected static final AxisAlignedBB c = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 0.5D, 0.75D); protected static final AxisAlignedBB d = new AxisAlignedBB(0.25D, 0.25D, 0.5D, 0.75D, 0.75D, 1.0D); protected static final AxisAlignedBB e = new AxisAlignedBB(0.25D, 0.25D, 0.0D, 0.75D, 0.75D, 0.5D); protected static final AxisAlignedBB f = new AxisAlignedBB(0.5D, 0.25D, 0.25D, 1.0D, 0.75D, 0.75D); protected static final AxisAlignedBB g = new AxisAlignedBB(0.0D, 0.25D, 0.25D, 0.5D, 0.75D, 0.75D); private ShapeDetector C; private ShapeDetector D; protected BlockSkull() { super(Material.ORIENTABLE); this.y( this.blockStateList .getBlockData() .set(BlockSkull.FACING, EnumDirection.NORTH) .set(BlockSkull.NODROP, Boolean.valueOf(false))); } public String getName() { return LocaleI18n.get("tile.skull.skeleton.name"); } public boolean b(IBlockData iblockdata) { return false; } public boolean c(IBlockData iblockdata) { return false; } public AxisAlignedBB b( IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) { switch ((EnumDirection) iblockdata.get(BlockSkull.FACING)) { case UP: default: return BlockSkull.c; case NORTH: return BlockSkull.d; case SOUTH: return BlockSkull.e; case WEST: return BlockSkull.f; case EAST: return BlockSkull.g; } } public IBlockData getPlacedState( World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2, int i, EntityLiving entityliving) { return this.getBlockData() .set(BlockSkull.FACING, entityliving.getDirection()) .set(BlockSkull.NODROP, Boolean.valueOf(false)); } public TileEntity a(World world, int i) { return new TileEntitySkull(); } public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) { int i = 0; TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity instanceof TileEntitySkull) { i = ((TileEntitySkull) tileentity).getSkullType(); } return new ItemStack(Items.SKULL, 1, i); } // CraftBukkit start - Special case dropping so we can get info from the tile entity @Override public void dropNaturally( World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { if (world.random.nextFloat() < f) { TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity instanceof TileEntitySkull) { TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; ItemStack itemstack = this.a(world, blockposition, iblockdata); if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { itemstack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); itemstack.getTag().set("SkullOwner", nbttagcompound); } a(world, blockposition, itemstack); } } } // CraftBukkit end public void a( World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { if (entityhuman.abilities.canInstantlyBuild) { iblockdata = iblockdata.set(BlockSkull.NODROP, Boolean.valueOf(true)); world.setTypeAndData(blockposition, iblockdata, 4); } super.a(world, blockposition, iblockdata, entityhuman); } public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { if (!world.isClientSide) { // CraftBukkit start - Drop item in code above, not here // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { if (false) { // CraftBukkit end TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity instanceof TileEntitySkull) { TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; ItemStack itemstack = this.a(world, blockposition, iblockdata); if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { itemstack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); itemstack.getTag().set("SkullOwner", nbttagcompound); } a(world, blockposition, itemstack); } } super.remove(world, blockposition, iblockdata); } } public Item getDropType(IBlockData iblockdata, Random random, int i) { return Items.SKULL; } public boolean b(World world, BlockPosition blockposition, ItemStack itemstack) { return itemstack.getData() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide ? this.e().a(world, blockposition) != null : false; } public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { if (world.captureBlockStates) return; // CraftBukkit if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide) { ShapeDetector shapedetector = this.g(); ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); if (shapedetector_shapedetectorcollection != null) { // CraftBukkit start - Use BlockStateListPopulator BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); int i; for (i = 0; i < 3; ++i) { ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0); // CraftBukkit start // world.setTypeAndData(shapedetectorblock.getPosition(), // shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2); BlockPosition pos = shapedetectorblock.getPosition(); IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)); blockList.setTypeAndData( pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2); // CraftBukkit end } for (i = 0; i < shapedetector.c(); ++i) { for (int j = 0; j < shapedetector.b(); ++j) { ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(i, j, 0); // CraftBukkit start // world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), // 2); BlockPosition pos = shapedetectorblock1.getPosition(); blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2); // CraftBukkit end } } BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(1, 0, 0).getPosition(); EntityWither entitywither = new EntityWither(world); BlockPosition blockposition2 = shapedetector_shapedetectorcollection.a(1, 2, 0).getPosition(); entitywither.setPositionRotation( (double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); entitywither.aN = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; entitywither.o(); Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator(); // CraftBukkit start if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { blockList.updateList(); while (iterator.hasNext()) { EntityHuman entityhuman = (EntityHuman) iterator.next(); entityhuman.b((Statistic) AchievementList.I); } int k; for (k = 0; k < 120; ++k) { world.addParticle( EnumParticle.SNOWBALL, (double) blockposition1.getX() + world.random.nextDouble(), (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (k = 0; k < shapedetector.c(); ++k) { for (int l = 0; l < shapedetector.b(); ++l) { ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(k, l, 0); world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false); } } } // CraftBukkit end } } } public IBlockData fromLegacyData(int i) { return this.getBlockData() .set(BlockSkull.FACING, EnumDirection.fromType1(i & 7)) .set(BlockSkull.NODROP, Boolean.valueOf((i & 8) > 0)); } public int toLegacyData(IBlockData iblockdata) { byte b0 = 0; int i = b0 | ((EnumDirection) iblockdata.get(BlockSkull.FACING)).a(); if (((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { i |= 8; } return i; } public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) { return iblockdata.set( BlockSkull.FACING, enumblockrotation.a((EnumDirection) iblockdata.get(BlockSkull.FACING))); } public IBlockData a(IBlockData iblockdata, EnumBlockMirror enumblockmirror) { return iblockdata.a(enumblockmirror.a((EnumDirection) iblockdata.get(BlockSkull.FACING))); } protected BlockStateList getStateList() { return new BlockStateList(this, new IBlockState[] {BlockSkull.FACING, BlockSkull.NODROP}); } protected ShapeDetector e() { if (this.C == null) { this.C = ShapeDetectorBuilder.a() .a(new String[] {" ", "###", "~#~"}) .a('#', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.SOUL_SAND))) .a('~', ShapeDetectorBlock.a(MaterialPredicate.a(Material.AIR))) .b(); } return this.C; } protected ShapeDetector g() { if (this.D == null) { this.D = ShapeDetectorBuilder.a() .a(new String[] {"^^^", "###", "~#~"}) .a('#', ShapeDetectorBlock.a(BlockStatePredicate.a(Blocks.SOUL_SAND))) .a('^', BlockSkull.B) .a('~', ShapeDetectorBlock.a(MaterialPredicate.a(Material.AIR))) .b(); } return this.D; } }