mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 05:14:28 +00:00
HUGE IScriptHandlerPacket merge.
All ScriptHandlers that send packets now directly define their data through the ScriptHandler class itself, NOT through their own GuiScript extended class.
This commit is contained in:
1 parent
3f8373d76f
commit
50e9f1b3e5
18 files changed
+323
-443
No files matched your search
@@ -1,15 +1,20 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
|
||||
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.item.IItemCustom;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
import noppes.npcs.controllers.data.IScriptHandlerPacket;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -18,13 +23,15 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCustom, IScriptHandler {
|
||||
public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCustom, IScriptHandlerPacket {
|
||||
public List<IScriptUnit> scripts = new ArrayList();
|
||||
public List<Integer> errored = new ArrayList();
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
public boolean loaded = false;
|
||||
|
||||
private Map<Long, String> clientConsoleText = new TreeMap<>();
|
||||
|
||||
public double durabilityValue = 1.0D;
|
||||
public int stackSize = 64;
|
||||
|
||||
@@ -60,6 +67,48 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptContext getContext() {
|
||||
return ScriptContext.ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookContext() {
|
||||
return IScriptHookHandler.CONTEXT_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestData() {
|
||||
ItemScriptErrorPacket.Get();
|
||||
ItemScriptPacket.Get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
|
||||
ItemScriptPacket.Save(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiDataResult setGuiData(NBTTagCompound compound) {
|
||||
if (compound.hasKey("LoadComplete")) {
|
||||
return new GuiDataResult(GuiDataKind.LOAD_COMPLETE, -1);
|
||||
}
|
||||
|
||||
if (compound.hasKey("ItemScriptConsole")) {
|
||||
clientConsoleText = NBTTags.GetLongStringMap(compound.getTagList("ItemScriptConsole", 10));
|
||||
return new GuiDataResult(GuiDataKind.TAB, -1);
|
||||
}
|
||||
|
||||
setMCNbt(compound);
|
||||
loadScriptData();
|
||||
return new GuiDataResult(GuiDataKind.METADATA, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
sendSavePacket(-1, getScripts().size(), getMCNbt());
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 6;
|
||||
}
|
||||
@@ -142,10 +191,12 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
return new TreeMap<>();
|
||||
return clientConsoleText;
|
||||
}
|
||||
|
||||
public void clearConsole() {
|
||||
clientConsoleText.clear();
|
||||
ItemScriptErrorPacket.Clear();
|
||||
}
|
||||
|
||||
public int getMaxStackSize() {
|
||||
|
||||
Reference in new issue
Block a user