mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 02:29:41 +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
@@ -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;
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Telegraph configuration - defines a visual warning shape.
|
||||
* Telegraphs warn players about incoming attacks.
|
||||
*/
|
||||
public class Telegraph {
|
||||
|
||||
// Identity
|
||||
private String id = "";
|
||||
private TelegraphType type = TelegraphType.CIRCLE;
|
||||
|
||||
// Shape parameters
|
||||
private float radius = 3.0f;
|
||||
private float innerRadius = 0.0f;
|
||||
private float length = 5.0f;
|
||||
private float width = 2.0f;
|
||||
private float angle = 45.0f;
|
||||
|
||||
// Timing
|
||||
private int durationTicks = 40;
|
||||
|
||||
// Visuals
|
||||
private int color = 0x80FF0000; // Semi-transparent red
|
||||
private int warningColor = 0xC0FF0000; // More opaque red
|
||||
private int warningStartTick = 10;
|
||||
private boolean animated = true;
|
||||
private float heightOffset = 0.1f;
|
||||
|
||||
// Positioning
|
||||
private boolean atTarget = true;
|
||||
private boolean followsTarget = false;
|
||||
private boolean followsCaster = false;
|
||||
private float offsetForward = 0.0f;
|
||||
|
||||
public Telegraph() {
|
||||
}
|
||||
|
||||
public Telegraph(String id, TelegraphType type) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Telegraph(Telegraph other) {
|
||||
this.id = other.id;
|
||||
this.type = other.type;
|
||||
this.radius = other.radius;
|
||||
this.innerRadius = other.innerRadius;
|
||||
this.length = other.length;
|
||||
this.width = other.width;
|
||||
this.angle = other.angle;
|
||||
this.durationTicks = other.durationTicks;
|
||||
this.color = other.color;
|
||||
this.warningColor = other.warningColor;
|
||||
this.warningStartTick = other.warningStartTick;
|
||||
this.animated = other.animated;
|
||||
this.heightOffset = other.heightOffset;
|
||||
this.atTarget = other.atTarget;
|
||||
this.followsTarget = other.followsTarget;
|
||||
this.followsCaster = other.followsCaster;
|
||||
this.offsetForward = other.offsetForward;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// NBT SERIALIZATION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("id", id);
|
||||
nbt.setString("type", type.name());
|
||||
nbt.setFloat("radius", radius);
|
||||
nbt.setFloat("innerRadius", innerRadius);
|
||||
nbt.setFloat("length", length);
|
||||
nbt.setFloat("width", width);
|
||||
nbt.setFloat("angle", angle);
|
||||
nbt.setInteger("durationTicks", durationTicks);
|
||||
nbt.setInteger("color", color);
|
||||
nbt.setInteger("warningColor", warningColor);
|
||||
nbt.setInteger("warningStartTick", warningStartTick);
|
||||
nbt.setBoolean("animated", animated);
|
||||
nbt.setFloat("heightOffset", heightOffset);
|
||||
nbt.setBoolean("atTarget", atTarget);
|
||||
nbt.setBoolean("followsTarget", followsTarget);
|
||||
nbt.setBoolean("followsCaster", followsCaster);
|
||||
nbt.setFloat("offsetForward", offsetForward);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.id = nbt.getString("id");
|
||||
if (nbt.hasKey("type")) {
|
||||
try {
|
||||
this.type = TelegraphType.valueOf(nbt.getString("type"));
|
||||
} catch (Exception e) {
|
||||
this.type = TelegraphType.CIRCLE;
|
||||
}
|
||||
}
|
||||
this.radius = nbt.getFloat("radius");
|
||||
this.innerRadius = nbt.getFloat("innerRadius");
|
||||
this.length = nbt.getFloat("length");
|
||||
this.width = nbt.getFloat("width");
|
||||
this.angle = nbt.getFloat("angle");
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
this.color = nbt.getInteger("color");
|
||||
this.warningColor = nbt.getInteger("warningColor");
|
||||
this.warningStartTick = nbt.getInteger("warningStartTick");
|
||||
this.animated = nbt.getBoolean("animated");
|
||||
this.heightOffset = nbt.getFloat("heightOffset");
|
||||
this.atTarget = nbt.getBoolean("atTarget");
|
||||
this.followsTarget = nbt.getBoolean("followsTarget");
|
||||
this.followsCaster = nbt.getBoolean("followsCaster");
|
||||
this.offsetForward = nbt.getFloat("offsetForward");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// FACTORY METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public static Telegraph circle(float radius) {
|
||||
Telegraph t = new Telegraph("", TelegraphType.CIRCLE);
|
||||
t.radius = radius;
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Telegraph ring(float outerRadius, float innerRadius) {
|
||||
Telegraph t = new Telegraph("", TelegraphType.RING);
|
||||
t.radius = outerRadius;
|
||||
t.innerRadius = innerRadius;
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Telegraph line(float length, float width) {
|
||||
Telegraph t = new Telegraph("", TelegraphType.LINE);
|
||||
t.length = length;
|
||||
t.width = width;
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Telegraph cone(float length, float angle) {
|
||||
Telegraph t = new Telegraph("", TelegraphType.CONE);
|
||||
t.length = length;
|
||||
t.angle = angle;
|
||||
return t;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// GETTERS & SETTERS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public TelegraphType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(TelegraphType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public float getInnerRadius() {
|
||||
return innerRadius;
|
||||
}
|
||||
|
||||
public void setInnerRadius(float innerRadius) {
|
||||
this.innerRadius = innerRadius;
|
||||
}
|
||||
|
||||
public float getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(float length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(float width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public float getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void setAngle(float angle) {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
public int getDurationTicks() {
|
||||
return durationTicks;
|
||||
}
|
||||
|
||||
public void setDurationTicks(int durationTicks) {
|
||||
this.durationTicks = durationTicks;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getWarningColor() {
|
||||
return warningColor;
|
||||
}
|
||||
|
||||
public void setWarningColor(int warningColor) {
|
||||
this.warningColor = warningColor;
|
||||
}
|
||||
|
||||
public int getWarningStartTick() {
|
||||
return warningStartTick;
|
||||
}
|
||||
|
||||
public void setWarningStartTick(int warningStartTick) {
|
||||
this.warningStartTick = warningStartTick;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
||||
public void setAnimated(boolean animated) {
|
||||
this.animated = animated;
|
||||
}
|
||||
|
||||
public float getHeightOffset() {
|
||||
return heightOffset;
|
||||
}
|
||||
|
||||
public void setHeightOffset(float heightOffset) {
|
||||
this.heightOffset = heightOffset;
|
||||
}
|
||||
|
||||
public boolean isAtTarget() {
|
||||
return atTarget;
|
||||
}
|
||||
|
||||
public void setAtTarget(boolean atTarget) {
|
||||
this.atTarget = atTarget;
|
||||
}
|
||||
|
||||
public boolean isFollowsTarget() {
|
||||
return followsTarget;
|
||||
}
|
||||
|
||||
public void setFollowsTarget(boolean followsTarget) {
|
||||
this.followsTarget = followsTarget;
|
||||
}
|
||||
|
||||
public boolean isFollowsCaster() {
|
||||
return followsCaster;
|
||||
}
|
||||
|
||||
public void setFollowsCaster(boolean followsCaster) {
|
||||
this.followsCaster = followsCaster;
|
||||
}
|
||||
|
||||
public float getOffsetForward() {
|
||||
return offsetForward;
|
||||
}
|
||||
|
||||
public void setOffsetForward(float offsetForward) {
|
||||
this.offsetForward = offsetForward;
|
||||
}
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Runtime instance of an active telegraph.
|
||||
* Tracks position, timing, and state for rendering.
|
||||
*/
|
||||
public class TelegraphInstance {
|
||||
|
||||
// Identity
|
||||
private String instanceId;
|
||||
private Telegraph telegraph;
|
||||
|
||||
// Position
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
|
||||
// Entity tracking
|
||||
private int entityIdToFollow = -1;
|
||||
private int casterEntityId = -1;
|
||||
|
||||
// Timing
|
||||
private int remainingTicks;
|
||||
private int totalTicks;
|
||||
|
||||
// State
|
||||
private boolean isWarning = false;
|
||||
|
||||
public TelegraphInstance() {
|
||||
this.instanceId = UUID.randomUUID().toString().substring(0, 8);
|
||||
}
|
||||
|
||||
public TelegraphInstance(Telegraph telegraph, double x, double y, double z, float yaw) {
|
||||
this();
|
||||
this.telegraph = new Telegraph(telegraph);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.remainingTicks = telegraph.getDurationTicks();
|
||||
this.totalTicks = telegraph.getDurationTicks();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// TICK LOGIC
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Called every tick to update telegraph state.
|
||||
*
|
||||
* @param world The world (for entity lookup)
|
||||
* @return false if telegraph should be removed
|
||||
*/
|
||||
public boolean tick(World world) {
|
||||
if (remainingTicks <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
remainingTicks--;
|
||||
|
||||
// Update position if following an entity
|
||||
if (entityIdToFollow >= 0 && world != null) {
|
||||
Entity entity = world.getEntityByID(entityIdToFollow);
|
||||
if (entity != null) {
|
||||
this.x = entity.posX;
|
||||
this.z = entity.posZ;
|
||||
// Find ground level below the entity for proper telegraph placement
|
||||
this.y = findGroundLevel(world, entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for warning phase transition
|
||||
if (!isWarning && telegraph != null) {
|
||||
if (remainingTicks <= telegraph.getWarningStartTick()) {
|
||||
isWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the ground level at a given position.
|
||||
* Searches downward from the given Y to find a solid block.
|
||||
*
|
||||
* @param world The world
|
||||
* @param x X coordinate
|
||||
* @param startY Starting Y coordinate (entity feet position)
|
||||
* @param z Z coordinate
|
||||
* @return The Y coordinate of the ground surface
|
||||
*/
|
||||
private double findGroundLevel(World world, double x, double startY, double z) {
|
||||
int blockX = (int) Math.floor(x);
|
||||
int blockZ = (int) Math.floor(z);
|
||||
int startBlockY = (int) Math.floor(startY);
|
||||
|
||||
// Search downward for solid ground (max 10 blocks down)
|
||||
for (int checkY = startBlockY; checkY >= startBlockY - 10 && checkY >= 0; checkY--) {
|
||||
Block block = world.getBlock(blockX, checkY, blockZ);
|
||||
if (block != null && block.getMaterial().isSolid()) {
|
||||
// Found solid block, telegraph goes on top of it
|
||||
return checkY + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// No ground found, use original position
|
||||
return startY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get progress from 0.0 (just started) to 1.0 (finished).
|
||||
*/
|
||||
public float getProgress() {
|
||||
if (totalTicks <= 0) return 1.0f;
|
||||
return 1.0f - ((float) remainingTicks / (float) totalTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current display color (normal or warning).
|
||||
*/
|
||||
public int getCurrentColor() {
|
||||
if (telegraph == null) return 0x80FF0000;
|
||||
return isWarning ? telegraph.getWarningColor() : telegraph.getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alpha-modulated color for pulsing animation.
|
||||
*/
|
||||
public int getAnimatedColor(float partialTicks) {
|
||||
int baseColor = getCurrentColor();
|
||||
if (telegraph == null || !telegraph.isAnimated()) {
|
||||
return baseColor;
|
||||
}
|
||||
|
||||
// Pulsing animation: modulate alpha based on time
|
||||
float time = (totalTicks - remainingTicks) + partialTicks;
|
||||
float pulse = (float) (Math.sin(time * 0.3) * 0.3 + 0.7); // 0.4 to 1.0 range
|
||||
|
||||
int alpha = (baseColor >> 24) & 0xFF;
|
||||
int r = (baseColor >> 16) & 0xFF;
|
||||
int g = (baseColor >> 8) & 0xFF;
|
||||
int b = baseColor & 0xFF;
|
||||
|
||||
alpha = (int) (alpha * pulse);
|
||||
|
||||
return (alpha << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// NBT SERIALIZATION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("instanceId", instanceId);
|
||||
|
||||
if (telegraph != null) {
|
||||
nbt.setTag("telegraph", telegraph.writeNBT());
|
||||
}
|
||||
|
||||
nbt.setDouble("x", x);
|
||||
nbt.setDouble("y", y);
|
||||
nbt.setDouble("z", z);
|
||||
nbt.setFloat("yaw", yaw);
|
||||
|
||||
nbt.setInteger("entityIdToFollow", entityIdToFollow);
|
||||
nbt.setInteger("casterEntityId", casterEntityId);
|
||||
|
||||
nbt.setInteger("remainingTicks", remainingTicks);
|
||||
nbt.setInteger("totalTicks", totalTicks);
|
||||
|
||||
nbt.setBoolean("isWarning", isWarning);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.instanceId = nbt.getString("instanceId");
|
||||
|
||||
if (nbt.hasKey("telegraph")) {
|
||||
this.telegraph = new Telegraph();
|
||||
this.telegraph.readNBT(nbt.getCompoundTag("telegraph"));
|
||||
}
|
||||
|
||||
this.x = nbt.getDouble("x");
|
||||
this.y = nbt.getDouble("y");
|
||||
this.z = nbt.getDouble("z");
|
||||
this.yaw = nbt.getFloat("yaw");
|
||||
|
||||
this.entityIdToFollow = nbt.getInteger("entityIdToFollow");
|
||||
this.casterEntityId = nbt.getInteger("casterEntityId");
|
||||
|
||||
this.remainingTicks = nbt.getInteger("remainingTicks");
|
||||
this.totalTicks = nbt.getInteger("totalTicks");
|
||||
|
||||
this.isWarning = nbt.getBoolean("isWarning");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// GETTERS & SETTERS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public void setInstanceId(String instanceId) {
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
|
||||
public Telegraph getTelegraph() {
|
||||
return telegraph;
|
||||
}
|
||||
|
||||
public void setTelegraph(Telegraph telegraph) {
|
||||
this.telegraph = telegraph;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public int getEntityIdToFollow() {
|
||||
return entityIdToFollow;
|
||||
}
|
||||
|
||||
public void setEntityIdToFollow(int entityIdToFollow) {
|
||||
this.entityIdToFollow = entityIdToFollow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the telegraph at its current position.
|
||||
* Stops following any entity - used when ability commits to action.
|
||||
*/
|
||||
public void lockPosition() {
|
||||
this.entityIdToFollow = -1;
|
||||
}
|
||||
|
||||
public int getCasterEntityId() {
|
||||
return casterEntityId;
|
||||
}
|
||||
|
||||
public void setCasterEntityId(int casterEntityId) {
|
||||
this.casterEntityId = casterEntityId;
|
||||
}
|
||||
|
||||
public int getRemainingTicks() {
|
||||
return remainingTicks;
|
||||
}
|
||||
|
||||
public void setRemainingTicks(int remainingTicks) {
|
||||
this.remainingTicks = remainingTicks;
|
||||
}
|
||||
|
||||
public int getTotalTicks() {
|
||||
return totalTicks;
|
||||
}
|
||||
|
||||
public void setTotalTicks(int totalTicks) {
|
||||
this.totalTicks = totalTicks;
|
||||
}
|
||||
|
||||
public boolean isWarning() {
|
||||
return isWarning;
|
||||
}
|
||||
|
||||
public void setWarning(boolean warning) {
|
||||
isWarning = warning;
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Manages active telegraph instances.
|
||||
* There's one instance per world (client and server).
|
||||
*/
|
||||
public class TelegraphManager {
|
||||
|
||||
/**
|
||||
* Client-side instance for rendering
|
||||
*/
|
||||
public static TelegraphManager ClientInstance;
|
||||
|
||||
private final ConcurrentHashMap<String, TelegraphInstance> telegraphs = new ConcurrentHashMap<>();
|
||||
|
||||
public TelegraphManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the client-side manager.
|
||||
* Call from client proxy during mod init.
|
||||
*/
|
||||
public static void initClient() {
|
||||
ClientInstance = new TelegraphManager();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// TELEGRAPH MANAGEMENT
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Add a new telegraph instance.
|
||||
*/
|
||||
public void addTelegraph(TelegraphInstance instance) {
|
||||
telegraphs.put(instance.getInstanceId(), instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a telegraph by ID.
|
||||
*/
|
||||
public void removeTelegraph(String instanceId) {
|
||||
telegraphs.remove(instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a telegraph by ID.
|
||||
*/
|
||||
public TelegraphInstance getTelegraph(String instanceId) {
|
||||
return telegraphs.get(instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active telegraphs for rendering.
|
||||
*/
|
||||
public Collection<TelegraphInstance> getTelegraphs() {
|
||||
return telegraphs.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all telegraphs.
|
||||
*/
|
||||
public void clear() {
|
||||
telegraphs.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any telegraphs are active.
|
||||
*/
|
||||
public boolean hasTelegraphs() {
|
||||
return !telegraphs.isEmpty();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// TICK
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Tick all telegraphs, removing expired ones.
|
||||
* Call from client tick handler.
|
||||
*/
|
||||
public void tick(World world) {
|
||||
Iterator<TelegraphInstance> iterator = telegraphs.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TelegraphInstance instance = iterator.next();
|
||||
if (!instance.tick(world)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// HELPER METHODS FOR ABILITIES
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Spawn a circle telegraph at a position.
|
||||
*/
|
||||
public TelegraphInstance spawnCircle(double x, double y, double z, float radius, int durationTicks, int color) {
|
||||
Telegraph telegraph = Telegraph.circle(radius);
|
||||
telegraph.setDurationTicks(durationTicks);
|
||||
telegraph.setColor(color);
|
||||
telegraph.setWarningColor((color & 0x00FFFFFF) | 0xC0000000);
|
||||
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, 0);
|
||||
addTelegraph(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a line telegraph from a position in a direction.
|
||||
*/
|
||||
public TelegraphInstance spawnLine(double x, double y, double z, float yaw, float length, float width, int durationTicks, int color) {
|
||||
Telegraph telegraph = Telegraph.line(length, width);
|
||||
telegraph.setDurationTicks(durationTicks);
|
||||
telegraph.setColor(color);
|
||||
telegraph.setWarningColor((color & 0x00FFFFFF) | 0xC0000000);
|
||||
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
addTelegraph(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a cone telegraph from a position in a direction.
|
||||
*/
|
||||
public TelegraphInstance spawnCone(double x, double y, double z, float yaw, float length, float angle, int durationTicks, int color) {
|
||||
Telegraph telegraph = Telegraph.cone(length, angle);
|
||||
telegraph.setDurationTicks(durationTicks);
|
||||
telegraph.setColor(color);
|
||||
telegraph.setWarningColor((color & 0x00FFFFFF) | 0xC0000000);
|
||||
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, x, y, z, yaw);
|
||||
addTelegraph(instance);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package kamkeel.npcs.controllers.data.ability.telegraph;
|
||||
|
||||
/**
|
||||
* Types of telegraph shapes for visual attack warnings.
|
||||
*/
|
||||
public enum TelegraphType {
|
||||
/**
|
||||
* Filled circle (uses radius)
|
||||
*/
|
||||
CIRCLE,
|
||||
|
||||
/**
|
||||
* Donut shape (uses radius and innerRadius)
|
||||
*/
|
||||
RING,
|
||||
|
||||
/**
|
||||
* Rectangle (uses length, width)
|
||||
*/
|
||||
LINE,
|
||||
|
||||
/**
|
||||
* Fan/wedge shape (uses length, angle)
|
||||
*/
|
||||
CONE,
|
||||
|
||||
/**
|
||||
* Single point indicator
|
||||
*/
|
||||
POINT,
|
||||
|
||||
/**
|
||||
* No telegraph
|
||||
*/
|
||||
NONE
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user