mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 13:29:43 +00:00
Basic NPC Wrapper
This commit is contained in:
1 parent
d52b7b1fc2
commit
f8dc8d9268
6 files changed
+267
-3
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package somehussar.janino;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.IWorldAccess;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityUnloadListener implements IWorldAccess {
|
||||
@Override
|
||||
public void markBlockForUpdate(int p_147586_1_, int p_147586_2_, int p_147586_3_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markBlockForRenderUpdate(int p_147588_1_, int p_147588_2_, int p_147588_3_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markBlockRangeForRenderUpdate(int p_147585_1_, int p_147585_2_, int p_147585_3_, int p_147585_4_, int p_147585_5_, int p_147585_6_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(String soundName, double x, double y, double z, float volume, float pitch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSoundToNearExcept(EntityPlayer p_85102_1_, String p_85102_2_, double p_85102_3_, double p_85102_5_, double p_85102_7_, float p_85102_9_, float p_85102_10_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(String p_72708_1_, double p_72708_2_, double p_72708_4_, double p_72708_6_, double p_72708_8_, double p_72708_10_, double p_72708_12_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCreate(Entity p_72703_1_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDestroy(Entity entity) {
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
if (npc.janinoHandler != null)
|
||||
npc.janinoHandler.prepareToUnload();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playRecord(String p_72702_1_, int p_72702_2_, int p_72702_3_, int p_72702_4_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastSound(int p_82746_1_, int p_82746_2_, int p_82746_3_, int p_82746_4_, int p_82746_5_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playAuxSFX(EntityPlayer p_72706_1_, int p_72706_2_, int p_72706_3_, int p_72706_4_, int p_72706_5_, int p_72706_6_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyBlockPartially(int p_147587_1_, int p_147587_2_, int p_147587_3_, int p_147587_4_, int p_147587_5_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStaticEntitiesChanged() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package somehussar.janino.wrapper;
|
||||
|
||||
import io.github.somehussar.janinoloader.annotations.PermissableScriptHandler;
|
||||
import noppes.npcs.api.event.INpcEvent;
|
||||
import noppes.npcs.scripted.event.NpcEvent;
|
||||
import noppes.npcs.scripted.event.ProjectileEvent;
|
||||
|
||||
public abstract class AbstractNPCJavaHandler {
|
||||
|
||||
public void prepareToUnload() {
|
||||
}
|
||||
|
||||
public void onInitialize(INpcEvent.InitEvent event) {
|
||||
}
|
||||
|
||||
public void onUpdate(NpcEvent.UpdateEvent event) {
|
||||
}
|
||||
|
||||
public void onDialog(NpcEvent.DialogEvent event) {
|
||||
}
|
||||
|
||||
public void onProjectileTick(ProjectileEvent.UpdateEvent event) {
|
||||
}
|
||||
|
||||
public void onDialogClosed(NpcEvent.DialogClosedEvent event) {
|
||||
}
|
||||
|
||||
public void onAttack(NpcEvent.MeleeAttackEvent event) {
|
||||
}
|
||||
|
||||
public void onRangedAttack(NpcEvent.RangedLaunchedEvent event) {
|
||||
}
|
||||
|
||||
public void onMeleeSwing(NpcEvent.SwingEvent event) {
|
||||
}
|
||||
|
||||
public void onKillEntity(NpcEvent.KilledEntityEvent event) {
|
||||
}
|
||||
|
||||
public void onTarget(NpcEvent.TargetEvent event) {
|
||||
}
|
||||
|
||||
public void onTargetLost(NpcEvent.TargetLostEvent event) {
|
||||
}
|
||||
|
||||
public void onCollide(NpcEvent.CollideEvent event) {
|
||||
}
|
||||
|
||||
public void onDamaged(NpcEvent.DamagedEvent event) {
|
||||
}
|
||||
|
||||
public void onNPCKilled(NpcEvent.DiedEvent event) {
|
||||
}
|
||||
|
||||
public void onTimer(NpcEvent.TimerEvent event) {
|
||||
}
|
||||
|
||||
public void onProjectileImpact(ProjectileEvent.ImpactEvent event) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package somehussar.janino.wrapper;
|
||||
|
||||
import io.github.somehussar.janinoloader.api.script.IScriptClassBody;
|
||||
import org.codehaus.commons.compiler.Sandbox;
|
||||
|
||||
public final class NPCWrapper {
|
||||
|
||||
private final Sandbox sandbox;
|
||||
private final IScriptClassBody<AbstractNPCJavaHandler> scriptBody;
|
||||
|
||||
public NPCWrapper(Sandbox sandbox, IScriptClassBody<AbstractNPCJavaHandler> scriptBody) {
|
||||
this.sandbox = sandbox;
|
||||
this.scriptBody = scriptBody;
|
||||
}
|
||||
|
||||
public void prepareToUnload() {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().prepareToUnload(); return null; });
|
||||
}
|
||||
|
||||
public void onInitialize(noppes.npcs.api.event.INpcEvent.InitEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onInitialize(event); return null; });
|
||||
}
|
||||
|
||||
public void onUpdate(noppes.npcs.scripted.event.NpcEvent.UpdateEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onUpdate(event); return null; });
|
||||
}
|
||||
|
||||
public void onDialog(noppes.npcs.scripted.event.NpcEvent.DialogEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onDialog(event); return null; });
|
||||
}
|
||||
|
||||
public void onProjectileTick(noppes.npcs.scripted.event.ProjectileEvent.UpdateEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onProjectileTick(event); return null; });
|
||||
}
|
||||
|
||||
public void onDialogClosed(noppes.npcs.scripted.event.NpcEvent.DialogClosedEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onDialogClosed(event); return null; });
|
||||
}
|
||||
|
||||
public void onAttack(noppes.npcs.scripted.event.NpcEvent.MeleeAttackEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onAttack(event); return null; });
|
||||
}
|
||||
|
||||
public void onRangedAttack(noppes.npcs.scripted.event.NpcEvent.RangedLaunchedEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onRangedAttack(event); return null; });
|
||||
}
|
||||
|
||||
public void onMeleeSwing(noppes.npcs.scripted.event.NpcEvent.SwingEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onMeleeSwing(event); return null; });
|
||||
}
|
||||
|
||||
public void onKillEntity(noppes.npcs.scripted.event.NpcEvent.KilledEntityEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onKillEntity(event); return null; });
|
||||
}
|
||||
|
||||
public void onTarget(noppes.npcs.scripted.event.NpcEvent.TargetEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onTarget(event); return null; });
|
||||
}
|
||||
|
||||
public void onTargetLost(noppes.npcs.scripted.event.NpcEvent.TargetLostEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onTargetLost(event); return null; });
|
||||
}
|
||||
|
||||
public void onCollide(noppes.npcs.scripted.event.NpcEvent.CollideEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onCollide(event); return null; });
|
||||
}
|
||||
|
||||
public void onDamaged(noppes.npcs.scripted.event.NpcEvent.DamagedEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onDamaged(event); return null; });
|
||||
}
|
||||
|
||||
public void onNPCKilled(noppes.npcs.scripted.event.NpcEvent.DiedEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onNPCKilled(event); return null; });
|
||||
}
|
||||
|
||||
public void onTimer(noppes.npcs.scripted.event.NpcEvent.TimerEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onTimer(event); return null; });
|
||||
}
|
||||
|
||||
public void onProjectileImpact(noppes.npcs.scripted.event.ProjectileEvent.ImpactEvent event) {
|
||||
sandbox.confine((java.security.PrivilegedAction<Void>) () -> { scriptBody.get().onProjectileImpact(event); return null; });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user