mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 07:22:20 +00:00
Every function in API classes that calls the main API class now calls the loaded API wrapper, renamed to NpcAPI, instead of the abstract class, renamed to AbstractNpcAPI.
This commit is contained in:
1 parent
6dea5a1cbc
commit
6896cec417
41 files changed
+252
-172
No files matched your search
+6
-6
@@ -24,10 +24,10 @@ import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public abstract class NpcAPI {
|
||||
private static NpcAPI instance = null;
|
||||
public abstract class AbstractNpcAPI {
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
public NpcAPI() {
|
||||
public AbstractNpcAPI() {
|
||||
}
|
||||
|
||||
public abstract ICustomNpc createNPC(World var1);
|
||||
@@ -64,15 +64,15 @@ public abstract class NpcAPI {
|
||||
return Loader.isModLoaded("customnpcs");
|
||||
}
|
||||
|
||||
public static NpcAPI Instance() {
|
||||
public static AbstractNpcAPI Instance() {
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
} else if (!IsAvailable()) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
Class c = Class.forName("noppes.npcs.scripted.wrapper.WrapperNpcAPI");
|
||||
instance = (NpcAPI) c.getMethod("Instance").invoke((Object) null);
|
||||
Class c = Class.forName("noppes.npcs.scripted.wrapper.NpcAPI");
|
||||
instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null);
|
||||
} catch (Exception var1) {
|
||||
var1.printStackTrace();
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.util.LRUHashMap;
|
||||
|
||||
public class ScriptBlock implements IBlock {
|
||||
|
||||
@@ -16,6 +16,7 @@ import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptContainer implements IContainer {
|
||||
private IInventory inventory;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.interfaces.INbt;
|
||||
import noppes.npcs.scripted.interfaces.ITileEntity;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
|
||||
protected T tileEntity;
|
||||
|
||||
@@ -31,7 +31,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptWorld implements IWorld {
|
||||
private static Map<String,Object> tempData = new HashMap<String,Object>();
|
||||
@@ -325,7 +325,7 @@ public class ScriptWorld implements IWorld {
|
||||
* @return Returns the item
|
||||
*/
|
||||
public IItemStack createItem(String id, int damage, int size){
|
||||
return WrapperNpcAPI.Instance().createItem(id,damage,size);
|
||||
return NpcAPI.Instance().createItem(id,damage,size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
||||
public T player;
|
||||
@@ -432,10 +432,10 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
||||
this.player.writeToNBT(compound);
|
||||
|
||||
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
|
||||
ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()];
|
||||
IItemStack[] itemList = new IItemStack[list.tagCount()];
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
||||
itemList[i] = new ScriptItemStack(itemStack);
|
||||
itemList[i] = NpcAPI.Instance().getIItemStack(itemStack);
|
||||
}
|
||||
|
||||
return itemList;
|
||||
|
||||
@@ -29,6 +29,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.INbt;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
protected T entity;
|
||||
@@ -740,6 +741,6 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
}
|
||||
|
||||
public ScriptWorld getWorld() {
|
||||
return (ScriptWorld)NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj);
|
||||
return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj);
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.scripted.wrapper.ScriptDamageSource;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
@@ -174,7 +174,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
* @return The item the entity is holding
|
||||
*/
|
||||
public IItemStack getHeldItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(entity.getHeldItem());
|
||||
return NpcAPI.Instance().getIItemStack(entity.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
* @return The item in the given slot
|
||||
*/
|
||||
public IItemStack getArmor(int slot){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1));
|
||||
return NpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ import noppes.npcs.scripted.roles.ScriptRoleInterface;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleMailman;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTrader;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTransporter;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -362,7 +362,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @return The item held in the right hand
|
||||
*/
|
||||
public IItemStack getRightItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getWeapon());
|
||||
return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +380,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @return The item held in the left hand
|
||||
*/
|
||||
public IItemStack getLefttItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.getOffHand());
|
||||
return NpcAPI.Instance().getIItemStack(npc.getOffHand());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,7 +398,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @return Returns the projectile the npc uses
|
||||
*/
|
||||
public IItemStack getProjectileItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getProjectile());
|
||||
return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,7 +483,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
*/
|
||||
@Override
|
||||
public IItemStack getArmor(int slot){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot));
|
||||
return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,7 +506,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @return
|
||||
*/
|
||||
public IItemStack getLootItem(int slot) {
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7));
|
||||
return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -247,7 +247,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack item = player.inventory.mainInventory[i];
|
||||
if(item != null)
|
||||
items[i] = WrapperNpcAPI.Instance().getIItemStack(item);
|
||||
items[i] = NpcAPI.Instance().getIItemStack(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.AbstractNpcAPI;
|
||||
|
||||
public class CustomNPCsEvent extends Event{
|
||||
public final NpcAPI API = NpcAPI.Instance();
|
||||
public final AbstractNpcAPI API = AbstractNpcAPI.Instance();
|
||||
|
||||
public CustomNPCsEvent() {
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.scripted.interfaces.item.ICustomItem;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemCustom;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
public class ItemEvent extends CustomNPCsEvent {
|
||||
public ICustomItem item;
|
||||
public IItemCustom item;
|
||||
|
||||
public ItemEvent(ICustomItem item) {
|
||||
public ItemEvent(IItemCustom item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public static class InitEvent extends ItemEvent {
|
||||
public InitEvent(ICustomItem item) {
|
||||
public InitEvent(IItemCustom item) {
|
||||
super(item);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public static class UpdateEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
|
||||
public UpdateEvent(ICustomItem item, IEntity entity) {
|
||||
public UpdateEvent(IItemCustom item, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public IEntity entity;
|
||||
public IPlayer player;
|
||||
|
||||
public TossedEvent(ICustomItem item, IPlayer player, IEntity entity) {
|
||||
public TossedEvent(IItemCustom item, IPlayer player, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
this.player = player;
|
||||
@@ -42,7 +42,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public static class PickedUpEvent extends ItemEvent {
|
||||
public IPlayer player;
|
||||
|
||||
public PickedUpEvent(ICustomItem item, IPlayer player) {
|
||||
public PickedUpEvent(IItemCustom item, IPlayer player) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
@Cancelable
|
||||
public static class SpawnEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
public SpawnEvent(ICustomItem item, IEntity entity){
|
||||
public SpawnEvent(IItemCustom item, IEntity entity){
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final Object target;
|
||||
public IPlayer player;
|
||||
|
||||
public InteractEvent(ICustomItem item, IPlayer player, int type, Object target) {
|
||||
public InteractEvent(IItemCustom item, IPlayer player, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -77,7 +77,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final Object target;
|
||||
public IEntity swingingEntity;
|
||||
|
||||
public AttackEvent(ICustomItem item, IEntity swingingEntity, int type, Object target) {
|
||||
public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, Object target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
@@ -89,7 +89,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StartUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
public StartUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -99,7 +99,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public UsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
public UsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -109,7 +109,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public StopUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
public StopUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
@@ -119,7 +119,7 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
public FinishUsingItem(ICustomItem item, IPlayer player, int duration){
|
||||
public FinishUsingItem(IItemCustom item, IPlayer player, int duration){
|
||||
super(item);
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
|
||||
@@ -12,13 +12,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class NpcEvent extends CustomNPCsEvent {
|
||||
public final ICustomNpc npc;
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
@@ -21,6 +20,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class PlayerEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
@@ -3,9 +3,9 @@ package noppes.npcs.scripted.gui;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.gui.IItemSlot;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot {
|
||||
IItemStack stack;
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptTileEntity;
|
||||
|
||||
public interface IBlock {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptBlock;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
package noppes.npcs.scripted.interfaces.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptBlockPos;
|
||||
import noppes.npcs.scripted.ScriptParticle;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package noppes.npcs.scripted.interfaces.item;
|
||||
|
||||
public interface IItemArmor {
|
||||
int getArmorSlot();
|
||||
|
||||
String getArmorMaterial();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.item;
|
||||
|
||||
public interface IItemBlock {
|
||||
String getBlockName();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package noppes.npcs.scripted.interfaces.item;
|
||||
|
||||
public interface IItemBook {
|
||||
String[] getText();
|
||||
|
||||
void setText(String[] var1);
|
||||
|
||||
String getAuthor();
|
||||
|
||||
void setAuthor(String var1);
|
||||
|
||||
String getTitle();
|
||||
|
||||
void setTitle(String var1);
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.scripted.interfaces.item;
|
||||
|
||||
public interface ICustomItem extends IItemStack {
|
||||
public interface IItemCustom extends IItemStack {
|
||||
String getTexture();
|
||||
|
||||
void setTexture(String var2);
|
||||
@@ -10,11 +10,11 @@ import noppes.npcs.controllers.IScriptHandler;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.interfaces.item.ICustomItem;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemCustom;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IScriptHandler {
|
||||
public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IScriptHandler {
|
||||
public List<ScriptContainer> scripts = new ArrayList();
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemArmor;
|
||||
|
||||
public class ScriptItemArmor extends ScriptItemStack implements IItemArmor {
|
||||
|
||||
public ScriptItemArmor(ItemStack item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
public int getArmorSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getArmorMaterial() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemBlock;
|
||||
|
||||
public class ScriptItemBlock extends ScriptItemStack implements IItemBlock {
|
||||
|
||||
public ScriptItemBlock(ItemStack item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
public String getBlockName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemBook;
|
||||
|
||||
public class ScriptItemBook extends ScriptItemStack implements IItemBook {
|
||||
|
||||
public ScriptItemBook(ItemStack item) {
|
||||
super(item);
|
||||
}
|
||||
|
||||
public String[] getText() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public void setText(String[] var1) {
|
||||
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAuthor(String var1) {
|
||||
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTitle(String var1) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptNbt;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.INbt;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
|
||||
public class ScriptItemStack implements IItemStack {
|
||||
public ItemStack item;
|
||||
|
||||
+17
-17
@@ -45,7 +45,7 @@ import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.item.ICustomItem;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemCustom;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
@@ -55,12 +55,12 @@ import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.LRUHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class WrapperNpcAPI extends NpcAPI {
|
||||
public class NpcAPI extends AbstractNpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap(10);
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
private static NpcAPI instance = null;
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
public WrapperNpcAPI() {
|
||||
public NpcAPI() {
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
@@ -163,9 +163,9 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public static NpcAPI Instance() {
|
||||
public static AbstractNpcAPI Instance() {
|
||||
if (instance == null) {
|
||||
instance = new WrapperNpcAPI();
|
||||
instance = new NpcAPI();
|
||||
}
|
||||
|
||||
return instance;
|
||||
@@ -177,12 +177,22 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
|
||||
public IItemStack getIItemStack(ItemStack itemstack) {
|
||||
if(itemstack.getItem() instanceof ItemScripted){
|
||||
return (ICustomItem) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0))));
|
||||
return (IItemCustom) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0))));
|
||||
} else {
|
||||
return (IItemStack) (itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0))));
|
||||
}
|
||||
}
|
||||
|
||||
public IItemStack createItem(String id, int damage, int size){
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
if(item == null)
|
||||
return null;
|
||||
if(item instanceof ItemScripted)
|
||||
return new ScriptCustomItem(new ItemStack(item, size, damage));
|
||||
else
|
||||
return new ScriptItemStack(new ItemStack(item, size, damage));
|
||||
}
|
||||
|
||||
public IWorld getIWorld(WorldServer world) {
|
||||
ScriptWorld w = (ScriptWorld)worldCache.get(world.provider.dimensionId);
|
||||
if (w != null) {
|
||||
@@ -270,16 +280,6 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
return arr;
|
||||
}
|
||||
|
||||
public IItemStack createItem(String id, int damage, int size){
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
if(item == null)
|
||||
return null;
|
||||
if(item instanceof ItemScripted)
|
||||
return new ScriptCustomItem(new ItemStack(item, size, damage));
|
||||
else
|
||||
return new ScriptItemStack(new ItemStack(item, size, damage));
|
||||
}
|
||||
|
||||
public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){
|
||||
entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch);
|
||||
}
|
||||
Reference in new issue
Block a user