public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload) { if ("MC|BEdit".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); ItemStack itemstack = Packet.readItemStack(datainputstream); if (!ItemWritableBook.validBookTagPages(itemstack.getTagCompound())) { throw new IOException("Invalid book tag!"); } ItemStack itemstack2 = playerEntity.inventory.getCurrentItem(); if (itemstack != null && itemstack.itemID == Item.writableBook.shiftedIndex && itemstack.itemID == itemstack2.itemID) { itemstack2.setTagCompound(itemstack.getTagCompound()); } } catch (Exception exception) { exception.printStackTrace(); } } else if ("MC|BSign".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream1 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); ItemStack itemstack1 = Packet.readItemStack(datainputstream1); if (!ItemEditableBook.validBookTagContents(itemstack1.getTagCompound())) { throw new IOException("Invalid book tag!"); } ItemStack itemstack3 = playerEntity.inventory.getCurrentItem(); if (itemstack1 != null && itemstack1.itemID == Item.writtenBook.shiftedIndex && itemstack3.itemID == Item.writableBook.shiftedIndex) { itemstack3.setTagCompound(itemstack1.getTagCompound()); itemstack3.itemID = Item.writtenBook.shiftedIndex; } } catch (Exception exception1) { exception1.printStackTrace(); } } else if ("MC|TrSel".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); int i = datainputstream2.readInt(); Container container = playerEntity.craftingInventory; if (container instanceof ContainerMerchant) { ((ContainerMerchant) container).setCurrentRecipeIndex(i); } } catch (Exception exception2) { exception2.printStackTrace(); } } else { ModLoader.serverCustomPayload(this, par1Packet250CustomPayload); } }
public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload) { DataInputStream var2; ItemStack var3; ItemStack var4; if ("MC|BEdit".equals(par1Packet250CustomPayload.channel)) { try { var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); var3 = Packet.readItemStack(var2); if (!ItemWritableBook.validBookTagPages(var3.getTagCompound())) { throw new IOException("Invalid book tag!"); } var4 = this.playerEntity.inventory.getCurrentItem(); if (var3 != null && var3.itemID == Item.writableBook.shiftedIndex && var3.itemID == var4.itemID) { var4.setTagCompound(var3.getTagCompound()); } } catch (Exception var7) { var7.printStackTrace(); } } else if ("MC|BSign".equals(par1Packet250CustomPayload.channel)) { try { var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); var3 = Packet.readItemStack(var2); if (!ItemEditableBook.validBookTagContents(var3.getTagCompound())) { throw new IOException("Invalid book tag!"); } var4 = this.playerEntity.inventory.getCurrentItem(); if (var3 != null && var3.itemID == Item.field_77823_bG.shiftedIndex && var4.itemID == Item.writableBook.shiftedIndex) { var4.setTagCompound(var3.getTagCompound()); var4.itemID = Item.field_77823_bG.shiftedIndex; } } catch (Exception var6) { var6.printStackTrace(); } } else if ("MC|TrSel".equals(par1Packet250CustomPayload.channel)) { try { var2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); int var8 = var2.readInt(); Container var9 = this.playerEntity.craftingInventory; if (var9 instanceof ContainerMerchant) { ((ContainerMerchant) var9).func_75175_c(var8); } } catch (Exception var5) { var5.printStackTrace(); } } }
public void func_82813_b(ItemStack par1ItemStack, int par2) { if (this.material != EnumArmorMaterial.CLOTH) { throw new UnsupportedOperationException("Can\'t dye non-leather!"); } else { NBTTagCompound var3 = par1ItemStack.getTagCompound(); if (var3 == null) { var3 = new NBTTagCompound(); par1ItemStack.setTagCompound(var3); } NBTTagCompound var4 = var3.getCompoundTag("display"); if (!var3.hasKey("display")) { var3.setCompoundTag("display", var4); } var4.setInteger("color", par2); } }
/** ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { if (!par1World.isRemote) { if ((par6 & 8) == 0) { ItemStack var7 = new ItemStack( Item.skull.shiftedIndex, 1, this.getDamageValue(par1World, par2, par3, par4)); TileEntitySkull var8 = (TileEntitySkull) par1World.getBlockTileEntity(par2, par3, par4); if (var8.func_82117_a() == 3 && var8.func_82120_c() != null && var8.func_82120_c().length() > 0) { var7.setTagCompound(new NBTTagCompound()); var7.getTagCompound().setString("SkullOwner", var8.func_82120_c()); } this.dropBlockAsItem_do(par1World, par2, par3, par4, var7); } super.breakBlock(par1World, par2, par3, par4, par5, par6); } }
/** Updates the task */ public void updateTask() { EntityPlayer var1 = (EntityPlayer) this.thisEntity.riddenByEntity; EntityCreature var2 = (EntityCreature) this.thisEntity; float var3 = MathHelper.wrapAngleTo180_float(var1.rotationYaw - this.thisEntity.rotationYaw) * 0.5F; if (var3 > 5.0F) { var3 = 5.0F; } if (var3 < -5.0F) { var3 = -5.0F; } this.thisEntity.rotationYaw = MathHelper.wrapAngleTo180_float(this.thisEntity.rotationYaw + var3); if (this.currentSpeed < this.maxSpeed) { this.currentSpeed += (this.maxSpeed - this.currentSpeed) * 0.01F; } if (this.currentSpeed > this.maxSpeed) { this.currentSpeed = this.maxSpeed; } int var4 = MathHelper.floor_double(this.thisEntity.posX); int var5 = MathHelper.floor_double(this.thisEntity.posY); int var6 = MathHelper.floor_double(this.thisEntity.posZ); float var7 = this.currentSpeed; if (this.speedBoosted) { if (this.speedBoostTime++ > this.maxSpeedBoostTime) { this.speedBoosted = false; } var7 += var7 * 1.15F * MathHelper.sin( (float) this.speedBoostTime / (float) this.maxSpeedBoostTime * (float) Math.PI); } float var8 = 0.91F; if (this.thisEntity.onGround) { var8 = 0.54600006F; int var9 = this.thisEntity.worldObj.getBlockId( MathHelper.floor_float((float) var4), MathHelper.floor_float((float) var5) - 1, MathHelper.floor_float((float) var6)); if (var9 > 0) { var8 = Block.blocksList[var9].slipperiness * 0.91F; } } float var23 = 0.16277136F / (var8 * var8 * var8); float var10 = MathHelper.sin(var2.rotationYaw * (float) Math.PI / 180.0F); float var11 = MathHelper.cos(var2.rotationYaw * (float) Math.PI / 180.0F); float var12 = var2.getAIMoveSpeed() * var23; float var13 = Math.max(var7, 1.0F); var13 = var12 / var13; float var14 = var7 * var13; float var15 = -(var14 * var10); float var16 = var14 * var11; if (MathHelper.abs(var15) > MathHelper.abs(var16)) { if (var15 < 0.0F) { var15 -= this.thisEntity.width / 2.0F; } if (var15 > 0.0F) { var15 += this.thisEntity.width / 2.0F; } var16 = 0.0F; } else { var15 = 0.0F; if (var16 < 0.0F) { var16 -= this.thisEntity.width / 2.0F; } if (var16 > 0.0F) { var16 += this.thisEntity.width / 2.0F; } } int var17 = MathHelper.floor_double(this.thisEntity.posX + (double) var15); int var18 = MathHelper.floor_double(this.thisEntity.posZ + (double) var16); PathPoint var19 = new PathPoint( MathHelper.floor_float(this.thisEntity.width + 1.0F), MathHelper.floor_float(this.thisEntity.height + var1.height + 1.0F), MathHelper.floor_float(this.thisEntity.width + 1.0F)); if (var4 != var17 || var6 != var18) { int var20 = this.thisEntity.worldObj.getBlockId(var4, var5, var6); int var21 = this.thisEntity.worldObj.getBlockId(var4, var5 - 1, var6); boolean var22 = this.func_98216_b(var20) || Block.blocksList[var20] == null && this.func_98216_b(var21); if (!var22 && PathFinder.func_82565_a(this.thisEntity, var17, var5, var18, var19, false, false, true) == 0 && PathFinder.func_82565_a( this.thisEntity, var4, var5 + 1, var6, var19, false, false, true) == 1 && PathFinder.func_82565_a( this.thisEntity, var17, var5 + 1, var18, var19, false, false, true) == 1) { var2.getJumpHelper().setJumping(); } } if (!var1.capabilities.isCreativeMode && this.currentSpeed >= this.maxSpeed * 0.5F && this.thisEntity.getRNG().nextFloat() < 0.006F && !this.speedBoosted) { ItemStack var24 = var1.getHeldItem(); if (var24 != null && var24.itemID == Item.carrotOnAStick.itemID) { var24.damageItem(1, var1); if (var24.stackSize == 0) { ItemStack var25 = new ItemStack(Item.fishingRod); var25.setTagCompound(var24.stackTagCompound); var1.inventory.mainInventory[var1.inventory.currentItem] = var25; } } } this.thisEntity.moveEntityWithHeading(0.0F, var7); }