}
// patch method
public static void processVanilla250Packet(NetHandlerPlayServer net, C17PacketCustomPayload p_147349_1_)
{
PacketBuffer packetbuffer;
ItemStack itemstack;
ItemStack itemstack1;
if ("MC|BEdit".equals(p_147349_1_.func_149559_c()))
{
packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));
try
{
itemstack = packetbuffer.readItemStackFromBuffer();
if (itemstack == null)
{
return;
}
if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound()))
{
throw new IOException("Invalid book tag!");
}
itemstack1 = net.playerEntity.inventory.getCurrentItem();
if (itemstack1 != null)
{
if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem())
{
itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
}
return;
}
}
catch (Exception exception4)
{
NetHandlerPlayServer.logger.error("Couldn\'t handle book info", exception4);
return;
}
finally
{
packetbuffer.release();
}
return;
}
else if ("MC|BSign".equals(p_147349_1_.func_149559_c()))
{
packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));
try
{
itemstack = packetbuffer.readItemStackFromBuffer();
if (itemstack != null)
{
if (!ItemEditableBook.validBookTagContents(itemstack.getTagCompound()))
{
throw new IOException("Invalid book tag!");
}
itemstack1 = net.playerEntity.inventory.getCurrentItem();
if (itemstack1 == null)
{
return;
}
if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
{
itemstack1.setTagInfo("author", new NBTTagString(net.playerEntity.getCommandSenderName()));
itemstack1.setTagInfo("title", new NBTTagString(itemstack.getTagCompound().getString("title")));
itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8));
itemstack1.func_150996_a(Items.written_book);
}
return;
}
}
catch (Exception exception3)
{
NetHandlerPlayServer.logger.error("Couldn\'t sign book", exception3);
return;
}
finally
{
packetbuffer.release();
}
return;
}
else
{
DataInputStream datainputstream;
int i;
if ("MC|TrSel".equals(p_147349_1_.func_149559_c()))
{
try
{
datainputstream = new DataInputStream(new ByteArrayInputStream(p_147349_1_.func_149558_e()));
i = datainputstream.readInt();
Container container = net.playerEntity.openContainer;
if (container instanceof ContainerMerchant)
{
((ContainerMerchant)container).setCurrentRecipeIndex(i);
}
}
catch (Exception exception2)
{
NetHandlerPlayServer.logger.error("Couldn\'t select trade", exception2);
}
}
else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c()))
{
if (!net.serverController.isCommandBlockEnabled())
{
net.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0]));
}
else if (PermissionsManager.checkPermission(net.playerEntity, "mc.cmdblocks") && net.playerEntity.capabilities.isCreativeMode)
{
packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));
try
{
byte b0 = packetbuffer.readByte();
CommandBlockLogic commandblocklogic = null;
if (b0 == 0)
{
TileEntity tileentity = net.playerEntity.worldObj.getTileEntity(packetbuffer.readInt(), packetbuffer.readInt(), packetbuffer.readInt());
if (tileentity instanceof TileEntityCommandBlock)
{
commandblocklogic = ((TileEntityCommandBlock)tileentity).func_145993_a();
}
}
else if (b0 == 1)
{
Entity entity = net.playerEntity.worldObj.getEntityByID(packetbuffer.readInt());
if (entity instanceof EntityMinecartCommandBlock)
{
commandblocklogic = ((EntityMinecartCommandBlock)entity).func_145822_e();
}
}
String s1 = packetbuffer.readStringFromBuffer(packetbuffer.readableBytes());
if (commandblocklogic != null)
{
commandblocklogic.func_145752_a(s1);
commandblocklogic.func_145756_e();
net.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1}));
}
}
catch (Exception exception1)
{
NetHandlerPlayServer.logger.error("Couldn\'t set command block", exception1);
}
finally
{
packetbuffer.release();
}
}
else
{
net.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notAllowed", new Object[0]));