diff --git a/src/api b/src/api index ffe67e93f..0a125ec5e 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit ffe67e93f10c98da09f0a05ff25d0c6202fe6b28 +Subproject commit 0a125ec5e21a23d05147683f4141ac91cc1251d4 diff --git a/src/main/java/noppes/npcs/PacketHandlerPlayer.java b/src/main/java/noppes/npcs/PacketHandlerPlayer.java index c1f06dc7a..d4d1dea95 100644 --- a/src/main/java/noppes/npcs/PacketHandlerPlayer.java +++ b/src/main/java/noppes/npcs/PacketHandlerPlayer.java @@ -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); } } } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java index c0cc81241..a44cca5f5 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java @@ -46,36 +46,43 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS scroll.guiLeft = guiLeft + 172; scroll.guiTop = guiTop + 8; addScroll(scroll); - addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 172, guiTop + 8 + 3 + 180, 130, 20, search)); - - this.addButton(new GuiNpcButton(0,guiLeft + 306, guiTop + 10, 94, 30, "menu.global")); - this.addButton(new GuiNpcButton(1,guiLeft + 306, guiTop + 32, 94, 20, "tile.npcCarpentyBench.name")); - this.getButton(0).setEnabled(container.width == 4); - this.getButton(1).setEnabled(container.width == 3); - this.addButton(new GuiNpcButton(3,guiLeft + 306, guiTop + 60, 94, 20, "gui.add")); - this.addButton(new GuiNpcButton(4,guiLeft + 306, guiTop + 82, 94, 20, "gui.remove")); + this.addButton(new GuiNpcButton(0,guiLeft + 306, guiTop + 10, 84, 20, "menu.global")); + this.addButton(new GuiNpcButton(1,guiLeft + 306, guiTop + 32, 84, 20, "tile.npcCarpentyBench.name")); + this.getButton(0).setEnabled(container.width == 4); + this.getButton(1).setEnabled(container.width == 3); + + this.addButton(new GuiNpcButton(3,guiLeft + 306, guiTop + 60, 84, 20, "gui.add")); + this.addButton(new GuiNpcButton(4,guiLeft + 306, guiTop + 82, 84, 20, "gui.remove")); this.addLabel(new GuiNpcLabel(0, "gui.ignoreDamage", guiLeft + 86, guiTop + 32)); this.addButton(new GuiNpcButtonYesNo(5,guiLeft + 114, guiTop + 40, 50, 20, container.recipe.ignoreDamage)); this.addLabel(new GuiNpcLabel(1, "gui.ignoreNBT", guiLeft + 86, guiTop + 82)); this.addButton(new GuiNpcButtonYesNo(6,guiLeft + 114, guiTop + 90, 50, 20, container.recipe.ignoreNBT)); - - this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 8, guiTop + 8, 160, 20, container.recipe.name)); - this.getTextField(0).enabled = false; - this.getButton(5).setEnabled(false); - this.getButton(6).setEnabled(false); - } + + this.addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 8, guiTop + 8, 160, 20, container.recipe.name)); + this.getTextField(0).enabled = false; + this.getButton(5).setEnabled(false); + this.getButton(6).setEnabled(false); + + this.addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 172, guiTop + 8 + 3 + 180, 130, 20, search)); + } @Override protected void actionPerformed(GuiButton guibutton){ GuiNpcButton button = (GuiNpcButton) guibutton; if(button.id == 0){ + getTextField(55).setText(""); + search = ""; + scroll.clear(); save(); NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,3,0,0); } if(button.id == 1){ + getTextField(55).setText(""); + search = ""; + scroll.clear(); save(); NoppesUtil.requestOpenGUI(EnumGuiType.ManageRecipes,4,0,0); } @@ -192,14 +199,16 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - String name = guiNpcTextField.getText(); - if(!name.isEmpty() && !data.containsKey(name)){ - String old = container.recipe.name; - data.remove(container.recipe.name); - container.recipe.name = name; - data.put(container.recipe.name, container.recipe.id); - selected = name; - scroll.replace(old,container.recipe.name); + if(guiNpcTextField.id == 0){ + String name = guiNpcTextField.getText(); + if(!name.isEmpty() && !data.containsKey(name)){ + String old = container.recipe.name; + data.remove(container.recipe.name); + container.recipe.name = name; + data.put(container.recipe.name, container.recipe.id); + selected = name; + scroll.replace(old,container.recipe.name); + } } } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 42cfc3985..cdaa9c29c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -915,4 +915,9 @@ public class ScriptEntity implements IEntity { public boolean equals(Object object) { return object instanceof IEntity && ((IEntity)object).getMCEntity().equals(this.entity); } + + public void updateEntity() { + IWorld world = NpcAPI.Instance().getIWorld(entity.worldObj); + entity.dimension = world.getDimensionID(); + } } \ No newline at end of file