mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 06:25:11 +00:00
Added handler support to NPC API.
This commit is contained in:
1 parent
69f96519dc
commit
d50f51e208
40 files changed
+1471
-56
No files matched your search
@@ -35,16 +35,18 @@ import net.minecraftforge.common.util.FakePlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.client.EntityUtil;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ScriptEntityData;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.containers.ContainerNpcInterface;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.ScriptContainer;
|
||||
import noppes.npcs.scripted.entity.*;
|
||||
import noppes.npcs.scripted.handler.*;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.LRUHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class WrapperNpcAPI extends NpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap(10);
|
||||
@@ -58,6 +60,29 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
worldCache.clear();
|
||||
}
|
||||
|
||||
public IFactionHandler getFactions() {
|
||||
this.checkWorld();
|
||||
return FactionController.getInstance();
|
||||
}
|
||||
|
||||
public IRecipeHandler getRecipes() {
|
||||
this.checkWorld();
|
||||
return RecipeController.instance;
|
||||
}
|
||||
|
||||
public IQuestHandler getQuests() {
|
||||
this.checkWorld();
|
||||
return QuestController.instance;
|
||||
}
|
||||
|
||||
public IDialogHandler getDialogs() {
|
||||
return DialogController.instance;
|
||||
}
|
||||
|
||||
public ICloneHandler getClones() {
|
||||
return ServerCloneController.Instance;
|
||||
}
|
||||
|
||||
public IEntity getIEntity(Entity entity) {
|
||||
if(entity == null)
|
||||
return null;
|
||||
@@ -98,6 +123,18 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
return compound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(compound);
|
||||
}
|
||||
|
||||
public INbt stringToNbt(String str) {
|
||||
if (str != null && !str.isEmpty()) {
|
||||
try {
|
||||
return this.getINbt(NBTJsonUtil.Convert(str));
|
||||
} catch (JsonException var3) {
|
||||
throw new CustomNPCsException(var3, "Failed converting " + str, new Object[0]);
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Cant cast empty string to nbt", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public ICustomNpc createNPC(World world) {
|
||||
if (world.isRemote) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user