mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 09:34:46 +00:00
Implemented Scripted Custom Items.
This commit is contained in:
1 parent
5520fc5f2b
commit
26f5f86dca
34 files changed
+1476
-137
No files matched your search
@@ -54,6 +54,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
public class PacketHandlerServer{
|
||||
|
||||
@@ -123,6 +124,8 @@ public class PacketHandlerServer{
|
||||
npcScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||
forgeScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
|
||||
itemScriptPackets(type, buffer, player);
|
||||
else if (item.getItem() == CustomItems.scripter)
|
||||
scriptPackets(type, buffer, player, npc);
|
||||
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
||||
@@ -187,6 +190,26 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
|
||||
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||
if (type == EnumPacketServer.ScriptItemDataGet) {
|
||||
ScriptCustomItem iw = new ScriptCustomItem(player.getHeldItem());
|
||||
NBTTagCompound compound = iw.getMCNbt();
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||
} else if (type == EnumPacketServer.ScriptItemDataSave) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptCustomItem wrapper = new ScriptCustomItem(player.getHeldItem());
|
||||
wrapper.setMCNbt(compound);
|
||||
wrapper.lastInited = -1L;
|
||||
wrapper.saveScriptData();
|
||||
player.sendContainerToPlayer(player.inventoryContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if(type == EnumPacketServer.DimensionsGet){
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
|
||||
Reference in new issue
Block a user