mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 12:15:11 +00:00
Telegraph Scripting System
This commit is contained in:
1 parent
3e57b837aa
commit
bd7cafa482
34 files changed
+839
-51
No files matched your search
@@ -24,6 +24,7 @@ import kamkeel.npcs.command.profile.CommandProfile;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.controllers.TelegraphController;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.profile.CNPCData;
|
||||
import kamkeel.npcs.developer.Developer;
|
||||
@@ -331,7 +332,7 @@ public class CustomNpcs {
|
||||
new AnimationController();
|
||||
new AbilityController();
|
||||
AbilityController.Instance.load();
|
||||
|
||||
TelegraphController.init();
|
||||
|
||||
LinkedItemController.getInstance().load();
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package noppes.npcs;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphRemovePacket;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
@@ -7,7 +7,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.client.renderer.TelegraphRenderer;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
|
||||
@@ -5,7 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.player.InputDevicePacket;
|
||||
|
||||
@@ -3,7 +3,7 @@ package noppes.npcs.client.gui.advanced;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.Condition;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
import foxz.command.ScriptedCommand;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.TelegraphController;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.CommandHandler;
|
||||
@@ -52,6 +53,7 @@ import noppes.npcs.api.IContainer;
|
||||
import noppes.npcs.api.IDamageSource;
|
||||
import noppes.npcs.api.INbt;
|
||||
import noppes.npcs.api.IParticle;
|
||||
import noppes.npcs.api.ITelegraph;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.api.ITileEntity;
|
||||
@@ -75,6 +77,7 @@ import noppes.npcs.api.handler.IProfileHandler;
|
||||
import noppes.npcs.api.handler.IQuestHandler;
|
||||
import noppes.npcs.api.handler.IRecipeHandler;
|
||||
import noppes.npcs.api.handler.IScriptHookHandler;
|
||||
import noppes.npcs.api.handler.ITelegraphHandler;
|
||||
import noppes.npcs.api.handler.ITransportHandler;
|
||||
import noppes.npcs.api.handler.data.IAnimation;
|
||||
import noppes.npcs.api.handler.data.IFrame;
|
||||
@@ -370,6 +373,18 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return AbilityController.Instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphHandler getTelegraphs() {
|
||||
this.checkWorld();
|
||||
return TelegraphController.Instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph createTelegraph(String type) {
|
||||
this.checkWorld();
|
||||
return TelegraphController.Instance.create(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAllBiomeNames() {
|
||||
List<String> biomes = new ArrayList<>();
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import kamkeel.npcs.controllers.TelegraphController;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.api.ITelegraph;
|
||||
import noppes.npcs.api.ITelegraphInstance;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
|
||||
/**
|
||||
* Script wrapper for Telegraph configuration.
|
||||
* Implements ITelegraph API interface.
|
||||
*/
|
||||
public class ScriptTelegraph implements ITelegraph {
|
||||
|
||||
private final Telegraph telegraph;
|
||||
|
||||
public ScriptTelegraph(Telegraph telegraph) {
|
||||
this.telegraph = telegraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Telegraph object.
|
||||
*/
|
||||
public Telegraph getMCTelegraph() {
|
||||
return telegraph;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// TYPE
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return telegraph.getType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(String type) {
|
||||
if (type == null) return;
|
||||
try {
|
||||
telegraph.setType(TelegraphType.valueOf(type.toUpperCase()));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// SHAPE PARAMETERS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public float getRadius() {
|
||||
return telegraph.getRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadius(float radius) {
|
||||
telegraph.setRadius(radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInnerRadius() {
|
||||
return telegraph.getInnerRadius();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInnerRadius(float innerRadius) {
|
||||
telegraph.setInnerRadius(innerRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLength() {
|
||||
return telegraph.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLength(float length) {
|
||||
telegraph.setLength(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth() {
|
||||
return telegraph.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWidth(float width) {
|
||||
telegraph.setWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAngle() {
|
||||
return telegraph.getAngle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngle(float angle) {
|
||||
telegraph.setAngle(angle);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// TIMING
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public int getDuration() {
|
||||
return telegraph.getDurationTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(int ticks) {
|
||||
telegraph.setDurationTicks(ticks);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// COLORS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return telegraph.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int argb) {
|
||||
telegraph.setColor(argb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningColor() {
|
||||
return telegraph.getWarningColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarningColor(int argb) {
|
||||
telegraph.setWarningColor(argb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningStartTick() {
|
||||
return telegraph.getWarningStartTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarningStartTick(int tick) {
|
||||
telegraph.setWarningStartTick(tick);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// ANIMATION
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public boolean isAnimated() {
|
||||
return telegraph.isAnimated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimated(boolean animated) {
|
||||
telegraph.setAnimated(animated);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// POSITIONING
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public float getHeightOffset() {
|
||||
return telegraph.getHeightOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightOffset(float offset) {
|
||||
telegraph.setHeightOffset(offset);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// SPAWN METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(IWorld world, double x, double y, double z) {
|
||||
return spawn(world, x, y, z, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(IWorld world, double x, double y, double z, float yaw) {
|
||||
if (world == null || world.getMCWorld() == null) return null;
|
||||
World mcWorld = (World) world.getMCWorld();
|
||||
TelegraphInstance instance = TelegraphController.Instance.spawn(telegraph, mcWorld, x, y, z, yaw);
|
||||
return new ScriptTelegraphInstance(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(IEntity entity) {
|
||||
return spawn(entity, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(IEntity entity, float yaw) {
|
||||
if (entity == null || entity.getMCEntity() == null) return null;
|
||||
Entity mcEntity = (Entity) entity.getMCEntity();
|
||||
TelegraphInstance instance = TelegraphController.Instance.spawn(telegraph, mcEntity, yaw);
|
||||
return new ScriptTelegraphInstance(instance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import kamkeel.npcs.controllers.TelegraphController;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import net.minecraft.entity.Entity;
|
||||
import noppes.npcs.api.ITelegraphInstance;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
|
||||
/**
|
||||
* Script wrapper for TelegraphInstance.
|
||||
* Implements ITelegraphInstance API interface.
|
||||
*/
|
||||
public class ScriptTelegraphInstance implements ITelegraphInstance {
|
||||
|
||||
private final TelegraphInstance instance;
|
||||
|
||||
public ScriptTelegraphInstance(TelegraphInstance instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying TelegraphInstance object.
|
||||
*/
|
||||
public TelegraphInstance getMCInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceId() {
|
||||
return instance.getInstanceId();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// POSITION
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return instance.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return instance.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return instance.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYaw() {
|
||||
return instance.getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
instance.setX(x);
|
||||
instance.setY(y);
|
||||
instance.setZ(z);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// ENTITY FOLLOWING
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public void followEntity(IEntity entity) {
|
||||
if (entity == null || entity.getMCEntity() == null) return;
|
||||
Entity mcEntity = (Entity) entity.getMCEntity();
|
||||
instance.setEntityIdToFollow(mcEntity.getEntityId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopFollowing() {
|
||||
instance.lockPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFollowing() {
|
||||
return instance.getEntityIdToFollow() >= 0;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// TIMING
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public int getRemainingTicks() {
|
||||
return instance.getRemainingTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTicks() {
|
||||
return instance.getTotalTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return instance.getProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarning() {
|
||||
return instance.isWarning();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// CONTROL
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
TelegraphController.Instance.remove(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockPosition() {
|
||||
instance.lockPosition();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user