public boolean generate(World world, Random random, BlockPosition blockposition) { while (world.isEmpty(blockposition) && blockposition.getY() > 2) { blockposition = blockposition.down(); } if (world.getType(blockposition).getBlock() != Blocks.SNOW) { return false; } else { int i = random.nextInt(this.b - 2) + 2; byte b0 = 1; for (int j = blockposition.getX() - i; j <= blockposition.getX() + i; ++j) { for (int k = blockposition.getZ() - i; k <= blockposition.getZ() + i; ++k) { int l = j - blockposition.getX(); int i1 = k - blockposition.getZ(); if (l * l + i1 * i1 <= i * i) { for (int j1 = blockposition.getY() - b0; j1 <= blockposition.getY() + b0; ++j1) { BlockPosition blockposition1 = new BlockPosition(j, j1, k); Block block = world.getType(blockposition1).getBlock(); if (block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) { world.setTypeAndData(blockposition1, this.a.getBlockData(), 2); } } } } } return true; } }
protected void checkBlockCollisions() { BlockPosition blockposition = new BlockPosition( this.getBoundingBox().a + 0.001D, this.getBoundingBox().b + 0.001D, this.getBoundingBox().c + 0.001D); BlockPosition blockposition1 = new BlockPosition( this.getBoundingBox().d - 0.001D, this.getBoundingBox().e - 0.001D, this.getBoundingBox().f - 0.001D); if (this.world.areChunksLoadedBetween(blockposition, blockposition1)) { for (int i = blockposition.getX(); i <= blockposition1.getX(); ++i) { for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) { for (int k = blockposition.getZ(); k <= blockposition1.getZ(); ++k) { BlockPosition blockposition2 = new BlockPosition(i, j, k); IBlockData iblockdata = this.world.getType(blockposition2); try { iblockdata.getBlock().a(this.world, blockposition2, iblockdata, this); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Colliding entity with block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being collided with"); CrashReportSystemDetails.a(crashreportsystemdetails, blockposition2, iblockdata); throw new ReportedException(crashreport); } } } } } }
public boolean interactWith( ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { if (world.isClientSide) { return true; } else { blockposition = blockposition.shift(enumdirection); if (!entityhuman.a(blockposition, enumdirection, itemstack)) { return false; } else { if (world.getType(blockposition).getBlock().getMaterial() == Material.AIR) { world.makeSound( (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "item.fireCharge.use", 1.0F, (ItemFireball.g.nextFloat() - ItemFireball.g.nextFloat()) * 0.2F + 1.0F); world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); } if (!entityhuman.abilities.canInstantlyBuild) { --itemstack.count; } return true; } } }
public void d(World world, BlockPosition blockposition) { if (!world.worldProvider.o()) { IBlockData iblockdata = world.getType(blockposition); int i = world.b(EnumSkyBlock.SKY, blockposition) - world.ab(); float f = world.d(1.0F); float f1 = f < 3.1415927F ? 0.0F : 6.2831855F; f += (f1 - f) * 0.2F; i = Math.round((float) i * MathHelper.cos(f)); i = MathHelper.clamp(i, 0, 15); if (this.b) { i = 15 - i; } if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) { i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange( world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), ((Integer) iblockdata.get(POWER)), i) .getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent world.setTypeAndData( blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3); } } }
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 void setPositionRotation(BlockPosition blockposition, float f, float f1) { this.setPositionRotation( (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, f, f1); }
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; }
protected void k() { boolean flag = true; boolean flag1 = true; boolean flag2 = true; boolean flag3 = true; int i = 0; this.b("menu.generatingTerrain"); byte b0 = 0; // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory for (int m = 0; m < worlds.size(); m++) { WorldServer worldserver = this.worlds.get(m); LOGGER.info( "Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")"); if (!worldserver.getWorld().getKeepSpawnInMemory()) { continue; } BlockPosition blockposition = worldserver.getSpawn(); long j = ax(); i = 0; for (int k = -192; k <= 192 && this.isRunning(); k += 16) { for (int l = -192; l <= 192 && this.isRunning(); l += 16) { long i1 = ax(); if (i1 - j > 1000L) { this.a_("Preparing spawn area", i * 100 / 625); j = i1; } ++i; worldserver.chunkProviderServer.getChunkAt( blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4); } } } for (WorldServer world : this.worlds) { this.server .getPluginManager() .callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); } // CraftBukkit end this.q(); }
public boolean interactWith( ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { IBlockData iblockdata = world.getType(blockposition); Block block = iblockdata.getBlock(); if (!block.a(world, blockposition)) { blockposition = blockposition.shift(enumdirection); } if (itemstack.count == 0) { return false; } else if (!entityhuman.a(blockposition, enumdirection, itemstack)) { return false; } else if (world.a(this.a, blockposition, false, enumdirection, (Entity) null, itemstack)) { int i = this.filterData(itemstack.getData()); IBlockData iblockdata1 = this.a.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityhuman); if (world.setTypeAndData(blockposition, iblockdata1, 3)) { iblockdata1 = world.getType(blockposition); if (iblockdata1.getBlock() == this.a) { a(world, entityhuman, blockposition, itemstack); this.a.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack); } world.makeSound( (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), this.a.stepSound.getPlaceSound(), (this.a.stepSound.getVolume1() + 1.0F) / 2.0F, this.a.stepSound.getVolume2() * 0.8F); --itemstack.count; } return true; } else { return false; } }
protected UseResult a( ItemStack var1, EntityHuman var2, World var3, BlockPosition var4, IBlockData var5) { var3.a( (double) ((float) var4.getX() + 0.5F), (double) ((float) var4.getY() + 0.5F), (double) ((float) var4.getZ() + 0.5F), var5.getBlock().stepSound.getStepSound(), (var5.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, var5.getBlock().stepSound.getPitch() * 0.8F); if (var3.isClientSide) { return UseResult.SUCCESS; } else { var3.setTypeUpdate(var4, var5); var1.a(1, (EntityLiving) var2); return UseResult.SUCCESS; } }
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 b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { int i = ((Integer) iblockdata.get(AGE)).intValue(); if ((i < 3) && (random.nextInt( Math.max(1, (int) world.growthOdds / world.spigotConfig.wartModifier * 10)) == 0)) { iblockdata = iblockdata.set(AGE, Integer.valueOf(i + 1)); CraftEventFactory.handleBlockGrowEvent( world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); } super.b(world, blockposition, iblockdata, random); }
protected boolean a( ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) { world.makeSound( (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), iblockdata.getBlock().stepSound.getStepSound(), (iblockdata.getBlock().stepSound.getVolume1() + 1.0F) / 2.0F, iblockdata.getBlock().stepSound.getVolume2() * 0.8F); if (world.isClientSide) { return true; } else { world.setTypeUpdate(blockposition, iblockdata); itemstack.damage(1, entityhuman); return true; } }
public static boolean a( World world, EntityHuman entityhuman, BlockPosition blockposition, ItemStack itemstack) { MinecraftServer minecraftserver = MinecraftServer.getServer(); if (minecraftserver == null) { return false; } else { if (itemstack.hasTag() && itemstack.getTag().hasKeyOfType("BlockEntityTag", 10)) { TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity != null) { if (!world.isClientSide && tileentity.F() && !minecraftserver.getPlayerList().isOp(entityhuman.getProfile())) { return false; } NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.clone(); tileentity.b(nbttagcompound); NBTTagCompound nbttagcompound2 = (NBTTagCompound) itemstack.getTag().get("BlockEntityTag"); nbttagcompound.a(nbttagcompound2); nbttagcompound.setInt("x", blockposition.getX()); nbttagcompound.setInt("y", blockposition.getY()); nbttagcompound.setInt("z", blockposition.getZ()); if (!nbttagcompound.equals(nbttagcompound1)) { tileentity.a(nbttagcompound); tileentity.update(); return true; } } } return false; } }
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { org.bukkit.World bworld = world.getWorld(); Server server = world.getServer(); org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); int i = ((Integer) iblockdata.get(LEVEL)).intValue(); byte b0 = 1; if ((this.material == Material.LAVA) && (!world.worldProvider.n())) { b0 = 2; } int j = a(world); if (i > 0) { int l = -100; this.a = 0; EnumDirection enumdirection; for (Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator(); iterator.hasNext(); l = a(world, blockposition.shift(enumdirection), l)) { enumdirection = (EnumDirection) iterator.next(); } int i1 = l + b0; if ((i1 >= 8) || (l < 0)) { i1 = -1; } if (e(world, blockposition.up()) >= 0) { int k = e(world, blockposition.up()); if (k >= 8) { i1 = k; } else { i1 = k + 8; } } if ((this.a >= 2) && (this.material == Material.WATER)) { IBlockData iblockdata1 = world.getType(blockposition.down()); if (iblockdata1.getBlock().getMaterial().isBuildable()) { i1 = 0; } else if ((iblockdata1.getBlock().getMaterial() == this.material) && (((Integer) iblockdata1.get(LEVEL)).intValue() == 0)) { i1 = 0; } } if ((this.material == Material.LAVA) && (i < 8) && (i1 < 8) && (i1 > i) && (random.nextInt(4) != 0)) { j *= 4; } if (i1 == i) { f(world, blockposition, iblockdata); } else { i = i1; if (i1 < 0) { world.setAir(blockposition); } else { iblockdata = iblockdata.set(LEVEL, Integer.valueOf(i1)); world.setTypeAndData(blockposition, iblockdata, 2); world.a(blockposition, this, j); world.applyPhysics(blockposition, this); } } } else { f(world, blockposition, iblockdata); } IBlockData iblockdata2 = world.getType(blockposition.down()); if (h(world, blockposition.down(), iblockdata2)) { BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); if (server != null) { server.getPluginManager().callEvent(event); } if (!event.isCancelled()) { if ((this.material == Material.LAVA) && (world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER)) { world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData()); fizz(world, blockposition.down()); return; } if (i >= 8) { flow(world, blockposition.down(), iblockdata2, i); } else { flow(world, blockposition.down(), iblockdata2, i + 8); } } } else if ((i >= 0) && ((i == 0) || (g(world, blockposition.down(), iblockdata2)))) { Set set = f(world, blockposition); int k = i + b0; if (i >= 8) { k = 1; } if (k >= 8) { return; } Iterator iterator1 = set.iterator(); while (iterator1.hasNext()) { EnumDirection enumdirection1 = (EnumDirection) iterator1.next(); BlockFromToEvent event = new BlockFromToEvent(source, CraftBlock.notchToBlockFace(enumdirection1)); if (server != null) { server.getPluginManager().callEvent(event); } if (!event.isCancelled()) { flow( world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k); } } } }
// CraftBukkit start - add method public InventoryHolder getOwner() { org.bukkit.block.BlockState state = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(); if (state instanceof InventoryHolder) return (InventoryHolder) state; return null; }
protected boolean j(double d0, double d1, double d2) { BlockPosition blockposition = new BlockPosition(d0, d1, d2); double d3 = d0 - (double) blockposition.getX(); double d4 = d1 - (double) blockposition.getY(); double d5 = d2 - (double) blockposition.getZ(); List list = this.world.a(this.getBoundingBox()); if (list.isEmpty() && !this.world.u(blockposition)) { return false; } else { byte b0 = 3; double d6 = 9999.0D; if (!this.world.u(blockposition.west()) && d3 < d6) { d6 = d3; b0 = 0; } if (!this.world.u(blockposition.east()) && 1.0D - d3 < d6) { d6 = 1.0D - d3; b0 = 1; } if (!this.world.u(blockposition.up()) && 1.0D - d4 < d6) { d6 = 1.0D - d4; b0 = 3; } if (!this.world.u(blockposition.north()) && d5 < d6) { d6 = d5; b0 = 4; } if (!this.world.u(blockposition.south()) && 1.0D - d5 < d6) { d6 = 1.0D - d5; b0 = 5; } float f = this.random.nextFloat() * 0.2F + 0.1F; if (b0 == 0) { this.motX = (double) (-f); } if (b0 == 1) { this.motX = (double) f; } if (b0 == 3) { this.motY = (double) f; } if (b0 == 4) { this.motZ = (double) (-f); } if (b0 == 5) { this.motZ = (double) f; } return true; } }
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { ItemBucket itembucket = (ItemBucket) itemstack.getItem(); BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f())); // CraftBukkit start World world = isourceblock.i(); int x = blockposition.getX(); int y = blockposition.getY(); int z = blockposition.getZ(); if (world.isEmpty(blockposition) || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) { org.bukkit.block.Block block = world .getWorld() .getBlockAt( isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); if (!BlockDispenser.eventFired) { world.getServer().getPluginManager().callEvent(event); } if (event.isCancelled()) { return itemstack; } if (!event.getItem().equals(craftItem)) { // Chain to handler for new item ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.M.get(eventStack.getItem()); if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { idispensebehavior.a(isourceblock, eventStack); return itemstack; } } itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); } // CraftBukkit end if (itembucket.a(isourceblock.i(), blockposition)) { // CraftBukkit start - Handle stacked buckets Item item = Items.BUCKET; if (--itemstack.count == 0) { itemstack.setItem(Items.BUCKET); itemstack.count = 1; } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { this.b.a(isourceblock, new ItemStack(item)); } // CraftBukkit end return itemstack; } else { return this.b.a(isourceblock, itemstack); } }
public boolean placeItem( EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { // CraftBukkit start - handle all block place event logic here int data = this.getData(); int count = this.count; if (!(this.getItem() instanceof ItemBucket)) { // if not bucket world.captureBlockStates = true; // special case bonemeal if (this.getItem() instanceof ItemDye && this.getData() == 15) { Block block = world.getType(blockposition).getBlock(); if (block == Blocks.SAPLING || block instanceof BlockMushroom) { world.captureTreeGeneration = true; } } } boolean flag = this.getItem() .interactWith(this, entityhuman, world, blockposition, enumdirection, f, f1, f2); int newData = this.getData(); int newCount = this.count; this.count = count; this.setData(data); world.captureBlockStates = false; if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { world.captureTreeGeneration = false; Location location = new Location( world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); TreeType treeType = BlockSapling.treeType; BlockSapling.treeType = null; List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); world.capturedBlockStates.clear(); StructureGrowEvent event = null; if (treeType != null) { event = new StructureGrowEvent( location, treeType, false, (Player) entityhuman.getBukkitEntity(), blocks); org.bukkit.Bukkit.getPluginManager().callEvent(event); } if (event == null || !event.isCancelled()) { // Change the stack to its new contents if it hasn't been tampered with. if (this.count == count && this.getData() == data) { this.setData(newData); this.count = newCount; } for (BlockState blockstate : blocks) { blockstate.update(true); } } return flag; } world.captureTreeGeneration = false; if (flag) { org.bukkit.event.block.BlockPlaceEvent placeEvent = null; List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); world.capturedBlockStates.clear(); if (blocks.size() > 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent( world, entityhuman, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); } else if (blocks.size() == 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent( world, entityhuman, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); } if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { flag = false; // cancel placement // revert back all captured blocks for (BlockState blockstate : blocks) { blockstate.update(true, false); } } else { // Change the stack to its new contents if it hasn't been tampered with. if (this.count == count && this.getData() == data) { this.setData(newData); this.count = newCount; } for (BlockState blockstate : blocks) { int x = blockstate.getX(); int y = blockstate.getY(); int z = blockstate.getZ(); int updateFlag = ((CraftBlockState) blockstate).getFlag(); org.bukkit.Material mat = blockstate.getType(); Block oldBlock = CraftMagicNumbers.getBlock(mat); BlockPosition newblockposition = new BlockPosition(x, y, z); IBlockData block = world.getType(newblockposition); if (!(block instanceof BlockContainer)) { // Containers get placed automatically block.getBlock().onPlace(world, newblockposition, block); } world.notifyAndUpdatePhysics( newblockposition, null, oldBlock, block.getBlock(), updateFlag); // send null chunk as chunk.k() returns false by this point } entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]); } } world.capturedBlockStates.clear(); // CraftBukkit end return flag; }
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 UseResult interactWith( ItemStack var1, EntityHuman var2, World var3, BlockPosition var4, EnumUsedHand var5, EnumDirection var6, float var7, float var8, float var9) { if (var6 == EnumDirection.DOWN) { return UseResult.CANT_USE; } else { boolean var10 = var3.getType(var4).getBlock().isReplaceable(var3, var4); BlockPosition var11 = var10 ? var4 : var4.shift(var6); if (!var2.a(var11, var6, var1)) { return UseResult.CANT_USE; } else { BlockPosition var12 = var11.up(); boolean var13 = !var3.isEmpty(var11) && !var3.getType(var11).getBlock().isReplaceable(var3, var11); var13 |= !var3.isEmpty(var12) && !var3.getType(var12).getBlock().isReplaceable(var3, var12); if (var13) { return UseResult.CANT_USE; } else { double var14 = (double) var11.getX(); double var16 = (double) var11.getY(); double var18 = (double) var11.getZ(); List var20 = var3.getEntities( (Entity) null, (AxisAlignedBB) AxisAlignedBB.a( var14, var16, var18, var14 + 1.0D, var16 + 2.0D, var18 + 1.0D)); if (!var20.isEmpty()) { return UseResult.CANT_USE; } else { if (!var3.isClientSide) { var3.setAir(var11); var3.setAir(var12); EntityArmorStand var21 = new EntityArmorStand(var3, var14 + 0.5D, var16, var18 + 0.5D); float var22 = (float) MathHelper.floor( (MathHelper.clampAngle(var2.yaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; var21.setPositionRotation(var14 + 0.5D, var16, var18 + 0.5D, var22, 0.0F); this.a(var21, var3.random); NBTTagCompound var23 = var1.getTag(); if (var23 != null && var23.hasOfType("EntityTag", 10)) { NBTTagCompound var24 = new NBTTagCompound(); var21.d(var24); var24.copyFrom(var23.getCompound("EntityTag")); var21.f(var24); } var3.addEntity((Entity) var21); } --var1.count; return UseResult.SUCCESS; } } } } }
private void f(World world, BlockPosition blockposition) { ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection; int i; int j; if ((shapedetector_shapedetectorcollection = this.getDetectorSnowGolem().a(world, blockposition)) != null) { BlockStateListPopulator blockList = new BlockStateListPopulator( world.getWorld()); // CraftBukkit - Use BlockStateListPopulator for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) { ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0); // CraftBukkit start // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2); BlockPosition pos = shapedetectorblock.getPosition(); blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0); // CraftBukkit end } EntitySnowman entitysnowman = new EntitySnowman(world); BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition(); entitysnowman.setPositionRotation( (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); // CraftBukkit start if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { blockList.updateList(); for (j = 0; j < 120; ++j) { world.addParticle( EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (j = 0; j < this.getDetectorSnowGolem().b(); ++j) { ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, j, 0); world.update(shapedetectorblock1.getPosition(), Blocks.AIR); } } // CraftBukkit end } else if ((shapedetector_shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition)) != null) { BlockStateListPopulator blockList = new BlockStateListPopulator( world.getWorld()); // CraftBukkit - Use BlockStateListPopulator for (i = 0; i < this.getDetectorIronGolem().c(); ++i) { for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) { // CraftBukkit start // world.setTypeAndData(shapedetectorcollection.a(i, k, 0).d(), Blocks.AIR.getBlockData(), // 2); BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(); blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0); // CraftBukkit end } } BlockPosition blockposition2 = shapedetector_shapedetectorcollection.a(1, 2, 0).getPosition(); EntityIronGolem entityirongolem = new EntityIronGolem(world); entityirongolem.setPlayerCreated(true); entityirongolem.setPositionRotation( (double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); // CraftBukkit start if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { blockList.updateList(); for (j = 0; j < 120; ++j) { world.addParticle( EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (j = 0; j < this.getDetectorIronGolem().c(); ++j) { for (int l = 0; l < this.getDetectorIronGolem().b(); ++l) { ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(j, l, 0); world.update(shapedetectorblock2.getPosition(), Blocks.AIR); } } } // CraftBukkit end } }
public boolean generate(World var1, Random var2, BlockPosition var3) { if (this.a == null) { this.a = var2.nextBoolean() ? Blocks.BROWN_MUSHROOM_BLOCK : Blocks.RED_MUSHROOM_BLOCK; } int var4 = var2.nextInt(3) + 4; boolean var5 = true; if (var3.getY() >= 1 && var3.getY() + var4 + 1 < 256) { int var9; int var10; for (int var6 = var3.getY(); var6 <= var3.getY() + 1 + var4; ++var6) { byte var7 = 3; if (var6 <= var3.getY() + 3) { var7 = 0; } BlockPosition.MutableBlockPosition var8 = new BlockPosition.MutableBlockPosition(); for (var9 = var3.getX() - var7; var9 <= var3.getX() + var7 && var5; ++var9) { for (var10 = var3.getZ() - var7; var10 <= var3.getZ() + var7 && var5; ++var10) { if (var6 >= 0 && var6 < 256) { Block var11 = var1.getType(var8.setPosition(var9, var6, var10)).getBlock(); if (var11.getMaterial() != Material.AIR && var11.getMaterial() != Material.LEAVES) { var5 = false; } } else { var5 = false; } } } } if (!var5) { return false; } else { Block var19 = var1.getType(var3.down()).getBlock(); if (var19 != Blocks.DIRT && var19 != Blocks.GRASS && var19 != Blocks.MYCELIM) { return false; } else { int var20 = var3.getY() + var4; if (this.a == Blocks.RED_MUSHROOM_BLOCK) { var20 = var3.getY() + var4 - 3; } int var21; for (var21 = var20; var21 <= var3.getY() + var4; ++var21) { var9 = 1; if (var21 < var3.getY() + var4) { ++var9; } if (this.a == Blocks.BROWN_MUSHROOM_BLOCK) { var9 = 3; } var10 = var3.getX() - var9; int var23 = var3.getX() + var9; int var12 = var3.getZ() - var9; int var13 = var3.getZ() + var9; for (int var14 = var10; var14 <= var23; ++var14) { for (int var15 = var12; var15 <= var13; ++var15) { int var16 = 5; if (var14 == var10) { --var16; } else if (var14 == var23) { ++var16; } if (var15 == var12) { var16 -= 3; } else if (var15 == var13) { var16 += 3; } BlockHugeMushroom.class_a_in_class_aiw var17 = BlockHugeMushroom.class_a_in_class_aiw.a(var16); if (this.a == Blocks.BROWN_MUSHROOM_BLOCK || var21 < var3.getY() + var4) { if ((var14 == var10 || var14 == var23) && (var15 == var12 || var15 == var13)) { continue; } if (var14 == var3.getX() - (var9 - 1) && var15 == var12) { var17 = BlockHugeMushroom.class_a_in_class_aiw.a; } if (var14 == var10 && var15 == var3.getZ() - (var9 - 1)) { var17 = BlockHugeMushroom.class_a_in_class_aiw.a; } if (var14 == var3.getX() + (var9 - 1) && var15 == var12) { var17 = BlockHugeMushroom.class_a_in_class_aiw.c; } if (var14 == var23 && var15 == var3.getZ() - (var9 - 1)) { var17 = BlockHugeMushroom.class_a_in_class_aiw.c; } if (var14 == var3.getX() - (var9 - 1) && var15 == var13) { var17 = BlockHugeMushroom.class_a_in_class_aiw.g; } if (var14 == var10 && var15 == var3.getZ() + (var9 - 1)) { var17 = BlockHugeMushroom.class_a_in_class_aiw.g; } if (var14 == var3.getX() + (var9 - 1) && var15 == var13) { var17 = BlockHugeMushroom.class_a_in_class_aiw.i; } if (var14 == var23 && var15 == var3.getZ() + (var9 - 1)) { var17 = BlockHugeMushroom.class_a_in_class_aiw.i; } } if (var17 == BlockHugeMushroom.class_a_in_class_aiw.e && var21 < var3.getY() + var4) { var17 = BlockHugeMushroom.class_a_in_class_aiw.k; } if (var3.getY() >= var3.getY() + var4 - 1 || var17 != BlockHugeMushroom.class_a_in_class_aiw.k) { BlockPosition var18 = new BlockPosition(var14, var21, var15); if (!var1.getType(var18).getBlock().isFullBlock()) { this.setTypeAndData( var1, var18, this.a.getBlockData().set(BlockHugeMushroom.a, var17)); } } } } } for (var21 = 0; var21 < var4; ++var21) { Block var22 = var1.getType(var3.up(var21)).getBlock(); if (!var22.isFullBlock()) { this.setTypeAndData( var1, var3.up(var21), this.a .getBlockData() .set(BlockHugeMushroom.a, BlockHugeMushroom.class_a_in_class_aiw.j)); } } return true; } } } else { return false; } }
public void a(boolean flag) { this.world.makeSound( this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F); if (this.size >= 2.0F && this.b) { this.world.addParticle( EnumParticle.EXPLOSION_HUGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]); } else { this.world.addParticle( EnumParticle.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]); } Iterator iterator; BlockPosition blockposition; if (this.b) { // CraftBukkit start org.bukkit.World bworld = this.world.getWorld(); org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); Location location = new Location(bworld, this.posX, this.posY, this.posZ); List<org.bukkit.block.Block> blockList = Lists.newArrayList(); for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) { BlockPosition cpos = (BlockPosition) this.blocks.get(i1); org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); if (bblock.getType() != org.bukkit.Material.AIR) { blockList.add(bblock); } } boolean cancelled; List<org.bukkit.block.Block> bukkitBlocks; float yield; if (explode != null) { EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F); this.world.getServer().getPluginManager().callEvent(event); cancelled = event.isCancelled(); bukkitBlocks = event.blockList(); yield = event.getYield(); } else { BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, 0.3F); this.world.getServer().getPluginManager().callEvent(event); cancelled = event.isCancelled(); bukkitBlocks = event.blockList(); yield = event.getYield(); } this.blocks.clear(); for (org.bukkit.block.Block bblock : bukkitBlocks) { BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ()); blocks.add(coords); } if (cancelled) { this.wasCanceled = true; return; } // CraftBukkit end iterator = this.blocks.iterator(); while (iterator.hasNext()) { blockposition = (BlockPosition) iterator.next(); Block block = this.world.getType(blockposition).getBlock(); world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, blockposition); // Spigot if (flag) { double d0 = (double) ((float) blockposition.getX() + this.world.random.nextFloat()); double d1 = (double) ((float) blockposition.getY() + this.world.random.nextFloat()); double d2 = (double) ((float) blockposition.getZ() + this.world.random.nextFloat()); double d3 = d0 - this.posX; double d4 = d1 - this.posY; double d5 = d2 - this.posZ; double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); d3 /= d6; d4 /= d6; d5 /= d6; double d7 = 0.5D / (d6 / (double) this.size + 0.1D); d7 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F); d3 *= d7; d4 *= d7; d5 *= d7; this.world.addParticle( EnumParticle.EXPLOSION_NORMAL, (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5, new int[0]); this.world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]); } if (block.getMaterial() != Material.AIR) { if (block.a(this)) { // CraftBukkit - add yield block.dropNaturally( this.world, blockposition, this.world.getType(blockposition), yield, 0); } this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); block.wasExploded(this.world, blockposition, this); } } } if (this.a) { iterator = this.blocks.iterator(); while (iterator.hasNext()) { blockposition = (BlockPosition) iterator.next(); if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && this.world.getType(blockposition.down()).getBlock().o() && this.c.nextInt(3) == 0) { // CraftBukkit start - Ignition by explosion if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent( this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this) .isCancelled()) { this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); } // CraftBukkit end } } } }