Compare commits

..
Author SHA1 Message Date
luisc b4aab454fe made mod build on java 21 2025-06-09 09:35:26 -05:00
Luis C.M. a7706b5e72 debugging changes, trying to get this to run on a server 2025-06-09 00:55:37 -05:00
Luis C.M. 92afb0a69e Merge remote-tracking branch 'origin/open-jdk-nashorn' into open-jdk-nashorn 2025-06-08 21:39:50 -05:00
Luis C.M. 5e7828ff66 Merge branch 'dev' into open-jdk-nashorn 2025-06-08 21:39:29 -05:00
Kam e973605be6 Make public 2025-06-05 13:18:33 -04:00
luisc 0b60f4b455 small fix HAHAHA 2025-06-03 18:18:24 -05:00
Kam 43154bba15 1.10.2 2025-06-03 19:06:34 -04:00
Kam 5d2b667aa6 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2025-06-03 19:06:09 -04:00
Kam 96496a40e2 Split Hover Text by New Lines 2025-06-03 19:06:07 -04:00
luisc 77ef063198 Merge branch 'refs/heads/dev' into open-jdk-nashorn 2025-06-03 15:50:55 -05:00
luisc fe1c21582a improved script performance when looking up top-level functions 2025-06-03 15:11:49 -05:00
Kam 49757c7cb5 1.10.1 2025-06-02 17:31:40 -04:00
Kam ce9941e3ee Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2025-06-02 15:09:29 -04:00
Kam 7b6c7c1c33 Update ScriptPlayerEventHandler.java 2025-06-02 15:09:24 -04:00
luisc b848dc0d7a Merge remote-tracking branch 'origin/dev' into dev 2025-06-02 14:09:08 -05:00
luisc e9f810dc21 set role on client side before opening role editors 2025-06-02 14:08:59 -05:00
Kam 20583d9b0d Fix CustomGuiClose Event 2025-06-02 15:01:31 -04:00
Kam 2b6f63a3e3 Right Click Event for Players 2025-06-02 14:56:29 -04:00
Kam b86c1ceabb Fix Couch Rendering 2025-06-01 23:46:51 -04:00
Kam 07640d9b6b Fix Negative Value Floats Only 2025-06-01 23:17:52 -04:00
luisc f2c7121912 added some more flags to optimize runtimes 2025-05-30 16:09:47 -05:00
luisc 44b3ddedd8 embedded open jdk nashorn 2025-05-30 11:53:08 -05:00
21 changed files with 227 additions and 73 deletions

No files matched your search

+7 -1
View File
@@ -5,7 +5,13 @@ plugins {
id 'idea'
}
version = "1.10"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
version = "1.10.2"
group= "kamkeel.customnpc-plus"
archivesBaseName = "CustomNPC-Plus"
+3 -1
View File
@@ -36,7 +36,7 @@
def embedMixin = !project.hasProperty("nomixin");
dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
shadowImplementation(project.files("lib/GraalJS.jar"))
// runtimeOnlyNonPublishable("curse.maven:Nashorn-374413:2924946")
if(embedMixin){
// Normal Jar will include built in Mixins
@@ -49,4 +49,6 @@ dependencies {
exclude module: 'log4j-core'
}
}
implementation('org.openjdk.nashorn:nashorn-core:15.4')
}
BIN
View File
Binary file not shown.
+1 -1
Submodule src/api updated: 5c6b16e75f...bbbea878fe.
@@ -49,9 +49,6 @@ public final class CustomGuiClosePacket extends AbstractPacket {
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player.openContainer instanceof ContainerCustomGui))
return;
NBTTagCompound comp = ByteBufUtils.readNBT(in);
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(comp));
}
@@ -55,6 +55,7 @@ public final class RoleGetPacket extends AbstractPacket {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("RoleData", true);
compound.setInteger("RoleOrdinal", npc.advanced.role.ordinal());
GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.roleInterface.writeToNBT(compound));
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ import noppes.npcs.scripted.NpcAPI;
import java.io.File;
import java.util.Set;
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.10")
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.10.2")
public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -390,6 +390,11 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerRightClick(PlayerDataScript handler, PlayerEvent.RightClickEvent event) {
handler.callScript(EnumScriptType.RIGHT_CLICK, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onProfileChange(PlayerDataScript handler, IPlayer player, IProfile profile, int newSlot, int prevSlot, boolean post) {
PlayerEvent.ProfileEvent.Changed event = new PlayerEvent.ProfileEvent.Changed(player, profile, newSlot, prevSlot, post);
handler.callScript(EnumScriptType.PROFILE_CHANGE, event);
@@ -154,6 +154,7 @@ public class ScriptItemEventHandler {
ItemNpcTool.setColor(held.getTagCompound(), color);
e.setCanceled(true);
return;
}
}
}
@@ -23,6 +23,7 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.IWorld;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.config.ConfigMain;
@@ -34,8 +35,10 @@ import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.quests.QuestItem;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.ItemEvent;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
@@ -123,9 +126,46 @@ public class ScriptPlayerEventHandler {
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer && event.entityPlayer instanceof EntityPlayerMP) {
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
IPlayer ip = NoppesUtilServer.getIPlayer(event.entityPlayer);
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 1, NpcAPI.Instance().getIEntity(event.target));
boolean rightClick = EventHooks.onPlayerRightClick(handler, rightClickEvent);
noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.player.PlayerEvent.InteractEvent(ip, 1, NpcAPI.Instance().getIEntity(event.target));
boolean interact = EventHooks.onPlayerInteract(handler, ev);
event.setCanceled(rightClick || interact);
}
}
@SubscribeEvent
public void invoke(PlayerInteractEvent event) {
if (event.entityPlayer == null || event.entityPlayer.worldObj == null || event.entityPlayer.worldObj.isRemote || !(event.entityPlayer instanceof EntityPlayerMP))
return;
if(event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)
return;
IPlayer ip = NoppesUtilServer.getIPlayer(event.entityPlayer);
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.entityPlayer);
PlayerData pd = PlayerData.get(event.entityPlayer);
if (pd == null) {
return;
}
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){
if (pd.hadInteract) {
pd.hadInteract = false;
return;
}
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 0, null);
event.setCanceled(EventHooks.onPlayerRightClick(handler, rightClickEvent));
} else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){
pd.hadInteract = true;
IWorld iw = (IWorld) NpcAPI.Instance().getIWorld(event.world);
Object blockCtx = NpcAPI.Instance().getIBlock(iw, event.x, event.y, event.z);
noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent rightClickEvent = new noppes.npcs.scripted.event.player.PlayerEvent.RightClickEvent(ip, 2, blockCtx);
event.setCanceled(EventHooks.onPlayerRightClick(handler, rightClickEvent));
}
}
@@ -7,6 +7,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Facing;
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
@@ -18,6 +19,11 @@ public class TileVariant extends TileEntity {
public int variant = 14;
public int rotation;
// Rotation = 0 Couch is Facing North
// Rotation = 1 Couch is Facing East
// Rotation = 2 Couch is Facing South
// Rotation = 3 Couch is Facing West
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
version = compound.getInteger("CNPCVersion");
@@ -93,6 +93,8 @@ public class SubGuiMagic extends SubGuiInterface implements ITextfieldListener,
addLabel(new GuiNpcLabel(50, "magic.interaction", guiLeft + 170, guiTop + 30 + 160 + 5));
interactionField = new GuiNpcTextField(90, this, fontRendererObj, guiLeft + 245, guiTop + 30 + 160, 45, 20, "");
interactionField.setFloatsOnly();
interactionField.setMinMaxDefaultFloat(-Float.MAX_VALUE, Float.MAX_VALUE, 0.0f);
addTextField(interactionField);
if (selectedInteraction != null) {
interactionField.setText(interactionValues.get(selectedInteraction) + "");
@@ -119,6 +119,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData {
@Override
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("RoleData")) {
npc.advanced.setRole(compound.getInteger("RoleOrdinal"));
if (npc.roleInterface != null)
npc.roleInterface.readFromNBT(compound);
@@ -18,6 +18,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
hookList.add(EnumScriptType.INIT.function);
hookList.add(EnumScriptType.TICK.function);
hookList.add(EnumScriptType.INTERACT.function);
hookList.add(EnumScriptType.RIGHT_CLICK.function);
hookList.add(EnumScriptType.ATTACK.function);
hookList.add(EnumScriptType.ATTACKED.function);
hookList.add(EnumScriptType.DAMAGED_ENTITY.function);
@@ -136,12 +136,20 @@ public abstract class GuiDiagram extends Gui {
String nameFrom = iconFrom != null ? getIconName(iconFrom) : "Unknown";
String nameTo = iconTo != null ? getIconName(iconTo) : "Unknown";
tooltip.add(nameFrom + " > " + nameTo + ":");
tooltip.add(conn.hoverText);
// Split Hover Text by newlines
if (conn.hoverText != null && !conn.hoverText.isEmpty()) {
String[] lines = conn.hoverText.split("\n");
tooltip.addAll(Arrays.asList(lines));
}
if (allowTwoWay) {
DiagramConnection reverse = getConnectionByIds(conn.idTo, conn.idFrom);
if (reverse != null) {
tooltip.add(nameTo + " > " + nameFrom + ":");
tooltip.add(reverse.hoverText);
// Split Hover Text by newlines
if (reverse.hoverText != null && !reverse.hoverText.isEmpty()) {
String[] lines = reverse.hoverText.split("\n");
tooltip.addAll(Arrays.asList(lines));
}
}
}
return tooltip;
@@ -100,7 +100,7 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface {
setCouchWood(var1.getBlockMetadata());
if (tile.hasCornerLeft) {
GL11.glPushMatrix();
GL11.glRotatef(90, 0, 1, 0);
GL11.glRotatef(270, 0, 1, 0);
modelCouchCorner.CouchBack.render(0.0625F);
GL11.glPopMatrix();
} else if (tile.hasCornerRight)
@@ -119,8 +119,12 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface {
float[] color = ColorUtil.hexToRGB(tile.color);
GL11.glColor3f(color[0], color[1], color[2]);
if (tile.hasCornerLeft)
if (tile.hasCornerLeft){
GL11.glPushMatrix();
GL11.glRotatef(270, 0, 1, 0);
modelCouchCorner.Cussion.render(0.0625F);
GL11.glPopMatrix();
}
else if (tile.hasCornerRight)
modelCouchCorner.Cussion.render(0.0625F);
else if (tile.hasLeft && tile.hasRight)
@@ -7,11 +7,9 @@ import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.scripted.NpcAPI;
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.*;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
@@ -35,6 +33,7 @@ public class ScriptContainer {
private static Method luaCoerce;
private static Method luaCall;
private CompiledScript compScript = null;
private final HashMap<String, ScriptObjectMirror> cachedFunctions = new HashMap<>();
public ScriptContainer(IScriptHandler handler) {
this.handler = handler;
@@ -173,6 +172,7 @@ public class ScriptContainer {
try {
if (!evaluated) {
this.cachedFunctions.clear();
engine.eval(getFullCode());
evaluated = true;
}
@@ -188,7 +188,15 @@ public class ScriptContainer {
unknownFunctions.add(type);
}
} else {
((Invocable) engine).invokeFunction(type, event);
if (!this.cachedFunctions.containsKey(type)) {
ScriptObjectMirror global = (ScriptObjectMirror) engine.getBindings(ScriptContext.ENGINE_SCOPE);
ScriptObjectMirror func = (ScriptObjectMirror) global.get(type);
this.cachedFunctions.put(type, func);
}
ScriptObjectMirror func = this.cachedFunctions.get(type);
if (func != null) {
func.call(null, event);
}
}
} catch (NoSuchMethodException e) {
unknownFunctions.add(type);
@@ -1,10 +1,6 @@
package noppes.npcs.controllers;
import com.oracle.truffle.js.scriptengine.GraalJSEngineFactory;
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
//import jdk.nashorn.api.scripting.ClassFilter;
//import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -23,8 +19,8 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.util.JsonException;
import noppes.npcs.util.NBTJsonUtil;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.HostAccess;
import org.openjdk.nashorn.api.scripting.ClassFilter;
import org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
@@ -34,8 +30,9 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.function.Predicate;
import static noppes.npcs.util.CustomNPCsThreader.customNPCThread;
@@ -44,7 +41,7 @@ public class ScriptController {
public static ScriptController Instance;
public static boolean HasStart = false;
private final ScriptEngineManager manager;
private ScriptEngineFactory graalFactory;
private ScriptEngineFactory nashornFactory;
public Map<String, String> languages = new HashMap<String, String>();
public Map<String, String> scripts = new HashMap<String, String>();
public long lastLoaded = 0;
@@ -69,34 +66,25 @@ public class ScriptController {
LogWriter.info("Script Engines Available:");
try {
this.graalFactory = new GraalJSEngineFactory();
LogWriter.info("→ standalone Nashorn loaded: " + this.graalFactory.getEngineName());
// this.nashornFactory = new NashornScriptEngineFactory();
// LogWriter.info("→ standalone Nashorn loaded");
Class<?> clazz = Class.forName("org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory");
this.nashornFactory = (ScriptEngineFactory) clazz.newInstance();
this.languages.put("ECMAScript", ".js");
LogWriter.info("→ standalone Nashorn loaded: " + this.nashornFactory.getEngineName());
} catch (Exception e) {
// fallback to built-in (Java 8–11) — also guarded
try {
ScriptEngine eng = manager.getEngineByName("nashorn");
if (eng != null) {
this.graalFactory = eng.getFactory();
this.nashornFactory = eng.getFactory();
this.languages.put("ECMAScript", ".js");
LogWriter.info("→ built-in Nashorn loaded");
}
} catch (Throwable t) {
LogWriter.error("No Nashorn engine available");
}
}
for (ScriptEngineFactory fac : manager.getEngineFactories()) {
if (fac.getExtensions().isEmpty())
continue;
ScriptEngine scriptEngine = fac.getScriptEngine();
try {
scriptEngine.put("$RunTest", null);
String ext = "." + fac.getExtensions().get(0).toLowerCase();
LogWriter.info("Engine " + fac.getEngineName() + " running " + fac.getLanguageName() + " with extension: " + ext);
languages.put(fac.getLanguageName(), ext);
} catch (Exception ignored) {
}
}
}
private File forgeScriptsFile() {
@@ -303,27 +291,27 @@ public class ScriptController {
private static final List<String> nashornNames = immutableList("nashorn", "Nashorn", "js", "JS", "JavaScript", "javascript", "ECMAScript", "ecmascript");
public ScriptEngine getEngineByName(String language) {
if (nashornNames.contains(language) && this.graalFactory != null) {
ScriptEngine scriptEngine = getGraalJSEngine();
if (nashornNames.contains(language) && this.nashornFactory != null) {
ScriptEngine scriptEngine = getOpenJDKNashornEngine();
if (scriptEngine != null) return scriptEngine;
if (ConfigScript.EnableBannedClasses) {
try {
// ClassFilter filter = s -> {
// for (String className : ConfigScript.BannedClasses) {
// if (s.compareTo(className) == 0) {
// return false;
// }
// }
// return true;
// };
// NashornScriptEngineFactory nashornScriptEngineFactory = (NashornScriptEngineFactory) this.graalFactory;
// scriptEngine = nashornScriptEngineFactory.getScriptEngine(filter);
ClassFilter filter = s -> {
for (String className : ConfigScript.BannedClasses) {
if (s.compareTo(className) == 0) {
return false;
}
}
return true;
};
NashornScriptEngineFactory nashornScriptEngineFactory = (NashornScriptEngineFactory) this.nashornFactory;
scriptEngine = nashornScriptEngineFactory.getScriptEngine(filter);
} catch (Exception e) {
scriptEngine = this.graalFactory.getScriptEngine();
scriptEngine = this.nashornFactory.getScriptEngine();
}
} else {
scriptEngine = this.graalFactory.getScriptEngine();
scriptEngine = this.nashornFactory.getScriptEngine();
}
scriptEngine.setBindings(this.manager.getBindings(), ScriptContext.GLOBAL_SCOPE);
return scriptEngine;
@@ -331,20 +319,69 @@ public class ScriptController {
return manager.getEngineByName(language);
}
public ScriptEngine getGraalJSEngine() {
Context.Builder polyglotContext = Context.newBuilder("js")
.option("js.nashorn-compat", "true")
.option("js.scripting", "true")
.option("js.syntax-extensions", "true")
.allowAllAccess(true)
.allowNativeAccess(true)
.allowIO(true)
.allowHostAccess(HostAccess.ALL)
.allowHostClassLookup(s -> true);
public ScriptEngine getOpenJDKNashornEngine() {
ScriptEngine engine;
try {
// Load factory and class filter
Class<?> factoryClass = Class.forName("org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory");
Object factory = factoryClass.getConstructor().newInstance();
return GraalJSScriptEngine.create(
((GraalJSEngineFactory)this.graalFactory).getPolyglotEngine(),
polyglotContext);
// Load ClassFilter interface (from Nashorn 15.6)
Class<?> classFilterClass = Class.forName("org.openjdk.nashorn.api.scripting.ClassFilter");
Object classFilter;
if (ConfigScript.EnableBannedClasses) {
// Create proxy instance of ClassFilter
classFilter = Proxy.newProxyInstance(
classFilterClass.getClassLoader(),
new Class[]{classFilterClass},
(proxy, method, args) -> {
if ("exposeToScripts".equals(method.getName()) && args.length == 1) {
String className = (String) args[0];
for (String banned : ConfigScript.BannedClasses) {
if (className.equals(banned)) return false;
}
return true;
}
throw new UnsupportedOperationException("Unsupported method: " + method);
});
Method getEngineMethod = factoryClass.getMethod(
"getScriptEngine",
String[].class,
ClassLoader.class,
classFilterClass
);
String[] args = new String[] {
"--language=es6",
"--optimistic-types=true",
"--lazy-compilation=true"
};
ClassLoader loader = Thread.currentThread().getContextClassLoader();
engine = (ScriptEngine) getEngineMethod.invoke(
factory,
(Object) args,
loader,
classFilter
);
} else {
Method getEngineMethod = factoryClass.getMethod("getScriptEngine", String[].class);
String[] args = new String[] {
"--language=es6",
"--optimistic-types=true",
"--lazy-compilation=true"
};
engine = (ScriptEngine) getEngineMethod.invoke(factory, (Object) args);
}
engine.setBindings(this.manager.getBindings(), ScriptContext.GLOBAL_SCOPE);
return engine;
} catch (Exception ignored) {
ignored.printStackTrace();
return null;
}
}
private static List<String> immutableList(String... elements) {
@@ -242,7 +242,7 @@ public class DataScript implements INpcScriptHandler {
@Override
public void callScript(String hookName, Event event) {
try {
EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName);
EnumScriptType enumScriptType = EnumScriptType.valueOfIgnoreCase(hookName);
this.callScript(enumScriptType, event);
} catch (IllegalArgumentException ignored) {
}
@@ -10,7 +10,7 @@ public class ModelPartData {
public byte pattern = 0;
public boolean playerTexture;
private ResourceLocation location;
public ResourceLocation location;
public ModelPartData() {
playerTexture = true;
@@ -13,13 +13,16 @@ import noppes.npcs.api.IDamageSource;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IEntityLivingBase;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.event.IItemEvent;
import noppes.npcs.api.event.IPlayerEvent;
import noppes.npcs.api.handler.data.IPlayerEffect;
import noppes.npcs.api.handler.data.IProfile;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.CustomNPCsEvent;
import noppes.npcs.scripted.event.ItemEvent;
public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final IPlayer player;
@@ -650,6 +653,38 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
}
}
@Cancelable
public static class RightClickEvent extends PlayerEvent implements IPlayerEvent.RightClickEvent {
/**
* 0:air, 1:entity, 2:block
*/
public final int type;
public final Object target;
public RightClickEvent(IPlayer player, int type, Object target) {
super(player);
this.type = type;
this.target = target;
}
public String getHookName() {
return EnumScriptType.RIGHT_CLICK.function;
}
public int getType() {
return type;
}
public Object getTarget() {
return target;
}
public IPlayer getPlayer() {
return player;
}
}
public static class UpdateEvent extends PlayerEvent implements IPlayerEvent.UpdateEvent {
public UpdateEvent(IPlayer player) {
super(player);