mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
1 parent
debd00c1c2
commit
8f28e94daf
1 file changed
+26
-37
@@ -12,7 +12,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.*;
|
||||
@@ -274,46 +273,36 @@ public class PacketHandlerPlayer{
|
||||
}
|
||||
else if(type == EnumPlayerPacket.SignSave){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
Chunk chunk = new Chunk(player.worldObj,x,z);
|
||||
if (chunk.isChunkLoaded) {
|
||||
if (player.worldObj.blockExists(x,y,z)) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if (tile == null || !(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if (sign.canEdit) {
|
||||
sign.setText(Server.readString(buffer));
|
||||
sign.canEdit = false;
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if(tile == null || !(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if(sign.canEdit){
|
||||
sign.setText(Server.readString(buffer));
|
||||
sign.canEdit = false;
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.SaveBook){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
Chunk chunk = new Chunk(player.worldObj,x,z);
|
||||
if (chunk.isChunkLoaded) {
|
||||
if (player.worldObj.blockExists(x,y,z)) {
|
||||
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
|
||||
if (!(tileentity instanceof TileBook))
|
||||
return;
|
||||
TileBook tile = (TileBook) tileentity;
|
||||
if (tile.book.getItem() == Items.written_book)
|
||||
return;
|
||||
boolean sign = buffer.readBoolean();
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
|
||||
if (book == null)
|
||||
return;
|
||||
if (book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())) {
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
}
|
||||
if (book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())) {
|
||||
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
|
||||
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
tile.book.func_150996_a(Items.written_book);
|
||||
}
|
||||
}
|
||||
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileBook))
|
||||
return;
|
||||
TileBook tile = (TileBook) tileentity;
|
||||
if(tile.book.getItem() == Items.written_book)
|
||||
return;
|
||||
boolean sign = buffer.readBoolean();
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
|
||||
if(book == null)
|
||||
return;
|
||||
if(book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())){
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
}
|
||||
if(book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())){
|
||||
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
|
||||
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
tile.book.func_150996_a(Items.written_book);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user