mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Add the Essential APIs
This commit is contained in:
1 parent
5e448c3324
commit
0833425d57
93 files changed
+4909
-1523
No files matched your search
@@ -0,0 +1,96 @@
|
||||
package kamkeel.npcs.platform;
|
||||
|
||||
import noppes.npcs.api.IDamageSource;
|
||||
import noppes.npcs.api.INbt;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.platform.nbt.NBTFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Central platform abstraction that bridges CORE logic with MC-version-specific code.
|
||||
*
|
||||
* Each mc* module (mc1710, mc1122, mc1165, mc1201) provides an implementation
|
||||
* that is registered during mod initialization via {@link PlatformServiceHolder#set(PlatformService)}.
|
||||
*
|
||||
* CORE code accesses this via {@link PlatformServiceHolder#get()}.
|
||||
*/
|
||||
public interface PlatformService {
|
||||
|
||||
// --- NBT ---
|
||||
|
||||
NBTFactory nbt();
|
||||
|
||||
// --- NBT I/O ---
|
||||
|
||||
INbt readCompressedNBT(File file) throws IOException;
|
||||
|
||||
void writeCompressedNBT(INbt compound, File file) throws IOException;
|
||||
|
||||
// --- Paths ---
|
||||
|
||||
File getWorldSaveDirectory();
|
||||
|
||||
File getWorldSaveDirectory(String subdir);
|
||||
|
||||
File getConfigDirectory();
|
||||
|
||||
// --- Environment ---
|
||||
|
||||
boolean isPhysicalClient();
|
||||
|
||||
String getModVersion();
|
||||
|
||||
// --- Logging ---
|
||||
|
||||
void logInfo(String message);
|
||||
|
||||
void logWarn(String message);
|
||||
|
||||
void logError(String message);
|
||||
|
||||
void logError(String message, Throwable t);
|
||||
|
||||
void logDebug(String message);
|
||||
|
||||
// --- Entity Wrapping ---
|
||||
|
||||
/**
|
||||
* Wraps a raw MC player entity.
|
||||
*/
|
||||
IPlayer wrapPlayer(Object mcPlayer);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC entity.
|
||||
*/
|
||||
IEntity wrapEntity(Object mcEntity);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC living entity.
|
||||
*/
|
||||
IEntityLivingBase wrapLiving(Object mcLiving);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC item stack.
|
||||
*/
|
||||
IItemStack wrapStack(Object mcStack);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC world.
|
||||
*/
|
||||
IWorld wrapWorld(Object mcWorld);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC damage source.
|
||||
*/
|
||||
IDamageSource wrapDamageSource(Object mcSource);
|
||||
|
||||
// --- Scheduling ---
|
||||
|
||||
void runOnMainThread(Runnable task);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package noppes.npcs.platform;
|
||||
package kamkeel.npcs.platform;
|
||||
|
||||
/**
|
||||
* Static accessor for the active {@link PlatformService} implementation.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package noppes.npcs.platform.config;
|
||||
package kamkeel.npcs.platform.config;
|
||||
|
||||
/**
|
||||
* Version-independent abstraction over Minecraft Forge's Configuration system.
|
||||
@@ -1,25 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
/**
|
||||
* Platform-independent damage source abstraction.
|
||||
*/
|
||||
public interface IDamage {
|
||||
|
||||
/**
|
||||
* @return the damage type identifier (e.g., "player", "mob", "generic")
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* @return the entity that caused this damage, or null if none (e.g., fall damage)
|
||||
*/
|
||||
IMob getSourceEntity();
|
||||
|
||||
/**
|
||||
* Returns the underlying MC DamageSource object.
|
||||
* Core code should NEVER call this.
|
||||
*
|
||||
* @return the raw MC DamageSource
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
/**
|
||||
* Platform-independent world abstraction.
|
||||
*/
|
||||
public interface IGameWorld {
|
||||
|
||||
/**
|
||||
* @return the dimension ID (e.g., 0 for overworld, -1 for nether)
|
||||
*/
|
||||
int getDimensionId();
|
||||
|
||||
/**
|
||||
* @return true if this is a client-side world
|
||||
*/
|
||||
boolean isClient();
|
||||
|
||||
/**
|
||||
* Look up an entity by its numeric ID.
|
||||
*
|
||||
* @param id the entity ID
|
||||
* @return the entity, or null if not found
|
||||
*/
|
||||
IMob getEntityById(int id);
|
||||
|
||||
/**
|
||||
* Returns the underlying MC World object.
|
||||
* Core code should NEVER call this.
|
||||
*
|
||||
* @return the raw MC World
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
/**
|
||||
* Platform-independent living entity abstraction.
|
||||
* Extends {@link IMob} with health and damage operations.
|
||||
*/
|
||||
public interface ILiving extends IMob {
|
||||
|
||||
float getHealth();
|
||||
|
||||
void setHealth(float hp);
|
||||
|
||||
float getMaxHealth();
|
||||
|
||||
/**
|
||||
* Deal damage to this entity.
|
||||
*
|
||||
* @param amount the damage amount
|
||||
* @param source the damage source, or null for generic damage
|
||||
*/
|
||||
void damage(float amount, IDamage source);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
/**
|
||||
* Platform-independent entity abstraction for core logic.
|
||||
* Thin interface — only exposes what core actually needs.
|
||||
*
|
||||
* Each MC version provides an implementation wrapping the native Entity class.
|
||||
* Use {@link #getHandle()} to retrieve the underlying MC object in platform code.
|
||||
*/
|
||||
public interface IMob {
|
||||
|
||||
/**
|
||||
* @return the entity's numeric ID in the world
|
||||
*/
|
||||
int getEntityId();
|
||||
|
||||
/**
|
||||
* @return the entity's UUID as a string
|
||||
*/
|
||||
String getUniqueID();
|
||||
|
||||
// --- Position ---
|
||||
|
||||
double getX();
|
||||
|
||||
double getY();
|
||||
|
||||
double getZ();
|
||||
|
||||
float getYaw();
|
||||
|
||||
float getPitch();
|
||||
|
||||
void setPosition(double x, double y, double z);
|
||||
|
||||
// --- State ---
|
||||
|
||||
/**
|
||||
* @return true if the entity exists and is not dead
|
||||
*/
|
||||
boolean isAlive();
|
||||
|
||||
/**
|
||||
* @return the dimension/world the entity is in
|
||||
*/
|
||||
IGameWorld getWorld();
|
||||
|
||||
// --- Escape hatch ---
|
||||
|
||||
/**
|
||||
* Returns the underlying MC entity object.
|
||||
* Platform code can cast this to the version-specific Entity class.
|
||||
* Core code should NEVER call this.
|
||||
*
|
||||
* @return the raw MC entity (e.g., net.minecraft.entity.Entity on 1.7.10)
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
import noppes.npcs.platform.nbt.INBTCompound;
|
||||
|
||||
/**
|
||||
* Platform-independent item stack abstraction.
|
||||
*/
|
||||
public interface IStack {
|
||||
|
||||
/**
|
||||
* @return the item's registry ID (e.g., "minecraft:stone")
|
||||
*/
|
||||
String getItemId();
|
||||
|
||||
int getCount();
|
||||
|
||||
void setCount(int count);
|
||||
|
||||
/**
|
||||
* @return the item's damage/metadata value
|
||||
*/
|
||||
int getDamage();
|
||||
|
||||
void setDamage(int dmg);
|
||||
|
||||
/**
|
||||
* @return the stack's NBT tag compound, or null if none
|
||||
*/
|
||||
INBTCompound getTag();
|
||||
|
||||
void setTag(INBTCompound tag);
|
||||
|
||||
/**
|
||||
* @return true if this stack is empty (null item or count <= 0)
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* @return a deep copy of this stack
|
||||
*/
|
||||
IStack copy();
|
||||
|
||||
/**
|
||||
* Returns the underlying MC ItemStack object.
|
||||
* Core code should NEVER call this.
|
||||
*
|
||||
* @return the raw MC ItemStack
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package kamkeel.npcs.platform.entity;
|
||||
|
||||
/**
|
||||
* Platform-independent player abstraction.
|
||||
* Extends {@link ILiving} with player-specific operations.
|
||||
*/
|
||||
public interface IUser extends ILiving {
|
||||
|
||||
/**
|
||||
* @return the player's username
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return the player's UUID as a string
|
||||
*/
|
||||
@Override
|
||||
String getUniqueID();
|
||||
|
||||
/**
|
||||
* @return true if the player is a server operator
|
||||
*/
|
||||
boolean isOp();
|
||||
|
||||
/**
|
||||
* Send a chat message to this player.
|
||||
*
|
||||
* @param text plain text message
|
||||
*/
|
||||
void sendMessage(String text);
|
||||
|
||||
/**
|
||||
* @return the item currently held in the player's main hand, or null if empty
|
||||
*/
|
||||
IStack getHeldItem();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package noppes.npcs.api;
|
||||
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
|
||||
/**
|
||||
* Platform-api version (MC-free). The src/api shadow adds typed getMCDamageSource().
|
||||
*/
|
||||
public interface IDamageSource {
|
||||
|
||||
String getType();
|
||||
|
||||
boolean isUnblockable();
|
||||
|
||||
boolean isProjectile();
|
||||
|
||||
IEntity getTrueSource();
|
||||
|
||||
IEntity getImmediateSource();
|
||||
|
||||
/**
|
||||
* Returns the underlying MC DamageSource object.
|
||||
* Expert use only. Returns Object in platform-api; shadow narrows to DamageSource.
|
||||
*/
|
||||
Object getMCDamageSource();
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package noppes.npcs.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Unified NBT compound interface — used by both CORE logic and scripting.
|
||||
*
|
||||
* Platform-api version (MC-free). The src/api shadow adds typed MC methods
|
||||
* (e.g., {@code NBTTagCompound getMCNBT()}).
|
||||
*
|
||||
* <p>Compound tags contain uniquely-keyed tags of various types:
|
||||
* <pre>
|
||||
* 1: Byte 2: Short 3: Int 4: Long
|
||||
* 5: Float 6: Double 7: Byte[] 8: String
|
||||
* 9: List 10: Compound 11: Int[]
|
||||
* </pre>
|
||||
*/
|
||||
public interface INbt {
|
||||
|
||||
// ======================== Setters ========================
|
||||
|
||||
void setString(String key, String value);
|
||||
|
||||
void setInteger(String key, int value);
|
||||
|
||||
void setBoolean(String key, boolean value);
|
||||
|
||||
void setDouble(String key, double value);
|
||||
|
||||
void setFloat(String key, float value);
|
||||
|
||||
void setLong(String key, long value);
|
||||
|
||||
void setShort(String key, short value);
|
||||
|
||||
void setByte(String key, byte value);
|
||||
|
||||
void setByteArray(String key, byte[] value);
|
||||
|
||||
void setIntArray(String key, int[] value);
|
||||
|
||||
/**
|
||||
* Alias for {@link #setIntArray(String, int[])}.
|
||||
*/
|
||||
default void setIntegerArray(String key, int[] value) {
|
||||
setIntArray(key, value);
|
||||
}
|
||||
|
||||
void setCompound(String key, INbt compound);
|
||||
|
||||
/**
|
||||
* Alias for {@link #setCompound(String, INbt)}.
|
||||
*/
|
||||
default void setTag(String key, INbt compound) {
|
||||
setCompound(key, compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a list from an Object array. Elements can be: INbt, String, Double, Float, Integer, int[].
|
||||
*/
|
||||
void setList(String key, Object[] value);
|
||||
|
||||
/**
|
||||
* Sets a typed tag list on this compound.
|
||||
*/
|
||||
void setTagList(String key, INbtList list);
|
||||
|
||||
// ======================== Getters ========================
|
||||
|
||||
String getString(String key);
|
||||
|
||||
int getInteger(String key);
|
||||
|
||||
boolean getBoolean(String key);
|
||||
|
||||
double getDouble(String key);
|
||||
|
||||
float getFloat(String key);
|
||||
|
||||
long getLong(String key);
|
||||
|
||||
short getShort(String key);
|
||||
|
||||
byte getByte(String key);
|
||||
|
||||
byte[] getByteArray(String key);
|
||||
|
||||
int[] getIntArray(String key);
|
||||
|
||||
/**
|
||||
* Alias for {@link #getIntArray(String)}.
|
||||
*/
|
||||
default int[] getIntegerArray(String key) {
|
||||
return getIntArray(key);
|
||||
}
|
||||
|
||||
INbt getCompound(String key);
|
||||
|
||||
/**
|
||||
* Returns a tag list as an Object array. Elements are typed based on list type:
|
||||
* INbt (compounds), String, Double, Float, Integer, int[].
|
||||
*/
|
||||
Object[] getList(String key, int type);
|
||||
|
||||
/**
|
||||
* Gets a typed tag list from this compound.
|
||||
*
|
||||
* @param key the key
|
||||
* @param type the element type ID (e.g. 10 for compounds, 8 for strings)
|
||||
* @return the list, or an empty list if the key doesn't exist
|
||||
*/
|
||||
INbtList getTagList(String key, int type);
|
||||
|
||||
/**
|
||||
* Returns the type of the list tag with the given key.
|
||||
*
|
||||
* @return the element type ID, or 0 if not a list tag
|
||||
*/
|
||||
int getListType(String key);
|
||||
|
||||
// ======================== Query ========================
|
||||
|
||||
/**
|
||||
* @return true if this compound has a tag with the given key
|
||||
*/
|
||||
boolean hasKey(String key);
|
||||
|
||||
/**
|
||||
* Alias for {@link #hasKey(String)}.
|
||||
*/
|
||||
default boolean has(String key) {
|
||||
return hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this compound has a key of a specific NBT type.
|
||||
*/
|
||||
boolean hasKey(String key, int type);
|
||||
|
||||
/**
|
||||
* @return a set of all keys in this compound
|
||||
*/
|
||||
Set<String> getKeySet();
|
||||
|
||||
/**
|
||||
* @return all keys as a String array
|
||||
*/
|
||||
default String[] getKeys() {
|
||||
return getKeySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the tag with the given key.
|
||||
*/
|
||||
void removeTag(String key);
|
||||
|
||||
/**
|
||||
* Alias for {@link #removeTag(String)}.
|
||||
*/
|
||||
default void remove(String key) {
|
||||
removeTag(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NBT type ID for the tag with the given key.
|
||||
*
|
||||
* @return the type ID, or 0 if not present
|
||||
*/
|
||||
int getTagType(String key);
|
||||
|
||||
/**
|
||||
* Alias for {@link #getTagType(String)}.
|
||||
*/
|
||||
default int getType(String key) {
|
||||
return getTagType(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this compound has no keys
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
// ======================== Interop ========================
|
||||
|
||||
/**
|
||||
* Merges all tags from the given compound into this one.
|
||||
*/
|
||||
void merge(INbt other);
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this compound.
|
||||
*/
|
||||
INbt copy();
|
||||
|
||||
/**
|
||||
* Returns the underlying MC NBT object.
|
||||
* Returns Object in platform-api; the src/api shadow narrows to the MC type.
|
||||
* CORE code should NEVER call this — only mc* modules should.
|
||||
*/
|
||||
Object getMCNBT();
|
||||
|
||||
// ======================== Convenience ========================
|
||||
|
||||
/**
|
||||
* @return a JSON string representation of this compound
|
||||
*/
|
||||
String toJsonString();
|
||||
|
||||
/**
|
||||
* @return true if this compound has the same data as the given compound
|
||||
*/
|
||||
boolean isEqual(INbt nbt);
|
||||
|
||||
/**
|
||||
* Removes all tags from this compound.
|
||||
*/
|
||||
void clear();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package noppes.npcs.api;
|
||||
|
||||
/**
|
||||
* Version-independent abstraction over Minecraft's NBT list tag.
|
||||
*
|
||||
* Platform-api version (MC-free). The src/api shadow may add MC-typed methods.
|
||||
*/
|
||||
public interface INbtList {
|
||||
|
||||
int size();
|
||||
|
||||
INbt getCompound(int index);
|
||||
|
||||
String getString(int index);
|
||||
|
||||
int getInt(int index);
|
||||
|
||||
double getDouble(int index);
|
||||
|
||||
float getFloat(int index);
|
||||
|
||||
int[] getIntArray(int index);
|
||||
|
||||
/**
|
||||
* @return the NBT type ID of elements in this list, or 0 if empty
|
||||
*/
|
||||
int getElementType();
|
||||
|
||||
// --- Mutators ---
|
||||
|
||||
void addCompound(INbt compound);
|
||||
|
||||
void addString(String value);
|
||||
|
||||
void addInt(int value);
|
||||
|
||||
void addDouble(double value);
|
||||
|
||||
void remove(int index);
|
||||
|
||||
/**
|
||||
* Returns the underlying MC NBT list object.
|
||||
* CORE code should NEVER call this — only mc* modules should.
|
||||
*/
|
||||
Object getMCTagList();
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package noppes.npcs.api;
|
||||
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
|
||||
public interface IWorld {
|
||||
/**
|
||||
* @return The worlds time
|
||||
*/
|
||||
long getTime();
|
||||
|
||||
/**
|
||||
* @return The total world time
|
||||
*/
|
||||
long getTotalTime();
|
||||
|
||||
boolean areAllPlayersAsleep();
|
||||
|
||||
boolean isBlockFreezable(IPos pos);
|
||||
|
||||
boolean isBlockFreezable(int x, int y, int z);
|
||||
|
||||
boolean isBlockFreezableNaturally(IPos pos);
|
||||
|
||||
boolean isBlockFreezableNaturally(int x, int y, int z);
|
||||
|
||||
boolean canBlockFreeze(IPos pos, boolean adjacentToWater);
|
||||
|
||||
boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater);
|
||||
|
||||
boolean canBlockFreezeBody(IPos pos, boolean adjacentToWater);
|
||||
|
||||
boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater);
|
||||
|
||||
boolean canSnowAt(IPos pos, boolean checkLight);
|
||||
|
||||
boolean canSnowAt(int x, int y, int z, boolean checkLight);
|
||||
|
||||
boolean canSnowAtBody(IPos pos, boolean checkLight);
|
||||
|
||||
boolean canSnowAtBody(int x, int y, int z, boolean checkLight);
|
||||
|
||||
/**
|
||||
* @param x X coordinate
|
||||
* @param z Z coordinate
|
||||
* @return The Y-value of the world at this x & z value based on the height map of the world.
|
||||
*/
|
||||
int getHeightValue(int x, int z);
|
||||
|
||||
int getHeightValue(IPos pos);
|
||||
|
||||
/**
|
||||
* @param x X coordinate
|
||||
* @param z Z coordinate
|
||||
* @return The minimum Y-value of the world at this x & z value based on the height map of the world.
|
||||
*/
|
||||
int getChunkHeightMapMinimum(int x, int z);
|
||||
|
||||
int getChunkHeightMapMinimum(IPos pos);
|
||||
|
||||
/**
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return The metadata of the block at this position.
|
||||
*/
|
||||
int getBlockMetadata(int x, int y, int z);
|
||||
|
||||
int getBlockMetadata(IPos pos);
|
||||
|
||||
boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag);
|
||||
|
||||
boolean setBlockMetadataWithNotify(IPos pos, int metadata, int flag);
|
||||
|
||||
/**
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return can the block at this position see the sky or are there no blocks above this one
|
||||
*/
|
||||
boolean canSeeSky(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @param pos the block position
|
||||
* @return can the block at this position see the sky or are there no blocks above this one
|
||||
*/
|
||||
boolean canSeeSky(IPos pos);
|
||||
|
||||
int getFullBlockLightValue(int x, int y, int z);
|
||||
|
||||
int getFullBlockLightValue(IPos pos);
|
||||
|
||||
int getBlockLightValue(int x, int y, int z);
|
||||
|
||||
int getBlockLightValue(IPos pos);
|
||||
|
||||
void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch);
|
||||
|
||||
void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch);
|
||||
|
||||
IEntity getEntityByID(int id);
|
||||
|
||||
boolean spawnEntityInWorld(IEntity entity);
|
||||
|
||||
IPlayer getClosestPlayerToEntity(IEntity entity, double range);
|
||||
|
||||
IPlayer getClosestPlayer(double x, double y, double z, double range);
|
||||
|
||||
IPlayer getClosestPlayer(IPos pos, double range);
|
||||
|
||||
IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range);
|
||||
|
||||
IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
|
||||
|
||||
IPlayer getClosestVulnerablePlayer(IPos pos, double range);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entity The entity whose type will be used as a parameter
|
||||
* @return The amount of entities of the given type in the world.
|
||||
*/
|
||||
int countEntities(IEntity entity);
|
||||
|
||||
IEntity[] getLoadedEntities();
|
||||
|
||||
IEntity[] getEntitiesNear(IPos position, double range);
|
||||
|
||||
IEntity[] getEntitiesNear(double x, double y, double z, double range);
|
||||
|
||||
/**
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return True if the block at this position is of cubic shape. (Not a stair, slab, etc.)
|
||||
*/
|
||||
boolean isBlockFullCube(int x, int y, int z);
|
||||
|
||||
boolean isBlockFullCube(IPos pos);
|
||||
|
||||
long getSeed();
|
||||
|
||||
void setSpawnLocation(int x, int y, int z);
|
||||
|
||||
void setSpawnLocation(IPos pos);
|
||||
|
||||
boolean canLightningStrikeAt(int x, int y, int z);
|
||||
|
||||
boolean canLightningStrikeAt(IPos pos);
|
||||
|
||||
boolean isBlockHighHumidity(int x, int y, int z);
|
||||
|
||||
boolean isBlockHighHumidity(IPos pos);
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
* @return Text from signs
|
||||
* @since 1.7.10d
|
||||
*/
|
||||
String getSignText(int x, int y, int z);
|
||||
|
||||
String getSignText(IPos pos);
|
||||
|
||||
boolean isPlaceCancelled(int posX, int posY, int posZ);
|
||||
|
||||
boolean isPlaceCancelled(IPos pos);
|
||||
|
||||
boolean isBreakCancelled(int posX, int posY, int posZ);
|
||||
|
||||
boolean isBreakCancelled(IPos pos);
|
||||
|
||||
IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance);
|
||||
|
||||
IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance);
|
||||
|
||||
/**
|
||||
* @param startPos the start position as [x, y, z]
|
||||
* @param maxHeight maximum search height
|
||||
* @return the position of the closest block of air to startPos
|
||||
*/
|
||||
IPos getNearestAir(IPos startPos, int maxHeight);
|
||||
|
||||
IEntity[] rayCastEntities(double[] startPos, double[] lookVector, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] rayCastEntities(IEntity[] ignoreEntities, double[] startPos, double[] lookVector, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] rayCastEntities(IPos startPos, IPos lookVector, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] rayCastEntities(double[] startPos, double[] lookVector, int maxDistance, double offset, double range);
|
||||
|
||||
IEntity[] rayCastEntities(IPos startPos, IPos lookVector, int maxDistance, double offset, double range);
|
||||
|
||||
/**
|
||||
* @param name The name of the player to be returned
|
||||
* @return The Player with name. Null is returned when the player isnt found
|
||||
*/
|
||||
IPlayer getPlayer(String name);
|
||||
|
||||
IPlayer getPlayerByUUID(String uuid);
|
||||
|
||||
/**
|
||||
* @param time The world time to be set
|
||||
*/
|
||||
void setTime(long time);
|
||||
|
||||
/**
|
||||
* @return Whether or not its daytime
|
||||
*/
|
||||
boolean isDay();
|
||||
|
||||
/**
|
||||
* @return Whether or not its currently raining
|
||||
*/
|
||||
boolean isRaining();
|
||||
|
||||
/**
|
||||
* @param bo Set if it's raining
|
||||
*/
|
||||
void setRaining(boolean bo);
|
||||
|
||||
/**
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param z The z position
|
||||
*/
|
||||
void thunderStrike(double x, double y, double z);
|
||||
|
||||
void thunderStrike(IPos pos);
|
||||
|
||||
/**
|
||||
* @param id The items name
|
||||
* @param damage The damage value
|
||||
* @param size The number of items in the item
|
||||
* @return Returns the item
|
||||
*/
|
||||
IItemStack createItem(String id, int damage, int size);
|
||||
|
||||
@Deprecated
|
||||
Object getTempData(String key);
|
||||
|
||||
@Deprecated
|
||||
void setTempData(String key, Object value);
|
||||
|
||||
@Deprecated
|
||||
boolean hasTempData(String key);
|
||||
|
||||
@Deprecated
|
||||
void removeTempData(String key);
|
||||
|
||||
@Deprecated
|
||||
void clearTempData();
|
||||
|
||||
@Deprecated
|
||||
String[] getTempDataKeys();
|
||||
|
||||
@Deprecated
|
||||
Object getStoredData(String key);
|
||||
|
||||
@Deprecated
|
||||
void setStoredData(String key, Object value);
|
||||
|
||||
@Deprecated
|
||||
boolean hasStoredData(String key);
|
||||
|
||||
@Deprecated
|
||||
void removeStoredData(String key);
|
||||
|
||||
@Deprecated
|
||||
void clearStoredData();
|
||||
|
||||
String[] getStoredDataKeys();
|
||||
|
||||
/**
|
||||
* @param x Position x
|
||||
* @param y Position y
|
||||
* @param z Position z
|
||||
* @param range Range of the explosion
|
||||
* @param fire Whether or not the explosion does fire damage
|
||||
* @param grief Whether or not the explosion does damage to blocks
|
||||
*/
|
||||
void explode(double x, double y, double z, float range, boolean fire, boolean grief);
|
||||
|
||||
void explode(IPos pos, float range, boolean fire, boolean grief);
|
||||
|
||||
IPlayer[] getAllServerPlayers();
|
||||
|
||||
String[] getPlayerNames();
|
||||
|
||||
/**
|
||||
* @param x Position x
|
||||
* @param z Position z
|
||||
* @return Returns the name of the biome
|
||||
* @since 1.7.10c
|
||||
*/
|
||||
String getBiomeName(int x, int z);
|
||||
|
||||
String getBiomeName(IPos pos);
|
||||
|
||||
/**
|
||||
* Lets you spawn a server side cloned entity
|
||||
*
|
||||
* @param x The x position the clone will be spawned at
|
||||
* @param y The y position the clone will be spawned at
|
||||
* @param z The z position the clone will be spawned at
|
||||
* @param tab The tab in which the clone is
|
||||
* @param name Name of the cloned entity
|
||||
* @param ignoreProtection Whether the spawning of this clone skips protection checks.
|
||||
* @return Returns the entity which was spawned
|
||||
*/
|
||||
IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection);
|
||||
|
||||
IEntity spawnClone(IPos pos, int tab, String name, boolean ignoreProtection);
|
||||
|
||||
IEntity spawnClone(int x, int y, int z, int tab, String name);
|
||||
|
||||
IEntity spawnClone(IPos pos, int tab, String name);
|
||||
|
||||
/**
|
||||
* @return Returns minecraft world object
|
||||
* @since 1.7.10c
|
||||
* Expert use only
|
||||
*/
|
||||
Object getMCWorld();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The ID of this world's dimension. 0 for overworld, 1 for End, -1 for Nether, etc.
|
||||
*/
|
||||
int getDimensionID();
|
||||
|
||||
void broadcast(String message);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package noppes.npcs.api.entity;
|
||||
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
|
||||
public interface IAnimatable {
|
||||
|
||||
IAnimationData getAnimationData();
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,596 @@
|
||||
package noppes.npcs.api.entity;
|
||||
|
||||
import noppes.npcs.api.INbt;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
|
||||
/**
|
||||
* Represents a generic entity in the world.
|
||||
* Provides methods to access or modify the entity's position, motion, temporary and persistent data,
|
||||
* and to perform various actions (such as dropping items or changing dimensions).
|
||||
*/
|
||||
public interface IEntity {
|
||||
|
||||
/**
|
||||
* Returns the unique entity ID.
|
||||
*
|
||||
* @return the entity ID.
|
||||
*/
|
||||
int getEntityId();
|
||||
|
||||
/**
|
||||
* Returns the unique UUID string of the entity.
|
||||
*
|
||||
* @return the unique ID.
|
||||
*/
|
||||
String getUniqueID();
|
||||
|
||||
/**
|
||||
* Returns the vertical offset for rendering.
|
||||
*
|
||||
* @return the Y offset.
|
||||
*/
|
||||
double getYOffset();
|
||||
|
||||
/**
|
||||
* @return The entity's width.
|
||||
*/
|
||||
double getWidth();
|
||||
|
||||
/**
|
||||
* @return The entity's height.
|
||||
*/
|
||||
double getHeight();
|
||||
|
||||
/**
|
||||
* @return The entity's x position.
|
||||
*/
|
||||
double getX();
|
||||
|
||||
/**
|
||||
* Sets the entity's x position.
|
||||
*
|
||||
* @param x the new x position.
|
||||
*/
|
||||
void setX(double x);
|
||||
|
||||
/**
|
||||
* @return The entity's y position.
|
||||
*/
|
||||
double getY();
|
||||
|
||||
/**
|
||||
* Sets the entity's y position.
|
||||
*
|
||||
* @param y the new y position.
|
||||
*/
|
||||
void setY(double y);
|
||||
|
||||
/**
|
||||
* @return The entity's z position.
|
||||
*/
|
||||
double getZ();
|
||||
|
||||
/**
|
||||
* Sets the entity's z position.
|
||||
*
|
||||
* @param z the new z position.
|
||||
*/
|
||||
void setZ(double z);
|
||||
|
||||
/**
|
||||
* @return The entity's x motion.
|
||||
*/
|
||||
double getMotionX();
|
||||
|
||||
/**
|
||||
* Sets the entity's x motion.
|
||||
*
|
||||
* @param x the new x motion.
|
||||
*/
|
||||
void setMotionX(double x);
|
||||
|
||||
/**
|
||||
* @return The entity's y motion.
|
||||
*/
|
||||
double getMotionY();
|
||||
|
||||
/**
|
||||
* Sets the entity's y motion.
|
||||
*
|
||||
* @param y the new y motion.
|
||||
*/
|
||||
void setMotionY(double y);
|
||||
|
||||
/**
|
||||
* @return The entity's z motion.
|
||||
*/
|
||||
double getMotionZ();
|
||||
|
||||
/**
|
||||
* Sets the entity's z motion.
|
||||
*
|
||||
* @param z the new z motion.
|
||||
*/
|
||||
void setMotionZ(double z);
|
||||
|
||||
/**
|
||||
* Convenience method to set the entity's motion in all three axes.
|
||||
*
|
||||
* @param x the x motion.
|
||||
* @param y the y motion.
|
||||
* @param z the z motion.
|
||||
*/
|
||||
void setMotion(double x, double y, double z);
|
||||
|
||||
/**
|
||||
* Sets the entity's motion based on the given position.
|
||||
*
|
||||
* @param pos the position containing motion components.
|
||||
*/
|
||||
void setMotion(IPos pos);
|
||||
|
||||
/**
|
||||
* Returns the entity's current motion as an IPos object.
|
||||
*
|
||||
* @return the motion vector.
|
||||
*/
|
||||
IPos getMotion();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is airborne.
|
||||
*/
|
||||
boolean isAirborne();
|
||||
|
||||
/**
|
||||
* @return The block (integer) x position.
|
||||
*/
|
||||
int getBlockX();
|
||||
|
||||
/**
|
||||
* @return The block (integer) y position.
|
||||
*/
|
||||
int getBlockY();
|
||||
|
||||
/**
|
||||
* @return The block (integer) z position.
|
||||
*/
|
||||
int getBlockZ();
|
||||
|
||||
/**
|
||||
* Sets the entity's position to the specified coordinates.
|
||||
*
|
||||
* @param x the x coordinate.
|
||||
* @param y the y coordinate.
|
||||
* @param z the z coordinate.
|
||||
*/
|
||||
void setPosition(double x, double y, double z);
|
||||
|
||||
/**
|
||||
* Sets the entity's position using an IPos object.
|
||||
*
|
||||
* @param pos the position object.
|
||||
*/
|
||||
void setPosition(IPos pos);
|
||||
|
||||
/**
|
||||
* Returns the entity's current position as an IPos object.
|
||||
*
|
||||
* @return the position.
|
||||
*/
|
||||
IPos getPosition();
|
||||
|
||||
/**
|
||||
* @return The dimension ID the entity is in.
|
||||
*/
|
||||
int getDimension();
|
||||
|
||||
/**
|
||||
* Moves the entity to the specified dimension.
|
||||
*
|
||||
* @param dimensionId the dimension ID.
|
||||
*/
|
||||
void setDimension(int dimensionId);
|
||||
|
||||
/**
|
||||
* @return Array of entities that are colliding with this entity
|
||||
*/
|
||||
IEntity[] getCollidingEntities();
|
||||
|
||||
/**
|
||||
* Returns an array of entities within the specified range.
|
||||
*
|
||||
* @param range the search range.
|
||||
* @return an array of surrounding entities.
|
||||
*/
|
||||
IEntity[] getSurroundingEntities(int range);
|
||||
|
||||
/**
|
||||
* Returns an array of entities of a specified type within the given range.
|
||||
*
|
||||
* @param range the search range.
|
||||
* @param type the EntityType to find.
|
||||
* @return an array of surrounding entities.
|
||||
*/
|
||||
IEntity[] getSurroundingEntities(int range, int type);
|
||||
|
||||
/**
|
||||
* @return Whether the entity is alive.
|
||||
*/
|
||||
boolean isAlive();
|
||||
|
||||
/**
|
||||
* Returns temporary data stored under the given key.
|
||||
*
|
||||
* @param key the key.
|
||||
* @return the temporary data.
|
||||
*/
|
||||
Object getTempData(String key);
|
||||
|
||||
/**
|
||||
* Stores temporary data that is cleared when the entity is unloaded.
|
||||
*
|
||||
* @param key the key.
|
||||
* @param value the value.
|
||||
*/
|
||||
void setTempData(String key, Object value);
|
||||
|
||||
/**
|
||||
* Checks if temporary data for the given key exists.
|
||||
*
|
||||
* @param key the key.
|
||||
* @return true if it exists; false otherwise.
|
||||
*/
|
||||
boolean hasTempData(String key);
|
||||
|
||||
/**
|
||||
* Removes the temporary data for the given key.
|
||||
*
|
||||
* @param key the key.
|
||||
*/
|
||||
void removeTempData(String key);
|
||||
|
||||
/**
|
||||
* Clears all temporary data.
|
||||
*/
|
||||
void clearTempData();
|
||||
|
||||
/**
|
||||
* Returns an array of keys for temporary data.
|
||||
*
|
||||
* @return the keys.
|
||||
*/
|
||||
String[] getTempDataKeys();
|
||||
|
||||
/**
|
||||
* Returns stored (persistent) data for the given key.
|
||||
*
|
||||
* @param key the key.
|
||||
* @return the stored data.
|
||||
*/
|
||||
Object getStoredData(String key);
|
||||
|
||||
/**
|
||||
* Stores persistent data under the given key.
|
||||
* Only Numbers and Strings are supported.
|
||||
*
|
||||
* @param key the key.
|
||||
* @param value the value.
|
||||
*/
|
||||
void setStoredData(String key, Object value);
|
||||
|
||||
/**
|
||||
* Checks if stored data for the given key exists.
|
||||
*
|
||||
* @param key the key.
|
||||
* @return true if it exists; false otherwise.
|
||||
*/
|
||||
boolean hasStoredData(String key);
|
||||
|
||||
/**
|
||||
* Removes the stored data for the given key.
|
||||
*
|
||||
* @param key the key.
|
||||
*/
|
||||
void removeStoredData(String key);
|
||||
|
||||
/**
|
||||
* Clears all stored data.
|
||||
*/
|
||||
void clearStoredData();
|
||||
|
||||
/**
|
||||
* Returns an array of keys for stored data.
|
||||
*
|
||||
* @return the keys.
|
||||
*/
|
||||
String[] getStoredDataKeys();
|
||||
|
||||
/**
|
||||
* @return The age of the entity in ticks.
|
||||
*/
|
||||
long getAge();
|
||||
|
||||
/**
|
||||
* Permanently despawns the entity.
|
||||
*/
|
||||
void despawn();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is standing in water.
|
||||
*/
|
||||
boolean inWater();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is standing in lava.
|
||||
*/
|
||||
boolean inLava();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is standing in fire.
|
||||
*/
|
||||
boolean inFire();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is on fire.
|
||||
*/
|
||||
boolean isBurning();
|
||||
|
||||
/**
|
||||
* Sets the entity on fire for the given number of ticks (20 ticks = 1 second).
|
||||
*
|
||||
* @param ticks the burn duration.
|
||||
*/
|
||||
void setBurning(int ticks);
|
||||
|
||||
/**
|
||||
* Extinguishes any fire on the entity.
|
||||
*/
|
||||
void extinguish();
|
||||
|
||||
/**
|
||||
* @return The entity type name as registered in Minecraft.
|
||||
*/
|
||||
String getTypeName();
|
||||
|
||||
/**
|
||||
* Causes the entity to drop the given item.
|
||||
*
|
||||
* @param item the item to drop.
|
||||
*/
|
||||
void dropItem(IItemStack item);
|
||||
|
||||
/**
|
||||
* @return The entity riding this entity.
|
||||
*/
|
||||
IEntity getRider();
|
||||
|
||||
/**
|
||||
* Sets the given entity as the rider of this entity.
|
||||
*
|
||||
* @param entity the rider.
|
||||
*/
|
||||
void setRider(IEntity entity);
|
||||
|
||||
/**
|
||||
* @return The entity this entity is riding.
|
||||
*/
|
||||
IEntity getMount();
|
||||
|
||||
/**
|
||||
* Sets the entity to be mounted by this entity.
|
||||
*
|
||||
* @param entity the mount.
|
||||
*/
|
||||
void setMount(IEntity entity);
|
||||
|
||||
/**
|
||||
* Returns the EntityType as defined in the scripting constants.
|
||||
*
|
||||
* @return the EntityType.
|
||||
*/
|
||||
int getType();
|
||||
|
||||
/**
|
||||
* Checks whether the entity is of the specified EntityType.
|
||||
*
|
||||
* @param type the type to check.
|
||||
* @return true if the entity is of that type; false otherwise.
|
||||
*/
|
||||
boolean typeOf(int type);
|
||||
|
||||
/**
|
||||
* Sets the entity's rotation (yaw) in degrees (0-360).
|
||||
*
|
||||
* @param rotation the rotation angle.
|
||||
*/
|
||||
void setRotation(float rotation);
|
||||
|
||||
/**
|
||||
* Sets both the rotation (yaw) and pitch of the entity.
|
||||
*
|
||||
* @param rotationYaw the yaw angle.
|
||||
* @param rotationPitch the pitch angle.
|
||||
*/
|
||||
void setRotation(float rotationYaw, float rotationPitch);
|
||||
|
||||
/**
|
||||
* @return The current rotation (yaw) of the entity.
|
||||
*/
|
||||
float getRotation();
|
||||
|
||||
/**
|
||||
* Sets the entity's pitch.
|
||||
*
|
||||
* @param pitch the pitch angle.
|
||||
*/
|
||||
void setPitch(float pitch);
|
||||
|
||||
/**
|
||||
* Returns the entity's pitch.
|
||||
*
|
||||
* @return the pitch angle.
|
||||
*/
|
||||
float getPitch();
|
||||
|
||||
/**
|
||||
* Applies a knockback effect to the entity.
|
||||
*
|
||||
* @param power the strength of the knockback.
|
||||
* @param direction the direction in degrees (usually based on getRotation()).
|
||||
*/
|
||||
void knockback(int power, float direction);
|
||||
|
||||
/**
|
||||
* Applies knockback using individual power components.
|
||||
*
|
||||
* @param xpower the x-axis power.
|
||||
* @param ypower the y-axis power.
|
||||
* @param zpower the z-axis power.
|
||||
* @param direction the direction in degrees.
|
||||
*/
|
||||
void knockback(double xpower, double ypower, double zpower, float direction);
|
||||
|
||||
/**
|
||||
* Applies knockback using a position vector.
|
||||
*
|
||||
* @param pos the position vector.
|
||||
* @param direction the direction in degrees.
|
||||
*/
|
||||
void knockback(IPos pos, float direction);
|
||||
|
||||
/**
|
||||
* Sets the entity's immunity time (hurt resistance).
|
||||
*
|
||||
* @param ticks the number of ticks.
|
||||
*/
|
||||
void setImmune(int ticks);
|
||||
|
||||
/**
|
||||
* Sets the entity's invisibility.
|
||||
*
|
||||
* @param invisible true to make invisible.
|
||||
*/
|
||||
void setInvisible(boolean invisible);
|
||||
|
||||
/**
|
||||
* Sets whether the entity is sneaking.
|
||||
*
|
||||
* @param sneaking true to enable sneaking.
|
||||
*/
|
||||
void setSneaking(boolean sneaking);
|
||||
|
||||
/**
|
||||
* Sets whether the entity is sprinting.
|
||||
*
|
||||
* @param sprinting true to enable sprinting.
|
||||
*/
|
||||
void setSprinting(boolean sprinting);
|
||||
|
||||
/**
|
||||
* @return Whether the entity has collided with something.
|
||||
*/
|
||||
boolean hasCollided();
|
||||
|
||||
/**
|
||||
* @return Whether the entity has collided vertically.
|
||||
*/
|
||||
boolean hasCollidedVertically();
|
||||
|
||||
/**
|
||||
* @return Whether the entity has collided horizontally.
|
||||
*/
|
||||
boolean hasCollidedHorizontally();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is capturing drops.
|
||||
*/
|
||||
boolean capturesDrops();
|
||||
|
||||
/**
|
||||
* Sets whether the entity captures drops.
|
||||
*
|
||||
* @param capture true to capture drops.
|
||||
*/
|
||||
void setCapturesDrops(boolean capture);
|
||||
|
||||
/**
|
||||
* Sets the captured drops for this entity.
|
||||
*
|
||||
* @param capturedDrops an array of captured drops.
|
||||
*/
|
||||
void setCapturedDrops(IEntity[] capturedDrops);
|
||||
|
||||
/**
|
||||
* Returns the captured drops.
|
||||
*
|
||||
* @return an array of captured drops.
|
||||
*/
|
||||
IEntity[] getCapturedDrops();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is sneaking.
|
||||
* @since 1.7.10c
|
||||
*/
|
||||
boolean isSneaking();
|
||||
|
||||
/**
|
||||
* @return Whether the entity is sprinting.
|
||||
* @since 1.7.10c
|
||||
*/
|
||||
boolean isSprinting();
|
||||
|
||||
/**
|
||||
* Expert users only.
|
||||
*
|
||||
* @return The underlying Minecraft entity.
|
||||
*/
|
||||
Object getMCEntity();
|
||||
|
||||
/**
|
||||
* Returns the entity's NBT data.
|
||||
*
|
||||
* @return the NBT data.
|
||||
*/
|
||||
INbt getNbt();
|
||||
|
||||
/**
|
||||
* Returns all NBT data for the entity.
|
||||
*
|
||||
* @return the complete NBT data.
|
||||
*/
|
||||
INbt getAllNbt();
|
||||
|
||||
/**
|
||||
* Applies the given NBT data to the entity.
|
||||
*
|
||||
* @param nbt the NBT data.
|
||||
*/
|
||||
void setNbt(INbt nbt);
|
||||
|
||||
/**
|
||||
* Returns optional NBT data if available.
|
||||
*
|
||||
* @return the optional NBT data, or null if none.
|
||||
*/
|
||||
INbt getNbtOptional();
|
||||
|
||||
/**
|
||||
* Stores the entity as a clone with the given tab and name.
|
||||
*
|
||||
* @param tab the tab index.
|
||||
* @param name the name for the clone.
|
||||
*/
|
||||
void storeAsClone(int tab, String name);
|
||||
|
||||
/**
|
||||
* @return The world this entity exists in.
|
||||
*/
|
||||
IWorld getWorld();
|
||||
|
||||
/**
|
||||
* Updates the entity's state.
|
||||
*/
|
||||
void updateEntity();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package noppes.npcs.api.entity;
|
||||
|
||||
/**
|
||||
* Platform-api version (MC-free). The src/api shadow adds generic type parameter.
|
||||
* All methods are clean — no MC types needed.
|
||||
*/
|
||||
public interface IEntityLiving extends IEntityLivingBase {
|
||||
|
||||
boolean isNavigating();
|
||||
|
||||
void clearNavigation();
|
||||
|
||||
void navigateTo(double x, double y, double z, double speed);
|
||||
|
||||
Object getMCEntity();
|
||||
|
||||
void playLivingSound();
|
||||
|
||||
void spawnExplosionParticle();
|
||||
|
||||
void setMoveForward(float speed);
|
||||
|
||||
void faceEntity(IEntity entity, float pitch, float yaw);
|
||||
|
||||
boolean canPickUpLoot();
|
||||
|
||||
void setCanPickUpLoot(boolean pickUp);
|
||||
|
||||
boolean isPersistent();
|
||||
|
||||
void enablePersistence();
|
||||
|
||||
void setCustomNameTag(String text);
|
||||
|
||||
String getCustomNameTag();
|
||||
|
||||
boolean hasCustomNameTag();
|
||||
|
||||
void setAlwaysRenderNameTag(boolean alwaysRender);
|
||||
|
||||
boolean getAlwaysRenderNameTag();
|
||||
|
||||
void clearLeashed(boolean sendPacket, boolean dropLeash);
|
||||
|
||||
boolean allowLeashing();
|
||||
|
||||
boolean getLeashed();
|
||||
|
||||
IEntity getLeashedTo();
|
||||
|
||||
void setLeashedTo(IEntity entity, boolean sendPacket);
|
||||
|
||||
boolean canBeSteered();
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package noppes.npcs.api.entity;
|
||||
|
||||
import noppes.npcs.api.IDamageSource;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
|
||||
/**
|
||||
* Platform-api version (MC-free). The src/api shadow adds generic type parameter
|
||||
* and IBlock-dependent methods.
|
||||
*/
|
||||
public interface IEntityLivingBase extends IEntity {
|
||||
|
||||
float getHealth();
|
||||
|
||||
void setHealth(float health);
|
||||
|
||||
void hurt(float damage);
|
||||
|
||||
void hurt(float damage, IEntity source);
|
||||
|
||||
void hurt(float damage, IDamageSource damageSource);
|
||||
|
||||
void setMaxHurtTime(int time);
|
||||
|
||||
int getMaxHurtTime();
|
||||
|
||||
double getMaxHealth();
|
||||
|
||||
double getFollowRange();
|
||||
|
||||
double getKnockbackResistance();
|
||||
|
||||
double getSpeed();
|
||||
|
||||
double getMeleeStrength();
|
||||
|
||||
void setMaxHealth(double health);
|
||||
|
||||
void setFollowRange(double range);
|
||||
|
||||
void setKnockbackResistance(double knockbackResistance);
|
||||
|
||||
void setSpeed(double speed);
|
||||
|
||||
void setMeleeStrength(double attackDamage);
|
||||
|
||||
boolean isAttacking();
|
||||
|
||||
void setAttackTarget(IEntityLivingBase living);
|
||||
|
||||
IEntityLivingBase getAttackTarget();
|
||||
|
||||
int getAttackTargetTime();
|
||||
|
||||
void setLastAttacker(IEntity entity);
|
||||
|
||||
IEntity getLastAttacker();
|
||||
|
||||
int getLastAttackerTime();
|
||||
|
||||
boolean canBreatheUnderwater();
|
||||
|
||||
int getType();
|
||||
|
||||
boolean typeOf(int type);
|
||||
|
||||
IPos getLookVector();
|
||||
|
||||
// Note: getLookingAtBlock methods omitted — require IBlock (not in platform-api)
|
||||
|
||||
IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IPos getLookingAtPos(int maxDistance);
|
||||
|
||||
IEntity[] getLookingAtEntities(IEntity[] ignoreEntities, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] getLookingAtEntities(int maxDistance, double offset, double range);
|
||||
|
||||
Object getMCEntity();
|
||||
|
||||
void swingHand();
|
||||
|
||||
void addPotionEffect(int effect, int duration, int strength, boolean hideParticles);
|
||||
|
||||
void clearPotionEffects();
|
||||
|
||||
int getPotionEffect(int effect);
|
||||
|
||||
IItemStack getHeldItem();
|
||||
|
||||
void setHeldItem(IItemStack item);
|
||||
|
||||
IItemStack getArmor(int slot);
|
||||
|
||||
void setArmor(int slot, IItemStack item);
|
||||
|
||||
boolean isChild();
|
||||
|
||||
void renderBrokenItemStack(IItemStack itemStack);
|
||||
|
||||
boolean isOnLadder();
|
||||
|
||||
int getTotalArmorValue();
|
||||
|
||||
int getArrowCountInEntity();
|
||||
|
||||
void setArrowCountInEntity(int count);
|
||||
|
||||
void dismountEntity(IEntity entity);
|
||||
|
||||
void setAIMoveSpeed(float speed);
|
||||
|
||||
float getAIMoveSpeed();
|
||||
|
||||
void setAbsorptionAmount(float amount);
|
||||
|
||||
float getAbsorptionAmount();
|
||||
|
||||
void setHurtTime(int time);
|
||||
|
||||
void applyKnockback(float strength, IEntity source);
|
||||
|
||||
void applyKnockback(float strength, double dirX, double dirZ);
|
||||
|
||||
void forceKnockback(float strength, IEntity source);
|
||||
|
||||
void forceKnockback(float strength, double dirX, double dirZ);
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package noppes.npcs.api.entity;
|
||||
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.api.handler.data.IMagicData;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
|
||||
/**
|
||||
* Platform-api version (MC-free). The src/api shadow adds generic type parameter
|
||||
* and methods requiring MC-only types (IBlock, IContainer, ICustomGui, ISound,
|
||||
* IDialog, IQuest, ITimers, IPlayerData, etc.).
|
||||
*/
|
||||
public interface IPlayer extends IEntityLivingBase, IAnimatable {
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
String getName();
|
||||
|
||||
void kick(String reason);
|
||||
|
||||
void setPosition(double x, double y, double z);
|
||||
|
||||
void setPosition(IPos pos);
|
||||
|
||||
void setPosition(double x, double y, double z, int dimensionId);
|
||||
|
||||
void setPosition(IPos pos, int dimensionId);
|
||||
|
||||
void setPosition(double x, double y, double z, IWorld world);
|
||||
|
||||
void setPosition(IPos pos, IWorld world);
|
||||
|
||||
void setDimension(int dimension);
|
||||
|
||||
int getHunger();
|
||||
|
||||
void setHunger(int hunger);
|
||||
|
||||
float getSaturation();
|
||||
|
||||
void setSaturation(float saturation);
|
||||
|
||||
// Dialog methods (int-based — IDialog-based stay in shadow)
|
||||
|
||||
void showDialog(int id);
|
||||
|
||||
boolean hasReadDialog(int id);
|
||||
|
||||
void readDialog(int id);
|
||||
|
||||
void unreadDialog(int id);
|
||||
|
||||
// Quest methods (int-based — IQuest-based stay in shadow)
|
||||
|
||||
boolean hasFinishedQuest(int id);
|
||||
|
||||
boolean hasActiveQuest(int id);
|
||||
|
||||
void startQuest(int id);
|
||||
|
||||
void finishQuest(int id);
|
||||
|
||||
void stopQuest(int id);
|
||||
|
||||
void removeQuest(int id);
|
||||
|
||||
int getType();
|
||||
|
||||
boolean typeOf(int type);
|
||||
|
||||
void addFactionPoints(int faction, int points);
|
||||
|
||||
void setFactionPoints(int faction, int points);
|
||||
|
||||
int getFactionPoints(int faction);
|
||||
|
||||
void sendMessage(String message);
|
||||
|
||||
int getMode();
|
||||
|
||||
void setMode(int type);
|
||||
|
||||
IItemStack[] getInventory();
|
||||
|
||||
int inventoryItemCount(IItemStack item, boolean ignoreNBT, boolean ignoreDamage);
|
||||
|
||||
boolean removeItem(String id, int damage, int amount);
|
||||
|
||||
boolean removeItem(IItemStack item, int amount, boolean ignoreNBT, boolean ignoreDamage);
|
||||
|
||||
int removeAllItems(IItemStack item, boolean ignoreNBT, boolean ignoreDamage);
|
||||
|
||||
boolean giveItem(IItemStack item, int amount);
|
||||
|
||||
boolean giveItem(String id, int damage, int amount);
|
||||
|
||||
void setSpawnpoint(int x, int y, int z);
|
||||
|
||||
void setSpawnpoint(IPos pos);
|
||||
|
||||
void resetSpawnpoint();
|
||||
|
||||
void setRotation(float rotationYaw, float rotationPitch);
|
||||
|
||||
void disableMouseInput(long time, int... buttonIds);
|
||||
|
||||
void stopUsingItem();
|
||||
|
||||
void clearItemInUse();
|
||||
|
||||
void clearInventory();
|
||||
|
||||
void playSound(String name, float volume, float pitch);
|
||||
|
||||
// playSound(ISound) and playSound(int, ISound) stay in shadow — ISound not in platform-api
|
||||
|
||||
void stopSound(int id);
|
||||
|
||||
void pauseSounds();
|
||||
|
||||
void continueSounds();
|
||||
|
||||
void stopSounds();
|
||||
|
||||
// mountEntity(Entity) stays in shadow — raw MC type
|
||||
|
||||
IEntity dropOneItem(boolean dropStack);
|
||||
|
||||
// canHarvestBlock(IBlock) stays in shadow — IBlock not in platform-api
|
||||
|
||||
boolean interactWith(IEntity entity);
|
||||
|
||||
boolean hasAchievement(String achievement);
|
||||
|
||||
boolean hasBukkitPermission(String permission);
|
||||
|
||||
int getExpLevel();
|
||||
|
||||
void setExpLevel(int level);
|
||||
|
||||
// getPixelmonData(), getTimers(), getDBCPlayer(), getData(),
|
||||
// getActionManager(), getAttributes(), getScreenSize(),
|
||||
// getOpenContainer(), showCustomGui(), getCustomGui(),
|
||||
// showCustomOverlay(), getOverlays()
|
||||
// all stay in shadow — types not in platform-api
|
||||
|
||||
void updatePlayerInventory();
|
||||
|
||||
boolean blocking();
|
||||
|
||||
boolean isScriptingDev();
|
||||
|
||||
void closeGui();
|
||||
|
||||
void closeOverlay(int id);
|
||||
|
||||
IAnimationData getAnimationData();
|
||||
|
||||
void setConqueredEnd(boolean conqueredEnd);
|
||||
|
||||
boolean conqueredEnd();
|
||||
|
||||
IMagicData getMagicData();
|
||||
|
||||
IPlayer[] getPartyMembers();
|
||||
|
||||
// =========================================
|
||||
// Currency Methods
|
||||
// =========================================
|
||||
|
||||
long getCurrencyBalance();
|
||||
|
||||
void setCurrencyBalance(long amount);
|
||||
|
||||
boolean depositCurrency(long amount);
|
||||
|
||||
boolean withdrawCurrency(long amount);
|
||||
|
||||
boolean canAffordCurrency(long amount);
|
||||
|
||||
boolean isUsingVaultCurrency();
|
||||
|
||||
String getFormattedCurrencyBalance();
|
||||
|
||||
Object getMCEntity();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package noppes.npcs.api.handler.data;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IAnimation {
|
||||
|
||||
IAnimationData getParent();
|
||||
|
||||
IFrame currentFrame();
|
||||
|
||||
IFrame[] getFrames();
|
||||
|
||||
IAnimation setFrames(IFrame[] frames);
|
||||
|
||||
IAnimation clearFrames();
|
||||
|
||||
IAnimation addFrame(IFrame frame);
|
||||
|
||||
IAnimation addFrame(int index, IFrame frame);
|
||||
|
||||
IAnimation removeFrame(IFrame frame);
|
||||
|
||||
IAnimation setName(String name);
|
||||
|
||||
String getName();
|
||||
|
||||
IAnimation setSpeed(float speed);
|
||||
|
||||
float getSpeed();
|
||||
|
||||
IAnimation setSmooth(byte smooth);
|
||||
|
||||
byte isSmooth();
|
||||
|
||||
IAnimation doWhileStanding(boolean whileStanding);
|
||||
|
||||
boolean doWhileStanding();
|
||||
|
||||
IAnimation doWhileMoving(boolean whileMoving);
|
||||
|
||||
boolean doWhileMoving();
|
||||
|
||||
IAnimation doWhileAttacking(boolean whileAttacking);
|
||||
|
||||
boolean doWhileAttacking();
|
||||
|
||||
IAnimation setLoop(int loopAtFrame);
|
||||
|
||||
int loop();
|
||||
|
||||
IAnimation save();
|
||||
|
||||
int getID();
|
||||
|
||||
void setID(int id);
|
||||
|
||||
long getTotalTime();
|
||||
|
||||
boolean hasData(String key);
|
||||
|
||||
Object getData(String key);
|
||||
|
||||
IAnimation setData(String key, Object v);
|
||||
|
||||
IAnimation removeData(String key);
|
||||
|
||||
IAnimation onStart(Consumer<IAnimation> task);
|
||||
|
||||
IAnimation onFrame(BiConsumer<Integer, IAnimation> task);
|
||||
|
||||
IAnimation onEnd(Consumer<IAnimation> task);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package noppes.npcs.api.handler.data;
|
||||
|
||||
import noppes.npcs.api.entity.IAnimatable;
|
||||
|
||||
public interface IAnimationData {
|
||||
|
||||
IAnimatable getEntity();
|
||||
|
||||
void updateClient();
|
||||
|
||||
boolean isActive();
|
||||
|
||||
boolean isClientAnimating();
|
||||
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
boolean enabled();
|
||||
|
||||
void setAnimation(IAnimation animation);
|
||||
|
||||
IAnimation getAnimation();
|
||||
|
||||
long getAnimatingTime();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.api.handler.data;
|
||||
|
||||
import noppes.npcs.platform.nbt.INBTCompound;
|
||||
import noppes.npcs.api.INbt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,11 +19,11 @@ public interface ISlot {
|
||||
|
||||
void setTemporary(boolean temporary);
|
||||
|
||||
Map<String, INBTCompound> getComponents();
|
||||
Map<String, INbt> getComponents();
|
||||
|
||||
void setComponentData(String key, INBTCompound data);
|
||||
void setComponentData(String key, INbt data);
|
||||
|
||||
INBTCompound getComponentData(String key);
|
||||
INbt getComponentData(String key);
|
||||
|
||||
INBTCompound toNBT();
|
||||
INbt toNBT();
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
package noppes.npcs.api.item;
|
||||
|
||||
import noppes.npcs.api.INbt;
|
||||
|
||||
/**
|
||||
* Represents an item stack with extended functionality:
|
||||
* enchantments, lore, and additional item data.
|
||||
*/
|
||||
public interface IItemStack {
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return Returns the stack size.
|
||||
*/
|
||||
int getStackSize();
|
||||
|
||||
/**
|
||||
* @return Returns whether the item has a custom name.
|
||||
*/
|
||||
boolean hasCustomName();
|
||||
|
||||
/**
|
||||
* Sets the custom name for the item.
|
||||
*
|
||||
* @param name The custom name.
|
||||
*/
|
||||
void setCustomName(String name);
|
||||
|
||||
/**
|
||||
* @return Returns the in-game displayed name. This is either the item name or the custom name if set.
|
||||
*/
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
* @return Returns the base item name, regardless of any custom name.
|
||||
*/
|
||||
String getItemName();
|
||||
|
||||
/**
|
||||
* Sets the stack size of the item.
|
||||
*
|
||||
* @param size The new stack size (between 1 and 64).
|
||||
*/
|
||||
void setStackSize(int size);
|
||||
|
||||
/**
|
||||
* @return Returns the maximum stack size for this item.
|
||||
*/
|
||||
int getMaxStackSize();
|
||||
|
||||
/**
|
||||
* @return Returns the item damage. For tools, this represents durability.
|
||||
*/
|
||||
int getItemDamage();
|
||||
|
||||
/**
|
||||
* Sets the item damage value.
|
||||
*
|
||||
* @param value The new damage value.
|
||||
*/
|
||||
void setItemDamage(int value);
|
||||
|
||||
/**
|
||||
* Sets an NBT tag for this item.
|
||||
*
|
||||
* @param key The tag key.
|
||||
* @param value The value to store (Number or String).
|
||||
*/
|
||||
void setTag(String key, Object value);
|
||||
|
||||
/**
|
||||
* Checks if the item has an NBT tag with the specified key.
|
||||
*
|
||||
* @param key The tag key.
|
||||
* @return true if present, false otherwise.
|
||||
*/
|
||||
boolean hasTag(String key);
|
||||
|
||||
/**
|
||||
* Returns the value of the NBT tag with the specified key.
|
||||
*
|
||||
* @param key The tag key.
|
||||
* @return The tag value, or null if not present.
|
||||
*/
|
||||
Object getTag(String key);
|
||||
|
||||
/**
|
||||
* Removes all custom tags from the item and returns the removed NBT data.
|
||||
*
|
||||
* @return The removed NBT data.
|
||||
*/
|
||||
INbt removeTags();
|
||||
|
||||
/**
|
||||
* @return Returns whether the item is enchanted.
|
||||
*/
|
||||
boolean isEnchanted();
|
||||
|
||||
/**
|
||||
* Checks if the item has the specified enchantment.
|
||||
*
|
||||
* @param id The enchantment id.
|
||||
* @return true if present, false otherwise.
|
||||
*/
|
||||
boolean hasEnchant(int id);
|
||||
|
||||
/**
|
||||
* Adds an enchantment to the item.
|
||||
*
|
||||
* @param id The enchantment id.
|
||||
* @param strength The enchantment strength.
|
||||
*/
|
||||
void addEnchant(int id, int strength);
|
||||
|
||||
// --- Default MC Attribute Handling (legacy) ---
|
||||
|
||||
/**
|
||||
* Sets an attribute on the item using the default MC attribute system.
|
||||
*
|
||||
* @param name The attribute key.
|
||||
* @param value The attribute value.
|
||||
*/
|
||||
void setAttribute(String name, double value);
|
||||
|
||||
/**
|
||||
* Retrieves the attribute value using the default MC attribute system.
|
||||
*
|
||||
* @param name The attribute key.
|
||||
* @return The attribute value.
|
||||
*/
|
||||
double getAttribute(String name);
|
||||
|
||||
/**
|
||||
* Checks if the item has an attribute (using the default MC attribute system).
|
||||
*
|
||||
* @param name The attribute key.
|
||||
* @return true if present, false otherwise.
|
||||
*/
|
||||
boolean hasAttribute(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the custom attribute value for the given key.
|
||||
* The value is stored in the item's custom NBT structure.
|
||||
*
|
||||
* @param key The custom attribute key.
|
||||
* @param value The attribute value.
|
||||
*/
|
||||
void setCustomAttribute(String key, double value);
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the item has a custom attribute with the specified key.
|
||||
*
|
||||
* @param key The custom attribute key.
|
||||
* @return true if the attribute exists, false otherwise.
|
||||
*/
|
||||
boolean hasCustomAttribute(String key);
|
||||
|
||||
/**
|
||||
* Returns the custom attribute object associated with the given key.
|
||||
* This may be a raw value or a more complex structure.
|
||||
*
|
||||
* @param key The custom attribute key.
|
||||
* @return The attribute object value
|
||||
*/
|
||||
float getCustomAttribute(String key);
|
||||
|
||||
/**
|
||||
* Removes the custom attribute with the specified key from the item.
|
||||
*
|
||||
* @param key The custom attribute key.
|
||||
*/
|
||||
void removeCustomAttribute(String key);
|
||||
|
||||
/**
|
||||
* Sets the magic attribute value for the given key and magic identifier.
|
||||
* The value is stored in the item's custom NBT under "RPGCore", "Magic".
|
||||
*
|
||||
* @param key The magic attribute key.
|
||||
* @param magicId The magic identifier.
|
||||
* @param value The attribute value.
|
||||
*/
|
||||
void setMagicAttribute(String key, int magicId, double value);
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the item has a magic attribute with the given key and magic identifier.
|
||||
*
|
||||
* @param key The magic attribute key.
|
||||
* @param magicId The magic identifier.
|
||||
* @return true if the attribute exists, false otherwise.
|
||||
*/
|
||||
boolean hasMagicAttribute(String key, int magicId);
|
||||
|
||||
/**
|
||||
* Returns the magic attribute object (typically a Float value) associated with the given key and magic identifier.
|
||||
*
|
||||
* @param key The magic attribute key.
|
||||
* @param magicId The magic identifier.
|
||||
* @return The attribute object, or null if not present.
|
||||
*/
|
||||
float getMagicAttribute(String key, int magicId);
|
||||
|
||||
/**
|
||||
* Removes the magic attribute with the specified key and magic identifier from the item.
|
||||
*
|
||||
* @param key The magic attribute key.
|
||||
* @param magicId The magic identifier.
|
||||
*/
|
||||
void removeMagicAttribute(String key, int magicId);
|
||||
|
||||
/**
|
||||
* Sets (or applies) a requirement for the item using the given requirement key and value.
|
||||
* The requirement data is stored under "RPGCore" → "Requirements" in the item's NBT.
|
||||
*
|
||||
* @param reqKey The requirement key.
|
||||
* @param value The requirement value (Number or String).
|
||||
*/
|
||||
void setRequirement(String reqKey, Object value);
|
||||
|
||||
/**
|
||||
* Checks whether the item has a requirement with the specified key.
|
||||
*
|
||||
* @param reqKey The requirement key.
|
||||
* @return true if the requirement exists, false otherwise.
|
||||
*/
|
||||
boolean hasRequirement(String reqKey);
|
||||
|
||||
/**
|
||||
* Retrieves the requirement value for the specified key.
|
||||
*
|
||||
* @param reqKey The requirement key.
|
||||
* @return The requirement value as an Object (or null if not present).
|
||||
*/
|
||||
Object getRequirement(String reqKey);
|
||||
|
||||
/**
|
||||
* Removes the requirement with the specified key from the item.
|
||||
*
|
||||
* @param reqKey The requirement key.
|
||||
*/
|
||||
void removeRequirement(String reqKey);
|
||||
|
||||
/**
|
||||
* Returns an array of all custom attribute keys stored on the item.
|
||||
*
|
||||
* @return an array of custom attribute keys.
|
||||
*/
|
||||
String[] getCustomAttributeKeys();
|
||||
|
||||
/**
|
||||
* Returns an array of all magic attribute keys (as strings) for the specified magic attribute key.
|
||||
*
|
||||
* @param key the magic attribute key (e.g. "magic_damage").
|
||||
* @return an array of magic identifier keys as strings.
|
||||
*/
|
||||
String[] getMagicAttributeKeys(String key);
|
||||
|
||||
/**
|
||||
* Returns an array of all requirement keys stored on the item.
|
||||
*
|
||||
* @return an array of requirement keys.
|
||||
*/
|
||||
String[] getRequirementKeys();
|
||||
|
||||
/**
|
||||
* @return Returns the lore (descriptive text) for the item.
|
||||
*/
|
||||
String[] getLore();
|
||||
|
||||
/**
|
||||
* @return Returns whether the item has lore.
|
||||
*/
|
||||
boolean hasLore();
|
||||
|
||||
/**
|
||||
* Sets the lore for the item.
|
||||
*
|
||||
* @param lore An array of lore strings.
|
||||
*/
|
||||
void setLore(String[] lore);
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this item stack.
|
||||
*
|
||||
* @return A copy of the item stack.
|
||||
*/
|
||||
IItemStack copy();
|
||||
|
||||
/**
|
||||
* @return Returns the maximum damage the item can sustain.
|
||||
*/
|
||||
int getMaxItemDamage();
|
||||
|
||||
/**
|
||||
* @return Returns whether the item is a written book.
|
||||
*/
|
||||
boolean isWrittenBook();
|
||||
|
||||
/**
|
||||
* @return Returns the book's title.
|
||||
*/
|
||||
String getBookTitle();
|
||||
|
||||
/**
|
||||
* @return Returns the book's author.
|
||||
*/
|
||||
String getBookAuthor();
|
||||
|
||||
/**
|
||||
* @return If the item is a book, returns the book pages.
|
||||
*/
|
||||
String[] getBookText();
|
||||
|
||||
/**
|
||||
* @return Returns whether the item represents a block.
|
||||
*/
|
||||
boolean isBlock();
|
||||
|
||||
/**
|
||||
* Returns an INbt instance representing the item's custom NBT data.
|
||||
*
|
||||
* @return The custom NBT data.
|
||||
*/
|
||||
INbt getNbt();
|
||||
|
||||
/**
|
||||
* Returns an INbt instance representing the full NBT data of the item.
|
||||
*
|
||||
* @return The complete NBT data.
|
||||
*/
|
||||
INbt getItemNbt();
|
||||
|
||||
/**
|
||||
* Returns the underlying Minecraft ItemStack.
|
||||
* <p>No support is given for this method. Use with caution.</p>
|
||||
*
|
||||
* @return The Minecraft ItemStack.
|
||||
*/
|
||||
Object getMCItemStack();
|
||||
|
||||
/**
|
||||
* Returns a hash value for the item.
|
||||
*
|
||||
* @return The item's hash code.
|
||||
*/
|
||||
int itemHash();
|
||||
|
||||
/**
|
||||
* Returns the underlying Minecraft NBTTagCompound for the item.
|
||||
*
|
||||
* @return The NBTTagCompound.
|
||||
*/
|
||||
Object getMCNbt();
|
||||
|
||||
/**
|
||||
* Sets the underlying Minecraft NBTTagCompound for the item.
|
||||
*
|
||||
* @param compound The NBTTagCompound to set.
|
||||
*/
|
||||
void setMCNbt(Object compound);
|
||||
|
||||
/**
|
||||
* Compares this item with another item, with an option to ignore NBT data.
|
||||
*
|
||||
* @param item The item to compare.
|
||||
* @param ignoreNBT true to ignore NBT data.
|
||||
* @return true if the items are considered equal, false otherwise.
|
||||
*/
|
||||
boolean compare(IItemStack item, boolean ignoreNBT);
|
||||
|
||||
/**
|
||||
* Compares this item with another item, with options to ignore damage and/or NBT data.
|
||||
*
|
||||
* @param item The item to compare.
|
||||
* @param ignoreDamage true to ignore damage values.
|
||||
* @param ignoreNBT true to ignore NBT data.
|
||||
* @return true if the items are considered equal, false otherwise.
|
||||
*/
|
||||
boolean compare(IItemStack item, boolean ignoreDamage, boolean ignoreNBT);
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
package noppes.npcs.platform;
|
||||
|
||||
import kamkeel.npcs.platform.entity.IDamage;
|
||||
import kamkeel.npcs.platform.entity.ILiving;
|
||||
import kamkeel.npcs.platform.entity.IMob;
|
||||
import kamkeel.npcs.platform.entity.IUser;
|
||||
import kamkeel.npcs.platform.entity.IStack;
|
||||
import kamkeel.npcs.platform.entity.IGameWorld;
|
||||
import noppes.npcs.platform.nbt.INBTCompound;
|
||||
import noppes.npcs.platform.nbt.INBTList;
|
||||
import noppes.npcs.platform.nbt.NBTFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Central platform abstraction that bridges CORE logic with MC-version-specific code.
|
||||
*
|
||||
* Each mc* module (mc1710, mc1122, mc1165, mc1201) provides an implementation
|
||||
* that is registered during mod initialization via {@link PlatformServiceHolder#set(PlatformService)}.
|
||||
*
|
||||
* CORE code accesses this via {@link PlatformServiceHolder#get()}.
|
||||
*/
|
||||
public interface PlatformService {
|
||||
|
||||
// --- NBT ---
|
||||
|
||||
/**
|
||||
* @return the NBT factory for creating and wrapping NBT objects
|
||||
*/
|
||||
NBTFactory nbt();
|
||||
|
||||
// --- NBT I/O ---
|
||||
|
||||
/**
|
||||
* Reads a compressed NBT compound from a file.
|
||||
* Maps to CompressedStreamTools.readCompressed() in MC.
|
||||
*/
|
||||
INBTCompound readCompressedNBT(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a compressed NBT compound to a file.
|
||||
* Maps to CompressedStreamTools.writeCompressed() in MC.
|
||||
*/
|
||||
void writeCompressedNBT(INBTCompound compound, File file) throws IOException;
|
||||
|
||||
// --- Paths ---
|
||||
|
||||
/**
|
||||
* @return the world save directory (server-side), e.g. "saves/MyWorld/customnpcs/"
|
||||
*/
|
||||
File getWorldSaveDirectory();
|
||||
|
||||
/**
|
||||
* @return a subdirectory within the world save directory
|
||||
*/
|
||||
File getWorldSaveDirectory(String subdir);
|
||||
|
||||
/**
|
||||
* @return the global config directory, e.g. ".minecraft/config/"
|
||||
*/
|
||||
File getConfigDirectory();
|
||||
|
||||
// --- Environment ---
|
||||
|
||||
/**
|
||||
* @return true if running on the physical client (has a GUI)
|
||||
*/
|
||||
boolean isPhysicalClient();
|
||||
|
||||
/**
|
||||
* @return the mod version string
|
||||
*/
|
||||
String getModVersion();
|
||||
|
||||
// --- Logging ---
|
||||
|
||||
void logInfo(String message);
|
||||
|
||||
void logWarn(String message);
|
||||
|
||||
void logError(String message);
|
||||
|
||||
void logError(String message, Throwable t);
|
||||
|
||||
void logDebug(String message);
|
||||
|
||||
// --- Entity Wrapping ---
|
||||
|
||||
/**
|
||||
* Wraps a raw MC player entity into a platform-independent player.
|
||||
*
|
||||
* @param mcPlayer the MC player object (e.g., EntityPlayerMP on 1.7.10)
|
||||
* @return a platform player wrapper
|
||||
*/
|
||||
IUser wrapPlayer(Object mcPlayer);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC entity into a platform-independent entity.
|
||||
*
|
||||
* @param mcEntity the MC entity object
|
||||
* @return a platform entity wrapper
|
||||
*/
|
||||
IMob wrapEntity(Object mcEntity);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC living entity into a platform-independent living entity.
|
||||
*
|
||||
* @param mcLiving the MC living entity object (e.g., EntityLivingBase on 1.7.10)
|
||||
* @return a platform living wrapper
|
||||
*/
|
||||
ILiving wrapLiving(Object mcLiving);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC item stack into a platform-independent stack.
|
||||
*
|
||||
* @param mcStack the MC ItemStack object
|
||||
* @return a platform stack wrapper
|
||||
*/
|
||||
IStack wrapStack(Object mcStack);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC world into a platform-independent world.
|
||||
*
|
||||
* @param mcWorld the MC World object
|
||||
* @return a platform world wrapper
|
||||
*/
|
||||
IGameWorld wrapWorld(Object mcWorld);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC damage source into a platform-independent damage source.
|
||||
*
|
||||
* @param mcSource the MC DamageSource object
|
||||
* @return a platform damage source wrapper
|
||||
*/
|
||||
IDamage wrapDamageSource(Object mcSource);
|
||||
|
||||
// --- Scheduling ---
|
||||
|
||||
/**
|
||||
* Runs a task on the main server thread.
|
||||
* Safe to call from any thread.
|
||||
*
|
||||
* @param task the task to run
|
||||
*/
|
||||
void runOnMainThread(Runnable task);
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package noppes.npcs.platform.nbt;
|
||||
|
||||
/**
|
||||
* Version-independent abstraction over Minecraft's NBT compound tag.
|
||||
*
|
||||
* Maps to:
|
||||
* - 1.7.10 / 1.12: net.minecraft.nbt.NBTTagCompound
|
||||
* - 1.16+: net.minecraft.nbt.CompoundNBT / CompoundTag
|
||||
*
|
||||
* Each mc* module provides a thin wrapper implementation that delegates
|
||||
* to the real MC class. CORE code uses this interface exclusively.
|
||||
*/
|
||||
public interface INBTCompound {
|
||||
|
||||
// --- Setters ---
|
||||
|
||||
void setString(String key, String value);
|
||||
|
||||
void setInteger(String key, int value);
|
||||
|
||||
void setBoolean(String key, boolean value);
|
||||
|
||||
void setDouble(String key, double value);
|
||||
|
||||
void setFloat(String key, float value);
|
||||
|
||||
void setLong(String key, long value);
|
||||
|
||||
void setShort(String key, short value);
|
||||
|
||||
void setByte(String key, byte value);
|
||||
|
||||
void setByteArray(String key, byte[] value);
|
||||
|
||||
void setIntArray(String key, int[] value);
|
||||
|
||||
void setCompound(String key, INBTCompound compound);
|
||||
|
||||
void setTag(String key, INBTCompound compound);
|
||||
|
||||
void setList(String key, INBTList list);
|
||||
|
||||
// --- Getters ---
|
||||
|
||||
String getString(String key);
|
||||
|
||||
int getInteger(String key);
|
||||
|
||||
boolean getBoolean(String key);
|
||||
|
||||
double getDouble(String key);
|
||||
|
||||
float getFloat(String key);
|
||||
|
||||
long getLong(String key);
|
||||
|
||||
short getShort(String key);
|
||||
|
||||
byte getByte(String key);
|
||||
|
||||
byte[] getByteArray(String key);
|
||||
|
||||
int[] getIntArray(String key);
|
||||
|
||||
INBTCompound getCompound(String key);
|
||||
|
||||
/**
|
||||
* Gets a tag list from this compound.
|
||||
* @param key the key
|
||||
* @param type the element type ID (e.g. 10 for compounds, 8 for strings)
|
||||
* @return the list, or an empty list if the key doesn't exist
|
||||
*/
|
||||
INBTList getList(String key, int type);
|
||||
|
||||
// --- Query ---
|
||||
|
||||
boolean hasKey(String key);
|
||||
|
||||
/**
|
||||
* Checks if this compound has a key of a specific NBT type.
|
||||
* @param key the key
|
||||
* @param type the NBT type ID
|
||||
*/
|
||||
boolean hasKey(String key, int type);
|
||||
|
||||
/**
|
||||
* @return a set of all keys in this compound
|
||||
*/
|
||||
java.util.Set<String> getKeySet();
|
||||
|
||||
/**
|
||||
* Removes a key from this compound.
|
||||
*/
|
||||
void removeTag(String key);
|
||||
|
||||
/**
|
||||
* Returns the NBT type ID for the tag with the given key.
|
||||
* @return the type ID (see {@link noppes.npcs.constants.NBTTypes}), or 0 if not present
|
||||
*/
|
||||
int getTagType(String key);
|
||||
|
||||
/**
|
||||
* @return true if this compound has no keys
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
// --- Interop ---
|
||||
|
||||
/**
|
||||
* Merges all tags from the given compound into this one.
|
||||
*/
|
||||
void merge(INBTCompound other);
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this compound.
|
||||
*/
|
||||
INBTCompound copy();
|
||||
|
||||
/**
|
||||
* Returns the underlying MC NBT object.
|
||||
* Used at the boundary between CORE and version-specific code.
|
||||
* CORE code should NEVER call this — only mc* modules should.
|
||||
*/
|
||||
Object getUnderlyingTag();
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package noppes.npcs.platform.nbt;
|
||||
|
||||
/**
|
||||
* Version-independent abstraction over Minecraft's NBT list tag.
|
||||
*
|
||||
* Maps to:
|
||||
* - 1.7.10 / 1.12: net.minecraft.nbt.NBTTagList
|
||||
* - 1.16+: net.minecraft.nbt.ListNBT / ListTag
|
||||
*/
|
||||
public interface INBTList {
|
||||
|
||||
/**
|
||||
* @return the number of elements in this list
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* Gets the compound tag at the given index.
|
||||
* @throws ClassCastException if the element is not a compound
|
||||
*/
|
||||
INBTCompound getCompound(int index);
|
||||
|
||||
/**
|
||||
* Gets the string value at the given index.
|
||||
*/
|
||||
String getString(int index);
|
||||
|
||||
/**
|
||||
* Gets the integer value at the given index (from int array tags).
|
||||
*/
|
||||
int getInt(int index);
|
||||
|
||||
/**
|
||||
* Gets the double value at the given index.
|
||||
*/
|
||||
double getDouble(int index);
|
||||
|
||||
/**
|
||||
* Gets the float value at the given index.
|
||||
*/
|
||||
float getFloat(int index);
|
||||
|
||||
/**
|
||||
* Gets an int array at the given index (for lists of int arrays).
|
||||
*/
|
||||
int[] getIntArray(int index);
|
||||
|
||||
/**
|
||||
* @return the NBT type ID of elements in this list (see {@link noppes.npcs.constants.NBTTypes}),
|
||||
* or 0 if the list is empty
|
||||
*/
|
||||
int getElementType();
|
||||
|
||||
// --- Mutators ---
|
||||
|
||||
/**
|
||||
* Appends a compound tag to the end of this list.
|
||||
*/
|
||||
void addCompound(INBTCompound compound);
|
||||
|
||||
/**
|
||||
* Appends a string to the end of this list.
|
||||
*/
|
||||
void addString(String value);
|
||||
|
||||
/**
|
||||
* Appends an integer tag to the end of this list.
|
||||
*/
|
||||
void addInt(int value);
|
||||
|
||||
/**
|
||||
* Appends a double tag to the end of this list.
|
||||
*/
|
||||
void addDouble(double value);
|
||||
|
||||
/**
|
||||
* Removes and returns the element at the given index.
|
||||
*/
|
||||
void remove(int index);
|
||||
|
||||
// --- Interop ---
|
||||
|
||||
/**
|
||||
* Returns the underlying MC NBT list object.
|
||||
* CORE code should NEVER call this — only mc* modules should.
|
||||
*/
|
||||
Object getUnderlyingTag();
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package noppes.npcs.platform.nbt;
|
||||
|
||||
import noppes.npcs.api.INbt;
|
||||
import noppes.npcs.api.INbtList;
|
||||
|
||||
/**
|
||||
* Factory for creating new NBT instances.
|
||||
* Each mc* module provides an implementation via PlatformService.
|
||||
@@ -9,29 +12,28 @@ public interface NBTFactory {
|
||||
/**
|
||||
* Creates a new, empty compound tag.
|
||||
*/
|
||||
INBTCompound createCompound();
|
||||
INbt createCompound();
|
||||
|
||||
/**
|
||||
* Creates a new, empty list tag.
|
||||
*/
|
||||
INBTList createList();
|
||||
INbtList createList();
|
||||
|
||||
/**
|
||||
* Wraps a raw MC NBT compound object into an INBTCompound.
|
||||
* Used at the boundary when receiving NBT from MC code.
|
||||
* Wraps a raw MC NBT compound object into an INbt.
|
||||
*
|
||||
* @param mcNBTTagCompound the raw MC NBTTagCompound / CompoundTag
|
||||
* @return the wrapped interface
|
||||
* @throws IllegalArgumentException if the object is not a valid MC NBT compound
|
||||
*/
|
||||
INBTCompound wrap(Object mcNBTTagCompound);
|
||||
INbt wrap(Object mcNBTTagCompound);
|
||||
|
||||
/**
|
||||
* Wraps a raw MC NBT list object into an INBTList.
|
||||
* Wraps a raw MC NBT list object into an INbtList.
|
||||
*
|
||||
* @param mcNBTTagList the raw MC NBTTagList / ListTag
|
||||
* @return the wrapped interface
|
||||
* @throws IllegalArgumentException if the object is not a valid MC NBT list
|
||||
*/
|
||||
INBTList wrapList(Object mcNBTTagList);
|
||||
INbtList wrapList(Object mcNBTTagList);
|
||||
}
|
||||
@@ -1,37 +1,21 @@
|
||||
package noppes.npcs.platform.nbt;
|
||||
|
||||
import noppes.npcs.api.INbt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Abstraction for NBT file I/O operations.
|
||||
*
|
||||
* Maps to CompressedStreamTools in MC. Used by controllers for
|
||||
* reading/writing world save data.
|
||||
* Maps to CompressedStreamTools in MC.
|
||||
*/
|
||||
public interface NBTIO {
|
||||
|
||||
/**
|
||||
* Reads a compressed NBT compound from a file.
|
||||
* Equivalent to CompressedStreamTools.readCompressed(FileInputStream).
|
||||
*/
|
||||
INBTCompound readCompressed(File file) throws IOException;
|
||||
INbt readCompressed(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a compressed NBT compound to a file.
|
||||
* Equivalent to CompressedStreamTools.writeCompressed(NBTTagCompound, FileOutputStream).
|
||||
*/
|
||||
void writeCompressed(INBTCompound compound, File file) throws IOException;
|
||||
void writeCompressed(INbt compound, File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Reads an uncompressed NBT compound from a file.
|
||||
* Equivalent to CompressedStreamTools.read(File).
|
||||
*/
|
||||
INBTCompound read(File file) throws IOException;
|
||||
INbt read(File file) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes an uncompressed NBT compound to a file (safe write with temp file).
|
||||
* Equivalent to CompressedStreamTools.safeWrite(NBTTagCompound, File).
|
||||
*/
|
||||
void safeWrite(INBTCompound compound, File file) throws IOException;
|
||||
void safeWrite(INbt compound, File file) throws IOException;
|
||||
}
|
||||
Reference in new issue
Block a user