public boolean func_73084_b(int p_73084_1_, int p_73084_2_, int p_73084_3_) { if(this.field_73091_c.func_82752_c() && !this.field_73090_b.func_82246_f(p_73084_1_, p_73084_2_, p_73084_3_)) { return false; } else if(this.field_73091_c.func_77145_d() && this.field_73090_b.func_70694_bm() != null && this.field_73090_b.func_70694_bm().func_77973_b() instanceof ItemSword) { return false; } else { int var4 = this.field_73092_a.func_72798_a(p_73084_1_, p_73084_2_, p_73084_3_); int var5 = this.field_73092_a.func_72805_g(p_73084_1_, p_73084_2_, p_73084_3_); this.field_73092_a.func_72889_a(this.field_73090_b, 2001, p_73084_1_, p_73084_2_, p_73084_3_, var4 + (this.field_73092_a.func_72805_g(p_73084_1_, p_73084_2_, p_73084_3_) << 12)); boolean var6 = this.func_73079_d(p_73084_1_, p_73084_2_, p_73084_3_); if(this.func_73083_d()) { this.field_73090_b.field_71135_a.func_72567_b(new Packet53BlockChange(p_73084_1_, p_73084_2_, p_73084_3_, this.field_73092_a)); } else { ItemStack var7 = this.field_73090_b.func_71045_bC(); boolean var8 = this.field_73090_b.func_71062_b(Block.field_71973_m[var4]); if(var7 != null) { var7.func_77941_a(this.field_73092_a, var4, p_73084_1_, p_73084_2_, p_73084_3_, this.field_73090_b); if(var7.field_77994_a == 0) { this.field_73090_b.func_71028_bD(); } } if(var6 && var8) { Block.field_71973_m[var4].func_71893_a(this.field_73092_a, this.field_73090_b, p_73084_1_, p_73084_2_, p_73084_3_, var5); } } return var6; } }
@Override public void handleBlockChange(Packet53BlockChange par1Packet53BlockChange) { nch.handleBlockChange(par1Packet53BlockChange); }
public void func_72456_a(Packet53BlockChange p_72456_1_) { this.func_72509_a(p_72456_1_); }
public void func_72510_a(Packet14BlockDig p_72510_1_) { WorldServer var2 = this.field_72573_d.func_71218_a(this.field_72574_e.field_71093_bK); this.field_72574_e.func_143004_u(); if(p_72510_1_.field_73342_e == 4) { this.field_72574_e.func_71040_bB(false); } else if(p_72510_1_.field_73342_e == 3) { this.field_72574_e.func_71040_bB(true); } else if(p_72510_1_.field_73342_e == 5) { this.field_72574_e.func_71034_by(); } else { boolean var3 = false; if(p_72510_1_.field_73342_e == 0) { var3 = true; } if(p_72510_1_.field_73342_e == 1) { var3 = true; } if(p_72510_1_.field_73342_e == 2) { var3 = true; } int var4 = p_72510_1_.field_73345_a; int var5 = p_72510_1_.field_73343_b; int var6 = p_72510_1_.field_73344_c; if(var3) { double var7 = this.field_72574_e.field_70165_t - ((double)var4 + 0.5D); double var9 = this.field_72574_e.field_70163_u - ((double)var5 + 0.5D) + 1.5D; double var11 = this.field_72574_e.field_70161_v - ((double)var6 + 0.5D); double var13 = var7 * var7 + var9 * var9 + var11 * var11; if(var13 > 36.0D) { return; } if(var5 >= this.field_72573_d.func_71207_Z()) { return; } } if(p_72510_1_.field_73342_e == 0) { if(!this.field_72573_d.func_96290_a(var2, var4, var5, var6, this.field_72574_e)) { this.field_72574_e.field_71134_c.func_73074_a(var4, var5, var6, p_72510_1_.field_73341_d); } else { this.field_72574_e.field_71135_a.func_72567_b(new Packet53BlockChange(var4, var5, var6, var2)); } } else if(p_72510_1_.field_73342_e == 2) { this.field_72574_e.field_71134_c.func_73082_a(var4, var5, var6); if(var2.func_72798_a(var4, var5, var6) != 0) { this.field_72574_e.field_71135_a.func_72567_b(new Packet53BlockChange(var4, var5, var6, var2)); } } else if(p_72510_1_.field_73342_e == 1) { this.field_72574_e.field_71134_c.func_73073_c(var4, var5, var6); if(var2.func_72798_a(var4, var5, var6) != 0) { this.field_72574_e.field_71135_a.func_72567_b(new Packet53BlockChange(var4, var5, var6, var2)); } } } }
public void func_72472_a(Packet15Place p_72472_1_) { WorldServer var2 = this.field_72573_d.func_71218_a(this.field_72574_e.field_71093_bK); ItemStack var3 = this.field_72574_e.field_71071_by.func_70448_g(); boolean var4 = false; int var5 = p_72472_1_.func_73403_d(); int var6 = p_72472_1_.func_73402_f(); int var7 = p_72472_1_.func_73407_g(); int var8 = p_72472_1_.func_73401_h(); this.field_72574_e.func_143004_u(); if(p_72472_1_.func_73401_h() == 255) { if(var3 == null) { return; } this.field_72574_e.field_71134_c.func_73085_a(this.field_72574_e, var2, var3); } else if(p_72472_1_.func_73402_f() >= this.field_72573_d.func_71207_Z() - 1 && (p_72472_1_.func_73401_h() == 1 || p_72472_1_.func_73402_f() >= this.field_72573_d.func_71207_Z())) { this.field_72574_e.field_71135_a.func_72567_b(new Packet3Chat(ChatMessageComponent.func_111082_b("build.tooHigh", new Object[]{Integer.valueOf(this.field_72573_d.func_71207_Z())}).func_111059_a(EnumChatFormatting.RED))); var4 = true; } else { if(this.field_72587_r && this.field_72574_e.func_70092_e((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < 64.0D && !this.field_72573_d.func_96290_a(var2, var5, var6, var7, this.field_72574_e)) { this.field_72574_e.field_71134_c.func_73078_a(this.field_72574_e, var2, var3, var5, var6, var7, var8, p_72472_1_.func_73406_j(), p_72472_1_.func_73404_l(), p_72472_1_.func_73408_m()); } var4 = true; } if(var4) { this.field_72574_e.field_71135_a.func_72567_b(new Packet53BlockChange(var5, var6, var7, var2)); if(var8 == 0) { --var6; } if(var8 == 1) { ++var6; } if(var8 == 2) { --var7; } if(var8 == 3) { ++var7; } if(var8 == 4) { --var5; } if(var8 == 5) { ++var5; } this.field_72574_e.field_71135_a.func_72567_b(new Packet53BlockChange(var5, var6, var7, var2)); } var3 = this.field_72574_e.field_71071_by.func_70448_g(); if(var3 != null && var3.field_77994_a == 0) { this.field_72574_e.field_71071_by.field_70462_a[this.field_72574_e.field_71071_by.field_70461_c] = null; var3 = null; } if(var3 == null || var3.func_77988_m() == 0) { this.field_72574_e.field_71137_h = true; this.field_72574_e.field_71071_by.field_70462_a[this.field_72574_e.field_71071_by.field_70461_c] = ItemStack.func_77944_b(this.field_72574_e.field_71071_by.field_70462_a[this.field_72574_e.field_71071_by.field_70461_c]); Slot var9 = this.field_72574_e.field_71070_bA.func_75147_a(this.field_72574_e.field_71071_by, this.field_72574_e.field_71071_by.field_70461_c); this.field_72574_e.field_71070_bA.func_75142_b(); this.field_72574_e.field_71137_h = false; if(!ItemStack.func_77989_b(this.field_72574_e.field_71071_by.func_70448_g(), p_72472_1_.func_73405_i())) { this.func_72567_b(new Packet103SetSlot(this.field_72574_e.field_71070_bA.field_75152_c, var9.field_75222_d, this.field_72574_e.field_71071_by.func_70448_g())); } } }
public void func_72456_a(Packet53BlockChange p_72456_1_) { this.field_72564_i.func_73023_g(p_72456_1_.field_73425_a, p_72456_1_.field_73423_b, p_72456_1_.field_73424_c, p_72456_1_.field_73421_d, p_72456_1_.field_73422_e); }
public void func_73254_a() { if(this.field_73262_e != 0) { int var1; int var2; int var3; if(this.field_73262_e == 1) { var1 = this.field_73264_c.field_77276_a * 16 + (this.field_73261_d[0] >> 12 & 15); var2 = this.field_73261_d[0] & 255; var3 = this.field_73264_c.field_77275_b * 16 + (this.field_73261_d[0] >> 8 & 15); this.func_73256_a(new Packet53BlockChange(var1, var2, var3, PlayerManager.func_72692_a(this.field_73265_a))); if(PlayerManager.func_72692_a(this.field_73265_a).func_72927_d(var1, var2, var3)) { this.func_73257_a(PlayerManager.func_72692_a(this.field_73265_a).func_72796_p(var1, var2, var3)); } } else { int var4; if(this.field_73262_e == 64) { var1 = this.field_73264_c.field_77276_a * 16; var2 = this.field_73264_c.field_77275_b * 16; this.func_73256_a(new Packet51MapChunk(PlayerManager.func_72692_a(this.field_73265_a).func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b), false, this.field_73260_f)); for(var3 = 0; var3 < 16; ++var3) { if((this.field_73260_f & 1 << var3) != 0) { var4 = var3 << 4; List var5 = PlayerManager.func_72692_a(this.field_73265_a).func_73049_a(var1, var4, var2, var1 + 16, var4 + 16, var2 + 16); for(int var6 = 0; var6 < var5.size(); ++var6) { this.func_73257_a((TileEntity)var5.get(var6)); } } } } else { this.func_73256_a(new Packet52MultiBlockChange(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b, this.field_73261_d, this.field_73262_e, PlayerManager.func_72692_a(this.field_73265_a))); for(var1 = 0; var1 < this.field_73262_e; ++var1) { var2 = this.field_73264_c.field_77276_a * 16 + (this.field_73261_d[var1] >> 12 & 15); var3 = this.field_73261_d[var1] & 255; var4 = this.field_73264_c.field_77275_b * 16 + (this.field_73261_d[var1] >> 8 & 15); if(PlayerManager.func_72692_a(this.field_73265_a).func_72927_d(var2, var3, var4)) { this.func_73257_a(PlayerManager.func_72692_a(this.field_73265_a).func_72796_p(var2, var3, var4)); } } } } this.field_73262_e = 0; this.field_73260_f = 0; } }
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, EnumGameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z) { // Logic from tryHarvestBlock for pre-canceling the event boolean preCancelEvent = false; if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z)) { preCancelEvent = true; } else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword) { preCancelEvent = true; } // Tell client the block is gone immediately then process events if (world.getBlockTileEntity(x, y, z) == null) { Packet53BlockChange packet = new Packet53BlockChange(x, y, z, world); packet.type = 0; packet.metadata = 0; entityPlayer.playerNetServerHandler.sendPacketToPlayer(packet); } // Post the block break event Block block = Block.blocksList[world.getBlockId(x, y, z)]; int blockMetadata = world.getBlockMetadata(x, y, z); BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer); event.setCanceled(preCancelEvent); MinecraftForge.EVENT_BUS.post(event); // Handle if the event is canceled if (event.isCanceled()) { // Let the client know the block still exists entityPlayer.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(x, y, z, world)); // Update any tile entity data for this block TileEntity tileentity = world.getBlockTileEntity(x, y, z); if (tileentity != null) { Packet pkt = tileentity.getDescriptionPacket(); if (pkt != null) { entityPlayer.playerNetServerHandler.sendPacketToPlayer(pkt); } } } return event; }
/** * if not creative, it calls destroyBlockInWorldPartially untill the block is broken first. par4 is the specific * side. tryHarvestBlock can also be the result of this call */ public void onBlockClicked(int par1, int par2, int par3, int par4) { if (!this.gameType.isAdventure() || this.thisPlayerMP.isCurrentToolAdventureModeExempt(par1, par2, par3)) { PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(thisPlayerMP, Action.LEFT_CLICK_BLOCK, par1, par2, par3, par4); if (event.isCanceled()) { thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par1, par2, par3, theWorld)); return; } if (this.isCreative()) { if (!this.theWorld.extinguishFire((EntityPlayer)null, par1, par2, par3, par4)) { this.tryHarvestBlock(par1, par2, par3); } } else { this.initialDamage = this.curblockDamage; float f = 1.0F; int i1 = this.theWorld.getBlockId(par1, par2, par3); Block block = Block.blocksList[i1]; if (block != null) { if (event.useBlock != Event.Result.DENY) { block.onBlockClicked(theWorld, par1, par2, par3, thisPlayerMP); theWorld.extinguishFire(thisPlayerMP, par1, par2, par3, par4); } else { thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par1, par2, par3, theWorld)); } f = block.getPlayerRelativeBlockHardness(thisPlayerMP, thisPlayerMP.worldObj, par1, par2, par3); } if (event.useItem == Event.Result.DENY) { if (f >= 1.0f) { thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par1, par2, par3, theWorld)); } return; } if (i1 > 0 && f >= 1.0F) { this.tryHarvestBlock(par1, par2, par3); } else { this.isDestroyingBlock = true; this.partiallyDestroyedBlockX = par1; this.partiallyDestroyedBlockY = par2; this.partiallyDestroyedBlockZ = par3; int j1 = (int)(f * 10.0F); this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.entityId, par1, par2, par3, j1); this.durabilityRemainingOnBlock = j1; } } } }
/** * Attempts to harvest a block at the given coordinate */ public boolean tryHarvestBlock(int par1, int par2, int par3) { BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(theWorld, gameType, thisPlayerMP, par1, par2, par3); if (event.isCanceled()) { return false; } else { ItemStack stack = thisPlayerMP.getCurrentEquippedItem(); if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, thisPlayerMP)) { return false; } int l = this.theWorld.getBlockId(par1, par2, par3); int i1 = this.theWorld.getBlockMetadata(par1, par2, par3); this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, par1, par2, par3, l + (this.theWorld.getBlockMetadata(par1, par2, par3) << 12)); boolean flag = false; if (this.isCreative()) { flag = this.removeBlock(par1, par2, par3); this.thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par1, par2, par3, this.theWorld)); } else { ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem(); boolean flag1 = false; Block block = Block.blocksList[l]; if (block != null) { flag1 = block.canHarvestBlock(thisPlayerMP, i1); } if (itemstack != null) { itemstack.onBlockDestroyed(this.theWorld, l, par1, par2, par3, this.thisPlayerMP); if (itemstack.stackSize == 0) { this.thisPlayerMP.destroyCurrentEquippedItem(); } } flag = this.removeBlock(par1, par2, par3); if (flag && flag1) { Block.blocksList[l].harvestBlock(this.theWorld, this.thisPlayerMP, par1, par2, par3, i1); } } // Drop experience if (!this.isCreative() && flag && event != null) { Block.blocksList[l].dropXpOnBlockBreak(this.theWorld, par1, par2, par3, event.getExpToDrop()); } return flag; } }
/** * Activate the clicked on block, otherwise use the held item. Args: player, world, itemStack, x, y, z, side, * xOffset, yOffset, zOffset */ public boolean activateBlockOrUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(par1EntityPlayer, Action.RIGHT_CLICK_BLOCK, par4, par5, par6, par7); if (event.isCanceled()) { thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par4, par5, par6, theWorld)); return false; } Item item = (par3ItemStack != null ? par3ItemStack.getItem() : null); if (item != null && item.onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10)) { if (par3ItemStack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, par3ItemStack); return true; } int i1 = par2World.getBlockId(par4, par5, par6); Block block = Block.blocksList[i1]; boolean result = false; if (block != null && (!par1EntityPlayer.isSneaking() || ( par1EntityPlayer.getHeldItem() == null || par1EntityPlayer.getHeldItem().getItem().shouldPassSneakingClickToBlock(par2World, par4, par5, par6)))) { if (event.useBlock != Event.Result.DENY) { result = block.onBlockActivated(par2World, par4, par5, par6, par1EntityPlayer, par7, par8, par9, par10); } else { thisPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange(par4, par5, par6, theWorld)); result = event.useItem != Event.Result.ALLOW; } } if (par3ItemStack != null && !result && event.useItem != Event.Result.DENY) { int meta = par3ItemStack.getItemDamage(); int size = par3ItemStack.stackSize; result = par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10); if (isCreative()) { par3ItemStack.setItemDamage(meta); par3ItemStack.stackSize = size; } if (par3ItemStack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, par3ItemStack); } /* Re-enable if this causes bukkit incompatibility, or re-write client side to only send a single packet per right click. if (par3ItemStack != null && ((!result && event.useItem != Event.Result.DENY) || event.useItem == Event.Result.ALLOW)) { this.tryUseItem(thisPlayerMP, par2World, par3ItemStack); }*/ return result; }
public void handleBlockChange(Packet53BlockChange par1Packet53BlockChange) { this.worldClient.setBlockAndMetadataAndInvalidate(par1Packet53BlockChange.xPosition, par1Packet53BlockChange.yPosition, par1Packet53BlockChange.zPosition, par1Packet53BlockChange.type, par1Packet53BlockChange.metadata); }
public void sendChunkUpdate() { if (this.numberOfTilesToUpdate != 0) { int i; int j; int k; if (this.numberOfTilesToUpdate == 1) { i = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[0] >> 12 & 15); j = this.locationOfBlockChange[0] & 255; k = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[0] >> 8 & 15); this.sendToAllPlayersWatchingChunk(new Packet53BlockChange(i, j, k, PlayerManager.getWorldServer(this.thePlayerManager))); if (PlayerManager.getWorldServer(this.thePlayerManager).blockHasTileEntity(i, j, k)) { this.sendTileToAllPlayersWatchingChunk(PlayerManager.getWorldServer(this.thePlayerManager).getBlockTileEntity(i, j, k)); } } else { int l; if (this.numberOfTilesToUpdate >= ForgeDummyContainer.clumpingThreshold) { i = this.chunkLocation.chunkXPos * 16; j = this.chunkLocation.chunkZPos * 16; this.sendToAllPlayersWatchingChunk(new Packet51MapChunk(PlayerManager.getWorldServer(this.thePlayerManager).getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), false, this.flagsYAreasToUpdate)); /* Forge: Grabs ALL tile entities is costly on a modded server, only send needed ones for (k = 0; k < 16; ++k) { if ((this.flagsYAreasToUpdate & 1 << k) != 0) { l = k << 4; List list = PlayerManager.getWorldServer(this.thePlayerManager).getAllTileEntityInBox(i, l, j, i + 16, l + 16, j + 16); for (int i1 = 0; i1 < list.size(); ++i1) { this.sendTileToAllPlayersWatchingChunk((TileEntity)list.get(i1)); } } } */ } else { this.sendToAllPlayersWatchingChunk(new Packet52MultiBlockChange(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos, this.locationOfBlockChange, this.numberOfTilesToUpdate, PlayerManager.getWorldServer(this.thePlayerManager))); } { //Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small for (i = 0; i < this.numberOfTilesToUpdate; ++i) { j = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[i] >> 12 & 15); k = this.locationOfBlockChange[i] & 255; l = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[i] >> 8 & 15); if (PlayerManager.getWorldServer(this.thePlayerManager).blockHasTileEntity(j, k, l)) { this.sendTileToAllPlayersWatchingChunk(PlayerManager.getWorldServer(this.thePlayerManager).getBlockTileEntity(j, k, l)); } } } } this.numberOfTilesToUpdate = 0; this.flagsYAreasToUpdate = 0; } }