mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-11 23:07:37 +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
+1
-1
Submodule src/api updated: a6b4a131c8...c8a2fb9824.
@@ -1,10 +1,10 @@
|
||||
package kamkeel.npcs.client.renderer;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
package kamkeel.npcs.controllers;
|
||||
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphRemovePacket;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.ITelegraph;
|
||||
import noppes.npcs.api.ITelegraphInstance;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.handler.ITelegraphHandler;
|
||||
import noppes.npcs.scripted.ScriptTelegraph;
|
||||
import noppes.npcs.scripted.ScriptTelegraphInstance;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Server-side controller for managing telegraphs.
|
||||
* Provides factory methods for creating telegraphs and spawn methods for sending to clients.
|
||||
* Also manages saved telegraph presets.
|
||||
*/
|
||||
public class TelegraphController implements ITelegraphHandler {
|
||||
|
||||
public static TelegraphController Instance;
|
||||
|
||||
// Saved telegraph presets (name -> Telegraph)
|
||||
private HashMap<String, Telegraph> savedTelegraphs = new HashMap<>();
|
||||
|
||||
// Active server-side telegraph instances (for removal tracking)
|
||||
private ConcurrentHashMap<String, TelegraphInstance> activeInstances = new ConcurrentHashMap<>();
|
||||
|
||||
public TelegraphController() {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Instance = new TelegraphController();
|
||||
Instance.load();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// INTERNAL SPAWN METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Spawn a telegraph at a fixed position.
|
||||
*
|
||||
* @param telegraph The telegraph configuration
|
||||
* @param world The world
|
||||
* @param x X position
|
||||
* @param y Y position
|
||||
* @param z Z position
|
||||
* @param yaw Rotation yaw (for directional telegraphs like LINE/CONE)
|
||||
* @return The spawned telegraph instance
|
||||
*/
|
||||
public TelegraphInstance spawn(Telegraph telegraph, World world, double x, double y, double z, float yaw) {
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
instance.setWorld(world);
|
||||
activeInstances.put(instance.getInstanceId(), instance);
|
||||
TelegraphSpawnPacket.sendToDimension(instance, world.provider.dimensionId);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph at a position with default yaw.
|
||||
*/
|
||||
public TelegraphInstance spawn(Telegraph telegraph, World world, double x, double y, double z) {
|
||||
return spawn(telegraph, world, x, y, z, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph that follows an entity.
|
||||
*
|
||||
* @param telegraph The telegraph configuration
|
||||
* @param entity The entity to follow
|
||||
* @return The spawned telegraph instance
|
||||
*/
|
||||
public TelegraphInstance spawn(Telegraph telegraph, Entity entity) {
|
||||
return spawn(telegraph, entity, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph that follows an entity with yaw.
|
||||
*/
|
||||
public TelegraphInstance spawn(Telegraph telegraph, Entity entity, float yaw) {
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, entity.posX, entity.posY, entity.posZ, yaw);
|
||||
instance.setWorld(entity.worldObj);
|
||||
instance.setEntityIdToFollow(entity.getEntityId());
|
||||
activeInstances.put(instance.getInstanceId(), instance);
|
||||
TelegraphSpawnPacket.sendToTracking(instance, entity);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph to a specific player only.
|
||||
*/
|
||||
public TelegraphInstance spawnToPlayer(Telegraph telegraph, EntityPlayerMP player, double x, double y, double z, float yaw) {
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
instance.setWorld(player.worldObj);
|
||||
activeInstances.put(instance.getInstanceId(), instance);
|
||||
TelegraphSpawnPacket.send(instance, player);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph to all players on the server.
|
||||
*/
|
||||
public TelegraphInstance spawnToAll(Telegraph telegraph, World world, double x, double y, double z, float yaw) {
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
instance.setWorld(world);
|
||||
activeInstances.put(instance.getInstanceId(), instance);
|
||||
TelegraphSpawnPacket.sendToAll(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a telegraph to all players tracking an entity.
|
||||
*/
|
||||
public TelegraphInstance spawnToTracking(Telegraph telegraph, Entity entity, double x, double y, double z, float yaw) {
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
instance.setWorld(entity.worldObj);
|
||||
activeInstances.put(instance.getInstanceId(), instance);
|
||||
TelegraphSpawnPacket.sendToTracking(instance, entity);
|
||||
return instance;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// REMOVAL METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Remove a telegraph by instance ID.
|
||||
*/
|
||||
public void remove(String instanceId) {
|
||||
TelegraphInstance instance = activeInstances.remove(instanceId);
|
||||
if (instance != null && instance.getWorld() != null) {
|
||||
TelegraphRemovePacket.sendToDimension(instanceId, instance.getDimensionId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a telegraph instance.
|
||||
*/
|
||||
public void remove(TelegraphInstance instance) {
|
||||
if (instance != null) {
|
||||
remove(instance.getInstanceId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a telegraph for a specific player only.
|
||||
*/
|
||||
public void removeFromPlayer(String instanceId, EntityPlayerMP player) {
|
||||
activeInstances.remove(instanceId);
|
||||
TelegraphRemovePacket.send(instanceId, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an active telegraph instance by ID.
|
||||
*/
|
||||
public TelegraphInstance getActiveInstance(String instanceId) {
|
||||
return activeInstances.get(instanceId);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// PRESET MANAGEMENT
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Save a telegraph preset (internal use).
|
||||
*
|
||||
* @param name The name for the preset
|
||||
* @param telegraph The telegraph configuration to save
|
||||
*/
|
||||
public void saveInternal(String name, Telegraph telegraph) {
|
||||
if (name == null || name.isEmpty() || telegraph == null) return;
|
||||
|
||||
telegraph.setId(name);
|
||||
savedTelegraphs.put(name, telegraph);
|
||||
saveTelegraphFile(name, telegraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a saved telegraph preset by name (internal use).
|
||||
*
|
||||
* @param name The preset name
|
||||
* @return The telegraph configuration, or null if not found
|
||||
*/
|
||||
public Telegraph getInternal(String name) {
|
||||
return savedTelegraphs.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a saved telegraph preset.
|
||||
*
|
||||
* @param name The preset name
|
||||
*/
|
||||
public void delete(String name) {
|
||||
Telegraph removed = savedTelegraphs.remove(name);
|
||||
if (removed != null) {
|
||||
File file = new File(getDir(), name + ".json");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a preset exists.
|
||||
*/
|
||||
public boolean has(String name) {
|
||||
return savedTelegraphs.containsKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all saved preset names.
|
||||
*/
|
||||
public String[] getSavedNames() {
|
||||
return savedTelegraphs.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// PERSISTENCE
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
private File getDir() {
|
||||
return new File(CustomNpcs.getWorldSaveDirectory(), "telegraphs");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
savedTelegraphs.clear();
|
||||
LogWriter.info("Loading telegraph presets...");
|
||||
|
||||
File dir = getDir();
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
return;
|
||||
}
|
||||
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) return;
|
||||
|
||||
for (File file : files) {
|
||||
if (!file.isFile() || !file.getName().endsWith(".json")) continue;
|
||||
try {
|
||||
Telegraph telegraph = new Telegraph();
|
||||
telegraph.readNBT(NBTJsonUtil.LoadFile(file));
|
||||
String name = file.getName().substring(0, file.getName().length() - 5);
|
||||
telegraph.setId(name);
|
||||
savedTelegraphs.put(name, telegraph);
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error loading telegraph preset: " + file.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
LogWriter.info("Loaded " + savedTelegraphs.size() + " telegraph presets.");
|
||||
}
|
||||
|
||||
private void saveTelegraphFile(String name, Telegraph telegraph) {
|
||||
try {
|
||||
File dir = getDir();
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File file = new File(dir, name + ".json_new");
|
||||
File file2 = new File(dir, name + ".json");
|
||||
|
||||
NBTJsonUtil.SaveFile(file, telegraph.writeNBT());
|
||||
if (file2.exists()) {
|
||||
file2.delete();
|
||||
}
|
||||
file.renameTo(file2);
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error saving telegraph preset: " + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// ITelegraphHandler INTERFACE IMPLEMENTATION
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
public ITelegraph createCircle(float radius) {
|
||||
return new ScriptTelegraph(Telegraph.circle(radius));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph createRing(float outerRadius, float innerRadius) {
|
||||
return new ScriptTelegraph(Telegraph.ring(outerRadius, innerRadius));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph createLine(float length, float width) {
|
||||
return new ScriptTelegraph(Telegraph.line(length, width));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph createCone(float length, float angle) {
|
||||
return new ScriptTelegraph(Telegraph.cone(length, angle));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph createPoint() {
|
||||
return new ScriptTelegraph(Telegraph.point());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph create(String type) {
|
||||
if (type == null) return null;
|
||||
try {
|
||||
TelegraphType telegraphType = TelegraphType.valueOf(type.toUpperCase());
|
||||
Telegraph telegraph;
|
||||
switch (telegraphType) {
|
||||
case CIRCLE:
|
||||
telegraph = Telegraph.circle(3.0f);
|
||||
break;
|
||||
case RING:
|
||||
telegraph = Telegraph.ring(5.0f, 2.0f);
|
||||
break;
|
||||
case LINE:
|
||||
telegraph = Telegraph.line(5.0f, 2.0f);
|
||||
break;
|
||||
case CONE:
|
||||
telegraph = Telegraph.cone(5.0f, 45.0f);
|
||||
break;
|
||||
case POINT:
|
||||
telegraph = Telegraph.point();
|
||||
break;
|
||||
default:
|
||||
telegraph = Telegraph.circle(3.0f);
|
||||
}
|
||||
return new ScriptTelegraph(telegraph);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(ITelegraph telegraph, IWorld world, double x, double y, double z) {
|
||||
return spawn(telegraph, world, x, y, z, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(ITelegraph telegraph, IWorld world, double x, double y, double z, float yaw) {
|
||||
if (telegraph == null || world == null) return null;
|
||||
Telegraph internal = ((ScriptTelegraph) telegraph).getMCTelegraph();
|
||||
TelegraphInstance instance = spawn(internal, (World) world.getMCWorld(), x, y, z, yaw);
|
||||
return new ScriptTelegraphInstance(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(ITelegraph telegraph, IEntity entity) {
|
||||
return spawn(telegraph, entity, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraphInstance spawn(ITelegraph telegraph, IEntity entity, float yaw) {
|
||||
if (telegraph == null || entity == null) return null;
|
||||
Telegraph internal = ((ScriptTelegraph) telegraph).getMCTelegraph();
|
||||
TelegraphInstance instance = spawn(internal, (Entity) entity.getMCEntity(), yaw);
|
||||
return new ScriptTelegraphInstance(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITelegraph get(String name) {
|
||||
Telegraph telegraph = savedTelegraphs.get(name);
|
||||
return telegraph != null ? new ScriptTelegraph(new Telegraph(telegraph)) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String name, ITelegraph telegraph) {
|
||||
if (name == null || name.isEmpty() || telegraph == null) return;
|
||||
Telegraph internal = ((ScriptTelegraph) telegraph).getMCTelegraph();
|
||||
saveInternal(name, internal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ITelegraphInstance instance) {
|
||||
if (instance != null) {
|
||||
remove(instance.getInstanceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package kamkeel.npcs.controllers.data.ability;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,9 +4,9 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
@@ -4,8 +4,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,9 +4,9 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -4,8 +4,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
+6
-2
@@ -1,10 +1,10 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
package kamkeel.npcs.controllers.data.telegraph;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Telegraph configuration - defines a visual warning shape.
|
||||
* Telegraphs warn players about incoming attacks.
|
||||
* Telegraphs warn players about incoming attacks or mark areas of effect.
|
||||
*/
|
||||
public class Telegraph {
|
||||
|
||||
@@ -146,6 +146,10 @@ public class Telegraph {
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Telegraph point() {
|
||||
return new Telegraph("", TelegraphType.POINT);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// GETTERS & SETTERS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
+24
-1
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
package kamkeel.npcs.controllers.data.telegraph;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -34,6 +34,10 @@ public class TelegraphInstance {
|
||||
// State
|
||||
private boolean isWarning = false;
|
||||
|
||||
// Server-side tracking (for removal)
|
||||
private transient World world;
|
||||
private transient int dimensionId;
|
||||
|
||||
public TelegraphInstance() {
|
||||
this.instanceId = UUID.randomUUID().toString().substring(0, 8);
|
||||
}
|
||||
@@ -303,4 +307,23 @@ public class TelegraphInstance {
|
||||
public void setWarning(boolean warning) {
|
||||
isWarning = warning;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void setWorld(World world) {
|
||||
this.world = world;
|
||||
if (world != null) {
|
||||
this.dimensionId = world.provider.dimensionId;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDimensionId() {
|
||||
return dimensionId;
|
||||
}
|
||||
|
||||
public void setDimensionId(int dimensionId) {
|
||||
this.dimensionId = dimensionId;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
package kamkeel.npcs.controllers.data.telegraph;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class TelegraphManager {
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// HELPER METHODS FOR ABILITIES
|
||||
// HELPER METHODS FOR SPAWNING
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
package kamkeel.npcs.controllers.data.telegraph;
|
||||
|
||||
/**
|
||||
* Types of telegraph shapes for visual attack warnings.
|
||||
@@ -26,8 +26,8 @@ import kamkeel.npcs.network.packets.data.SoundManagementPacket;
|
||||
import kamkeel.npcs.network.packets.data.SwingPlayerArmPacket;
|
||||
import kamkeel.npcs.network.packets.data.UpdateAnimationsPacket;
|
||||
import kamkeel.npcs.network.packets.data.VillagerListPacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphRemovePacket;
|
||||
import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenBookPacket;
|
||||
|
||||
+17
-3
@@ -1,9 +1,9 @@
|
||||
package kamkeel.npcs.network.packets.data.ability;
|
||||
package kamkeel.npcs.network.packets.data.telegraph;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
@@ -16,7 +16,7 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Packet to remove a telegraph on the client.
|
||||
* Sent from server to client when an ability's telegraph should be removed early.
|
||||
* Sent from server to client when a telegraph should be removed early.
|
||||
*/
|
||||
public final class TelegraphRemovePacket extends AbstractPacket {
|
||||
public static final String packetName = "Data|TelegraphRemove";
|
||||
@@ -67,4 +67,18 @@ public final class TelegraphRemovePacket extends AbstractPacket {
|
||||
public static void sendToTracking(String instanceId, net.minecraft.entity.Entity entity) {
|
||||
PacketHandler.Instance.sendTracking(new TelegraphRemovePacket(instanceId), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send remove to all players in a dimension.
|
||||
*/
|
||||
public static void sendToDimension(String instanceId, int dimensionId) {
|
||||
PacketHandler.Instance.sendToDimension(new TelegraphRemovePacket(instanceId), dimensionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send remove to all players on the server.
|
||||
*/
|
||||
public static void sendToAll(String instanceId) {
|
||||
PacketHandler.Instance.sendToAll(new TelegraphRemovePacket(instanceId));
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -1,10 +1,10 @@
|
||||
package kamkeel.npcs.network.packets.data.ability;
|
||||
package kamkeel.npcs.network.packets.data.telegraph;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
@@ -18,7 +18,7 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Packet to spawn a telegraph on the client.
|
||||
* Sent from server to client when an ability creates a telegraph.
|
||||
* Sent from server to client when a telegraph is created.
|
||||
*/
|
||||
public final class TelegraphSpawnPacket extends AbstractPacket {
|
||||
public static final String packetName = "Data|TelegraphSpawn";
|
||||
@@ -78,4 +78,11 @@ public final class TelegraphSpawnPacket extends AbstractPacket {
|
||||
public static void sendToDimension(TelegraphInstance instance, int dimensionId) {
|
||||
PacketHandler.Instance.sendToDimension(new TelegraphSpawnPacket(instance), dimensionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send telegraph to all players on the server.
|
||||
*/
|
||||
public static void sendToAll(TelegraphInstance instance) {
|
||||
PacketHandler.Instance.sendToAll(new TelegraphSpawnPacket(instance));
|
||||
}
|
||||
}
|
||||
@@ -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