Used interfaces in implementations instead of the real classes for most scripted classes.

This commit is contained in:
Luis C.M committed 2022-05-11 22:08:31 -05:00
1 parent 6896cec417
commit cf33b90b26
63 files changed
+466 -551

No files matched your search

@@ -3,7 +3,7 @@
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.wrapper;
package noppes.npcs.scripted;
import java.io.File;
import java.util.List;
@@ -33,13 +33,12 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.*;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.*;
import noppes.npcs.containers.ContainerNpcInterface;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptContainer;
import noppes.npcs.scripted.entity.*;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.*;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
@@ -47,6 +46,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
import noppes.npcs.scripted.interfaces.item.IItemCustom;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
import noppes.npcs.scripted.item.ScriptCustomItem;
import noppes.npcs.scripted.item.ScriptItemStack;
@@ -270,21 +270,21 @@ public class NpcAPI extends AbstractNpcAPI {
return CustomNpcs.MARKOV_GENERATOR[dictionary].fetch(gender);
}
public ScriptPlayer[] getAllServerPlayers(){
public IPlayer[] getAllServerPlayers(){
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
ScriptPlayer[] arr = new ScriptPlayer[list.size()];
IPlayer[] arr = new IPlayer[list.size()];
for(int i = 0; i < list.size(); i++){
arr[i] = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(list.get(i));
arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i));
}
return arr;
}
public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){
public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){
entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch);
}
public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){
public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){
player.getWorld().getMCWorld().playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch);
}
@@ -298,12 +298,12 @@ public class NpcAPI extends AbstractNpcAPI {
MinecraftServer.getServer().setMOTD(motd);
}
public ScriptParticle createParticle(String directory){
public IParticle createParticle(String directory){
return new ScriptParticle(directory);
}
@Deprecated
public ScriptParticle createEntityParticle(String directory){
public IParticle createEntityParticle(String directory){
return new ScriptParticle(directory);
}
@@ -15,7 +15,6 @@ 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 {
@@ -12,11 +12,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.interfaces.IContainer;
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 ScriptContainer implements IContainer {
private IInventory inventory;
@@ -96,11 +94,11 @@ public class ScriptContainer implements IContainer {
container.detectAndSendChanges();
}
public void putStackInSlot(int slot, ScriptItemStack itemStack){
public void putStackInSlot(int slot, IItemStack itemStack){
container.putStackInSlot(slot,itemStack.getMCItemStack());
}
public boolean isPlayerNotUsingContainer(ScriptPlayer player){
public boolean isPlayerNotUsingContainer(IPlayer player){
return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity());
}
}
@@ -3,7 +3,7 @@
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.wrapper;
package noppes.npcs.scripted;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.ScriptController;
@@ -34,10 +34,10 @@ public class ScriptDamageSource implements IDamageSource {
}
public IEntity getTrueSource() {
return ScriptController.Instance.getScriptForEntity(this.source.getEntity());
return NpcAPI.Instance().getIEntity(this.source.getEntity());
}
public IEntity getImmediateSource() {
return ScriptController.Instance.getScriptForEntity(this.source.getSourceOfDamage());
return NpcAPI.Instance().getIEntity(this.source.getSourceOfDamage());
}
}
@@ -1,8 +1,10 @@
package noppes.npcs.scripted;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.Faction;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptFaction {
private Faction faction;
@@ -33,19 +35,19 @@ public class ScriptFaction {
return faction.color;
}
public boolean isFriendlyToPlayer(ScriptPlayer player){
return faction.isFriendlyToPlayer(player.player);
public boolean isFriendlyToPlayer(IPlayer player){
return faction.isFriendlyToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isNeutralToPlayer(ScriptPlayer player){
return faction.isNeutralToPlayer(player.player);
public boolean isNeutralToPlayer(IPlayer player){
return faction.isNeutralToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isAggressiveToPlayer(ScriptPlayer player){
return faction.isAggressiveToPlayer(player.player);
public boolean isAggressiveToPlayer(IPlayer player){
return faction.isAggressiveToPlayer((EntityPlayer) player.getMCEntity());
}
public boolean isAggressiveToNpc(ScriptNpc npc){
return faction.isAggressiveToNpc(npc.npc);
public boolean isAggressiveToNpc(ICustomNpc npc){
return faction.isAggressiveToNpc((EntityNPCInterface) npc.getMCEntity());
}
}
@@ -1,12 +1,9 @@
package noppes.npcs.scripted;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.entity.IEntity;
/**
* Created by luisc on 9/8/2021.
*/
public class ScriptParticle implements IParticle {
private String directory;
@@ -52,7 +49,7 @@ public class ScriptParticle implements IParticle {
this.directory = directory;
}
public void spawnOnEntity(ScriptEntity entity){
public void spawnOnEntity(IEntity entity){
int entityID = entity.getMCEntity().getEntityId();
NoppesUtilServer.spawnScriptedParticle(directory,
HEXColor, HEXColor2, HEXColorRate, HEXColorStart,
@@ -6,7 +6,6 @@ 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;
@@ -24,14 +24,13 @@ import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.interfaces.IBlock;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.ITileEntity;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.wrapper.NpcAPI;
public class ScriptWorld implements IWorld {
private static Map<String,Object> tempData = new HashMap<String,Object>();
@@ -135,43 +134,43 @@ public class ScriptWorld implements IWorld {
return world.getBlockLightValue(x,y,z);
}
public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){
public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){
world.playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch);
}
public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){
public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){
world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch);
}
public IEntity getEntityByID(int id){
return ScriptController.Instance.getScriptForEntity(world.getEntityByID(id));
return NpcAPI.Instance().getIEntity(world.getEntityByID(id));
}
public boolean spawnEntityInWorld(ScriptEntity entity){
public boolean spawnEntityInWorld(IEntity entity){
return world.spawnEntityInWorld(entity.getMCEntity());
}
public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range){
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range));
public IPlayer getClosestPlayerToEntity(IEntity entity, double range){
return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range));
}
public ScriptPlayer getClosestPlayer(double x, double y, double z, double range){
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayer(x,y,z, range));
public IPlayer getClosestPlayer(double x, double y, double z, double range){
return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x,y,z, range));
}
public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range){
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range));
public IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range){
return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range));
}
public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayer(x,y,z, range));
public IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){
return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x,y,z, range));
}
public int countEntities(ScriptEntity entity){
public int countEntities(IEntity entity){
return world.countEntities(entity.getMCEntity().getClass());
}
public void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity){
public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){
world.setTileEntity(x,y,z,tileEntity.getMCTileEntity());
}
@@ -230,12 +229,12 @@ public class ScriptWorld implements IWorld {
* @param z World position z
* @param item The block to be set
*/
public void setBlock(int x, int y, int z, ScriptItemStack item){
public void setBlock(int x, int y, int z, IItemStack item){
if(item == null){
removeBlock(x, y, z);
return;
}
Block block = Block.getBlockFromItem(item.item.getItem());
Block block = Block.getBlockFromItem(item.getMCItemStack().getItem());
if(block == null || block == Blocks.air)
return;
world.setBlock(x, y, z, block);
@@ -254,15 +253,15 @@ public class ScriptWorld implements IWorld {
* @param name The name of the player to be returned
* @return The Player with name. Null is returned when the player isnt found
*/
public ScriptPlayer getPlayer(String name){
public IPlayer getPlayer(String name){
EntityPlayer player = world.getPlayerEntityByName(name);
if(player == null)
return null;
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
return (IPlayer) NpcAPI.Instance().getIEntity(player);
}
public ScriptPlayer getPlayerByUUID(String uuid){
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.func_152378_a(UUID.fromString(uuid)));
public IPlayer getPlayerByUUID(String uuid){
return (IPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid)));
}
/**
@@ -333,8 +332,8 @@ public class ScriptWorld implements IWorld {
* @return Returns ScriptParticle object
*/
@Deprecated
public ScriptParticle createEntityParticle(String directory){
return new ScriptParticle(directory);
public IParticle createEntityParticle(String directory){
return NpcAPI.Instance().createEntityParticle(directory);
}
/**
@@ -440,11 +439,11 @@ public class ScriptWorld implements IWorld {
world.newExplosion(null, x, y, z, range, fire, grief);
}
public ScriptPlayer[] getAllServerPlayers(){
public IPlayer[] getAllServerPlayers(){
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
ScriptPlayer[] arr = new ScriptPlayer[list.size()];
IPlayer[] arr = new IPlayer[list.size()];
for(int i = 0; i < list.size(); i++){
arr[i] = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(list.get(i));
arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i));
}
return arr;
@@ -469,14 +468,14 @@ public class ScriptWorld implements IWorld {
* @param name Name of the cloned entity
* @return Returns the entity which was spawned
*/
public ScriptEntity spawnClone(int x, int y, int z, int tab, String name){
public IEntity spawnClone(int x, int y, int z, int tab, String name){
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab);
if(compound == null)
return null;
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
if(entity == null)
return null;
return ScriptController.Instance.getScriptForEntity(entity);
return NpcAPI.Instance().getIEntity(entity);
}
public ScriptScoreboard getScoreboard(){
@@ -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.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
public T player;
@@ -20,7 +20,6 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*;
@@ -28,8 +27,8 @@ import noppes.npcs.scripted.constants.EntityType;
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;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
public class ScriptEntity<T extends Entity> implements IEntity {
protected T entity;
@@ -367,14 +366,14 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param range The search range for entities around this entity
* @return Array of entities within range
*/
public ScriptEntity[] getSurroundingEntities(int range){
public IEntity[] getSurroundingEntities(int range){
List<Entity> entities = entity.worldObj.getEntitiesWithinAABB(Entity.class, entity.boundingBox.expand(range, range, range));
List<ScriptEntity> list = new ArrayList<ScriptEntity>();
List<IEntity> list = new ArrayList<IEntity>();
for(Entity living : entities){
if(living != entity)
list.add(ScriptController.Instance.getScriptForEntity(living));
list.add(NpcAPI.Instance().getIEntity(living));
}
return list.toArray(new ScriptEntity[list.size()]);
return list.toArray(new IEntity[list.size()]);
}
/**
@@ -382,7 +381,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param type The EntityType you want to find
* @return Array of entities within range
*/
public ScriptEntity[] getSurroundingEntities(int range, int type){
public IEntity[] getSurroundingEntities(int range, int type){
Class cls = Entity.class;
if(type == EntityType.LIVING)
cls = EntityLivingBase.class;
@@ -396,12 +395,12 @@ public class ScriptEntity<T extends Entity> implements IEntity {
cls = EntityNPCInterface.class;
List<Entity> entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range));
List<ScriptEntity> list = new ArrayList<ScriptEntity>();
List<IEntity> list = new ArrayList<IEntity>();
for(Entity living : entities){
if(living != entity)
list.add(ScriptController.Instance.getScriptForEntity(living));
list.add(NpcAPI.Instance().getIEntity(living));
}
return list.toArray(new ScriptEntity[list.size()]);
return list.toArray(new IEntity[list.size()]);
}
@@ -581,23 +580,23 @@ public class ScriptEntity<T extends Entity> implements IEntity {
/**
* @param item Item to be dropped
*/
public void dropItem(ScriptItemStack item){
entity.entityDropItem(item.item, 0);
public void dropItem(IItemStack item){
entity.entityDropItem(item.getMCItemStack(), 0);
}
/**
* @return Return the rider
*/
public ScriptEntity getRider(){
return ScriptController.Instance.getScriptForEntity(entity.riddenByEntity);
public IEntity getRider(){
return NpcAPI.Instance().getIEntity(entity.riddenByEntity);
}
/**
* @param entity The entity to ride this entity
*/
public void setRider(ScriptEntity entity){
public void setRider(IEntity entity){
if(entity != null){
entity.entity.mountEntity(this.entity);;
entity.getMCEntity().mountEntity(this.entity);;
}
else if(this.entity.riddenByEntity != null)
this.entity.riddenByEntity.mountEntity(null);
@@ -606,18 +605,18 @@ public class ScriptEntity<T extends Entity> implements IEntity {
/**
* @return Return the entity, this entity is riding
*/
public ScriptEntity getMount(){
return ScriptController.Instance.getScriptForEntity(entity.ridingEntity);
public IEntity getMount(){
return NpcAPI.Instance().getIEntity(entity.ridingEntity);
}
/**
* @param entity The entity this entity will mount
*/
public void setMount(ScriptEntity entity){
public void setMount(IEntity entity){
if(entity == null)
this.entity.mountEntity(null);
else
this.entity.mountEntity(entity.entity);
this.entity.mountEntity(entity.getMCEntity());
}
/**
@@ -1,8 +1,10 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.EntityLiving;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IEntityLiving;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> implements IEntityLiving {
@@ -18,17 +20,17 @@ public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> im
}
@Override
public void setAttackTarget(ScriptLivingBase living){
public void setAttackTarget(IEntityLivingBase living){
if(living == null)
entity.setAttackTarget(null);
else
entity.setAttackTarget(living.entity);
entity.setAttackTarget(living.getMCEntity());
super.setAttackTarget(living);
}
@Override
public ScriptLivingBase getAttackTarget(){
ScriptLivingBase base = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(entity.getAttackTarget());
public IEntityLivingBase getAttackTarget(){
IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget());
return (base != null)? base: super.getAttackTarget();
}
@@ -58,7 +60,7 @@ public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> im
}
@Override
public boolean canSeeEntity(ScriptEntity entity){
return this.entity.getEntitySenses().canSee(entity.entity);
public boolean canSeeEntity(IEntity entity){
return this.entity.getEntitySenses().canSee(entity.getMCEntity());
}
}
@@ -6,13 +6,12 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.interfaces.entity.IEntity;
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.NpcAPI;
import noppes.npcs.scripted.ScriptDamageSource;
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
protected T entity;
@@ -40,7 +39,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
entity.attackEntityFrom(DamageSource.generic,damage);
}
public void hurt(float damage, ScriptEntity source) {
public void hurt(float damage, IEntity source) {
if(source.getType() == 1)//if player
entity.attackEntityFrom(new EntityDamageSource("player",source.getMCEntity()),damage);
else
@@ -67,18 +66,18 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
/**
* @param living Entity which this entity will attack
*/
public void setAttackTarget(ScriptLivingBase living){
public void setAttackTarget(IEntityLivingBase living){
if(living == null)
entity.setRevengeTarget(null);
else
entity.setRevengeTarget(living.entity);
entity.setRevengeTarget(living.getMCEntity());
}
/**
* @return The entity which this entity is attacking
*/
public ScriptLivingBase getAttackTarget(){
return (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(entity.getAITarget());
public IEntityLivingBase getAttackTarget(){
return (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity.getAITarget());
}
@Override
@@ -89,14 +88,14 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
@Override
public boolean typeOf(int type){
return type == EntityType.LIVING?true:super.typeOf(type);
return type == EntityType.LIVING || super.typeOf(type);
}
/**
* @param entity Entity to check
* @return Whether or not this entity can see the given entity
*/
public boolean canSeeEntity(ScriptEntity entity){
return this.entity.canEntityBeSeen(entity.entity);
public boolean canSeeEntity(IEntity entity){
return this.entity.canEntityBeSeen(entity.getMCEntity());
}
/**
@@ -182,8 +181,8 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
* @since 1.7.10c
* @param item The item to be set
*/
public void setHeldItem(ScriptItemStack item){
entity.setCurrentItemOrArmor(0, item == null?null:item.item);
public void setHeldItem(IItemStack item){
entity.setCurrentItemOrArmor(0, item == null?null:item.getMCItemStack());
}
/**
@@ -201,7 +200,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
* @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head
* @param item Item to be set
*/
public void setArmor(int slot, ScriptItemStack item){
entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.item);
public void setArmor(int slot, IItemStack item){
entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.getMCItemStack());
}
}
@@ -1,5 +1,6 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.*;
@@ -7,8 +8,9 @@ import noppes.npcs.controllers.Line;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptFaction;
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.constants.AnimationType;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
@@ -28,7 +30,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.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
@@ -260,14 +262,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param item The item you want to shoot
* @param accuracy Accuracy of the shot (0-100)
*/
public void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy){
public void shootItem(IEntityLivingBase target, IItemStack item, int accuracy){
if(item == null)
return;
if(accuracy < 0)
accuracy = 0;
else if(accuracy > 100)
accuracy = 100;
npc.shoot(target.entity, accuracy, item.item, false);
npc.shoot(target.getMCEntity(), accuracy, item.getMCItemStack(), false);
}
/**
@@ -280,10 +282,10 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @param message The message the npc will say
*/
public void say(ScriptPlayer player, String message){
public void say(IPlayer player, String message){
if(player == null || message == null || message.isEmpty())
return;
npc.say(player.player, new Line(message));
npc.say((EntityPlayer) player.getMCEntity(), new Line(message));
}
/**
@@ -368,11 +370,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @param item Item to be held in the right hand
*/
public void setRightItem(ScriptItemStack item){
public void setRightItem(IItemStack item){
if(item == null)
npc.inventory.setWeapon(null);
else
npc.inventory.setWeapon(item.item);
npc.inventory.setWeapon(item.getMCItemStack());
npc.script.clientNeedsUpdate = true;
}
@@ -386,11 +388,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @param item Item to be held in the left hand
*/
public void setLeftItem(ScriptItemStack item){
public void setLeftItem(IItemStack item){
if(item == null)
npc.inventory.setOffHand(null);
else
npc.inventory.setOffHand(item.item);
npc.inventory.setOffHand(item.getMCItemStack());
npc.script.clientNeedsUpdate = true;
}
@@ -404,11 +406,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @param item Item to be used as projectile
*/
public void setProjectileItem(ScriptItemStack item){
public void setProjectileItem(IItemStack item){
if(item == null)
npc.inventory.setProjectile(null);
else
npc.inventory.setProjectile(item.item);
npc.inventory.setProjectile(item.getMCItemStack());
npc.script.aiNeedsUpdate = true;
}
@@ -491,11 +493,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param item Item to be set as armor
*/
@Override
public void setArmor(int slot, ScriptItemStack item){
public void setArmor(int slot, IItemStack item){
if(item == null)
npc.inventory.armor.put(slot, null);
else
npc.inventory.armor.put(slot, item.item);
npc.inventory.armor.put(slot, item.getMCItemStack());
npc.script.clientNeedsUpdate = true;
}
@@ -514,8 +516,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param slot The slot from the NPC's drop list to change
* @param item The item the drop list slot will be changed to
*/
public void setLootItem(int slot, ScriptItemStack item) {
npc.inventory.setInventorySlotContents(slot+7, item.item);
public void setLootItem(int slot, IItemStack item) {
npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack());
}
/**
@@ -694,8 +696,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc.display.visible;
}
public void setVisibleTo(ScriptPlayer player, boolean visible) {
UUID uuid = player.player.getPersistentID();
public void setVisibleTo(IPlayer player, boolean visible) {
UUID uuid = player.getMCEntity().getPersistentID();
ArrayList<UUID> uuidList = npc.display.invisibleToList;
if(uuidList != null) {
if (!uuidList.contains(uuid)) {
@@ -708,8 +710,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.script.clientNeedsUpdate = true;
}
public boolean isVisibleTo(ScriptPlayer player) {
return !npc.scriptInvisibleToPlayer(player.player);
public boolean isVisibleTo(IPlayer player) {
return !npc.scriptInvisibleToPlayer((EntityPlayer) player.getMCEntity());
}
/**
@@ -849,8 +851,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.stats.canDespawn = canDespawn;
}
public void giveItem(ScriptPlayer player, ScriptItemStack item){
npc.givePlayerItem(player.player, item.item);
public void giveItem(IPlayer player, IItemStack item){
npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack());
}
public void executeCommand(String command){
@@ -20,15 +20,15 @@ import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
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.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
@@ -229,10 +229,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
* @param item The item to be checked
* @return How many of this item the player has
*/
public int inventoryItemCount(ScriptItemStack item){
public int inventoryItemCount(IItemStack item){
int i = 0;
for(ItemStack is : player.inventory.mainInventory){
if (is != null && is.isItemEqual(item.item))
if (is != null && is.isItemEqual(item.getMCItemStack()))
i += is.stackSize;
}
return i;
@@ -257,7 +257,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
* @param amount How many will be removed
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given
*/
public boolean removeItem(ScriptItemStack item, int amount){
public boolean removeItem(IItemStack item, int amount){
int count = inventoryItemCount(item);
if(amount > count)
return false;
@@ -266,7 +266,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
else{
for(int i = 0; i < player.inventory.mainInventory.length; i++){
ItemStack is = player.inventory.mainInventory[i];
if (is != null && is.isItemEqual(item.item)){
if (is != null && is.isItemEqual(item.getMCItemStack())){
if(amount > is.stackSize){
player.inventory.mainInventory[i] = null;
amount -= is.stackSize;
@@ -293,7 +293,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
Item item = (Item)Item.itemRegistry.getObject(id);
if(item == null)
return false;
return removeItem(new ScriptItemStack(new ItemStack(item, 1, damage)), amount);
return removeItem(NpcAPI.Instance().getIItemStack(new ItemStack(item, 1, damage)), amount);
}
/**
@@ -302,7 +302,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
* @param amount The amount of the item to be added
* @return Returns whether or not it gave the item succesfully
*/
public boolean giveItem(ScriptItemStack item, int amount){
public boolean giveItem(IItemStack item, int amount){
if(item != null && item.getMCItemStack() != null) {
item.setStackSize(amount);
boolean bool = this.player.inventory.addItemStackToInventory(item.getMCItemStack());
@@ -347,10 +347,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
/**
* @param item The item to be removed from the players inventory
*/
public void removeAllItems(ScriptItemStack item){
public void removeAllItems(IItemStack item){
for(int i = 0; i < player.inventory.mainInventory.length; i++){
ItemStack is = player.inventory.mainInventory[i];
if (is != null && is.isItemEqual(item.item))
if (is != null && is.isItemEqual(item.getMCItemStack()))
player.inventory.mainInventory[i] = null;
}
}
@@ -383,15 +383,15 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
player.mountEntity(ridingEntity);
}
public ScriptEntity dropOneItem(boolean dropStack){
return new ScriptEntity(player.dropOneItem(dropStack));
public IEntity dropOneItem(boolean dropStack){
return NpcAPI.Instance().getIEntity(player.dropOneItem(dropStack));
}
public boolean canHarvestBlock(ScriptBlock block){
return player.canHarvestBlock(block.getMCBlock());
}
public boolean interactWith(ScriptEntity entity){
public boolean interactWith(IEntity entity){
return player.interactWith(entity.getMCEntity());
}
@@ -6,7 +6,7 @@
package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.scripted.AbstractNpcAPI;
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
public class CustomNPCsEvent extends Event{
public final AbstractNpcAPI API = AbstractNpcAPI.Instance();
@@ -18,7 +18,7 @@ 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;
import noppes.npcs.scripted.NpcAPI;
public class NpcEvent extends CustomNPCsEvent {
public final ICustomNpc npc;
@@ -41,7 +41,7 @@ public class NpcEvent extends CustomNPCsEvent {
public CollideEvent(ICustomNpc npc, Entity entity) {
super(npc);
this.entity = ScriptController.Instance.getScriptForEntity(entity);
this.entity = NpcAPI.Instance().getIEntity(entity);
}
}
@@ -54,7 +54,7 @@ public class NpcEvent extends CustomNPCsEvent {
public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) {
super(npc);
this.source = ScriptController.Instance.getScriptForEntity(source);
this.source = NpcAPI.Instance().getIEntity(source);
this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
}
@@ -71,7 +71,7 @@ public class NpcEvent extends CustomNPCsEvent {
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
}
@@ -83,7 +83,7 @@ public class NpcEvent extends CustomNPCsEvent {
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
}
@@ -93,7 +93,7 @@ public class NpcEvent extends CustomNPCsEvent {
public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) {
super(npc);
this.entity = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(entity);
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
}
}
@@ -108,7 +108,7 @@ public class NpcEvent extends CustomNPCsEvent {
super(npc);
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
this.type = damagesource.damageType;
this.source = ScriptController.Instance.getScriptForEntity(entity);
this.source = NpcAPI.Instance().getIEntity(entity);
}
public String getType(){
@@ -122,7 +122,7 @@ public class NpcEvent extends CustomNPCsEvent {
public InteractEvent(ICustomNpc npc, EntityPlayer player) {
super(npc);
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
}
}
@@ -134,7 +134,7 @@ public class NpcEvent extends CustomNPCsEvent {
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
@@ -149,7 +149,7 @@ public class NpcEvent extends CustomNPCsEvent {
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
@@ -162,7 +162,7 @@ public class NpcEvent extends CustomNPCsEvent {
public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) {
super(npc);
this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity);
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
}
}
@@ -172,7 +172,7 @@ public class NpcEvent extends CustomNPCsEvent {
public TargetEvent(ICustomNpc npc, EntityLivingBase entity) {
super(npc);
this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity);
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
}
}
@@ -12,15 +12,12 @@ import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.interfaces.*;
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.item.ScriptItemStack;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class PlayerEvent extends CustomNPCsEvent {
public final IPlayer player;
@@ -138,7 +135,7 @@ public class PlayerEvent extends CustomNPCsEvent {
public DamagedEvent(IPlayer player, Entity source, float damage, DamageSource damagesource) {
super(player);
this.source = ScriptController.Instance.getScriptForEntity(source);
this.source = NpcAPI.Instance().getIEntity(source);
this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
}
@@ -185,7 +182,7 @@ public class PlayerEvent extends CustomNPCsEvent {
public KilledEntityEvent(IPlayer player, EntityLivingBase entity) {
super(player);
this.entity = new ScriptLivingBase<>(entity);//NpcAPI.Instance().getIEntity(entity);
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
}
}
@@ -199,7 +196,7 @@ public class PlayerEvent extends CustomNPCsEvent {
super(player);
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
this.type = damagesource.getDamageType();
this.source = ScriptController.Instance.getScriptForEntity(entity);
this.source = NpcAPI.Instance().getIEntity(entity);
}
}
@@ -223,7 +220,7 @@ public class PlayerEvent extends CustomNPCsEvent {
public DamagedEntityEvent(IPlayer player, Entity target, float damage, DamageSource damagesource) {
super(player);
this.target = ScriptController.Instance.getScriptForEntity(target);
this.target = NpcAPI.Instance().getIEntity(target);
this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
}
@@ -378,7 +375,7 @@ public class PlayerEvent extends CustomNPCsEvent {
public UseHoe(IPlayer player, ItemStack item, int x, int y, int z) {
super(player);
this.hoe = new ScriptItemStack(item);
this.hoe = NpcAPI.Instance().getIItemStack(item);
this.x = x;
this.y = y;
this.z = z;
@@ -422,8 +419,8 @@ public class PlayerEvent extends CustomNPCsEvent {
public FillBucket(IPlayer player, ItemStack current, ItemStack result) {
super(player);
this.current = new ScriptItemStack(current);
this.result = new ScriptItemStack(result);
this.current = NpcAPI.Instance().getIItemStack(current);
this.result = NpcAPI.Instance().getIItemStack(result);
}
}
@@ -1,26 +1,26 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventAttack extends ScriptEvent{
private float damage;
private ScriptLivingBase target;
private IEntityLivingBase target;
private boolean isRanged;
public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){
this.damage = damage;
this.isRanged = isRanged;
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
* @deprecated
*/
public ScriptLivingBase getTarget(){
public IEntityLivingBase getTarget(){
return target;
}
@@ -2,26 +2,26 @@ package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventDamaged extends ScriptEvent{
private float damage;
private boolean clear = false;
private ScriptLivingBase source;
private IEntityLivingBase source;
private DamageSource damagesource;
public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){
this.damage = damage;
this.damagesource = damagesource;
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(attackingEntity);
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(attackingEntity);
}
/**
* @return The source of the damage
*/
public ScriptLivingBase getSource(){
public IEntityLivingBase getSource(){
return source;
}
@@ -3,6 +3,7 @@ package noppes.npcs.scripted.event;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptEventDialog extends ScriptEvent{
@@ -12,7 +13,7 @@ public class ScriptEventDialog extends ScriptEvent{
public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = (IPlayer) ScriptController.Instance.getScriptForEntity(player);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
this.dialog = dialog;
this.option = option;
this.dialogObj = dialogObj;
@@ -2,26 +2,28 @@ package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IDamageSource;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventKilled extends ScriptEvent{
private ScriptLivingBase source;
private IEntityLivingBase source;
private DamageSource damagesource;
public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){
this.damagesource = damagesource;
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
*/
public ScriptLivingBase getSource(){
public IEntityLivingBase getSource(){
return source;
}
public IDamageSource getDamageSource() { return NpcAPI.Instance().getIDamageSource(damagesource); }
/**
* @return Returns the damage type
*/
@@ -1,27 +1,26 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptEventTarget extends ScriptEvent {
private ScriptLivingBase target;
private IEntityLivingBase target;
public ScriptEventTarget(EntityLivingBase target){
if(target != null)
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
}
/**
* @return The source of the damage
*/
public ScriptLivingBase getTarget(){
public IEntityLivingBase getTarget(){
return target;
}
public void setTarget(ScriptLivingBase target){
public void setTarget(IEntityLivingBase target){
this.target = target;
}
}
@@ -14,7 +14,6 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.interfaces.gui.*;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
@@ -215,7 +214,7 @@ public class ScriptGui implements ICustomGui {
}
public void update(IPlayer player) {
CustomGuiController.updateGui((ScriptPlayer)player, this);
CustomGuiController.updateGui(player, this);
}
public boolean getShowPlayerInv() {
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.interfaces.gui.IItemSlot;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot {
IItemStack stack;
@@ -3,7 +3,7 @@
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted;
package noppes.npcs.scripted.interfaces;
import java.io.File;
@@ -18,10 +18,9 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.entity.ScriptPlayer;
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.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public abstract class AbstractNpcAPI {
@@ -71,7 +70,7 @@ public abstract class AbstractNpcAPI {
return null;
} else {
try {
Class c = Class.forName("noppes.npcs.scripted.wrapper.NpcAPI");
Class c = Class.forName("noppes.npcs.scripted.NpcAPI");
instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null);
} catch (Exception var1) {
var1.printStackTrace();
@@ -87,13 +86,13 @@ public abstract class AbstractNpcAPI {
public abstract INbt getINbt(NBTTagCompound entityData);
public abstract ScriptPlayer[] getAllServerPlayers();
public abstract IPlayer[] getAllServerPlayers();
public abstract IItemStack createItem(String id, int damage, int size);
public abstract ScriptParticle createParticle(String directory);
public abstract IParticle createParticle(String directory);
public abstract ScriptParticle createEntityParticle(String directory);
public abstract IParticle createEntityParticle(String directory);
public abstract int getServerTime();
}
@@ -7,9 +7,8 @@ package noppes.npcs.scripted.interfaces;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptPlayer;
public interface IContainer {
int getSize();
@@ -30,7 +29,7 @@ public interface IContainer {
void detectAndSendChanges();
void putStackInSlot(int slot, ScriptItemStack itemStack);
void putStackInSlot(int slot, IItemStack itemStack);
boolean isPlayerNotUsingContainer(ScriptPlayer player);
boolean isPlayerNotUsingContainer(IPlayer player);
}
@@ -2,11 +2,11 @@ package noppes.npcs.scripted.interfaces;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public interface IParticle {
void spawnOnEntity(ScriptEntity entity);
void spawnOnEntity(IEntity entity);
void spawnInWorld(ScriptWorld world);
@@ -3,11 +3,9 @@ package noppes.npcs.scripted.interfaces;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
public interface IWorld {
/**
@@ -58,25 +56,25 @@ public interface IWorld {
int getBlockLightValue(int x, int y, int z);
void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch);
void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch);
void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch);
void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch);
IEntity getEntityByID(int id);
boolean spawnEntityInWorld(ScriptEntity entity);
boolean spawnEntityInWorld(IEntity entity);
ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range);
IPlayer getClosestPlayerToEntity(IEntity entity, double range);
ScriptPlayer getClosestPlayer(double x, double y, double z, double range);
IPlayer getClosestPlayer(double x, double y, double z, double range);
ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range);
IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range);
ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
int countEntities(ScriptEntity entity);
int countEntities(IEntity entity);
void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity);
void setTileEntity(int x, int y, int z, ITileEntity tileEntity);
void removeTileEntity(int x, int y, int z);
@@ -105,7 +103,7 @@ public interface IWorld {
* @param z World position z
* @param item The block to be set
*/
void setBlock(int x, int y, int z, ScriptItemStack item);
void setBlock(int x, int y, int z, IItemStack item);
/**
* @param x World position x
@@ -118,9 +116,9 @@ public interface IWorld {
* @param name The name of the player to be returned
* @return The Player with name. Null is returned when the player isnt found
*/
ScriptPlayer getPlayer(String name);
IPlayer getPlayer(String name);
ScriptPlayer getPlayerByUUID(String uuid);
IPlayer getPlayerByUUID(String uuid);
/**
* @param time The world time to be set
@@ -173,9 +171,9 @@ public interface IWorld {
/**
* @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png"
* @return Returns ScriptEntityParticle object
* @return Returns IEntityParticle object
*/
ScriptParticle createEntityParticle(String directory);
IParticle createEntityParticle(String directory);
/**
* @param key Get temp data for this key
@@ -245,7 +243,7 @@ public interface IWorld {
*/
void explode(double x, double y, double z, float range, boolean fire, boolean grief);
ScriptPlayer[] getAllServerPlayers();
IPlayer[] getAllServerPlayers();
/**
* @since 1.7.10c
@@ -264,7 +262,7 @@ public interface IWorld {
* @param name Name of the cloned entity
* @return Returns the entity which was spawned
*/
ScriptEntity spawnClone(int x, int y, int z, int tab, String name);
IEntity spawnClone(int x, int y, int z, int tab, String name);
ScriptScoreboard getScoreboard();
@@ -9,9 +9,6 @@ import net.minecraft.entity.EntityCreature;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.roles.*;
public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
@@ -167,7 +164,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param item The item you want to shoot
* @param accuracy Accuracy of the shot (0-100)
*/
void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy);
void shootItem(IEntityLivingBase target, IItemStack item, int accuracy);
/**
* @param message The message the npc will say
@@ -177,7 +174,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param message The message the npc will say
*/
void say(ScriptPlayer player, String message);
void say(IPlayer player, String message);
/**
* Kill the npc, doesnt't despawn it
@@ -211,7 +208,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be held in the right hand
*/
void setRightItem(ScriptItemStack item);
void setRightItem(IItemStack item);
/**
* @return The item held in the left hand
@@ -221,7 +218,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be held in the left hand
*/
void setLeftItem(ScriptItemStack item);
void setLeftItem(IItemStack item);
/**
* @return Returns the projectile the npc uses
@@ -231,7 +228,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be used as projectile
*/
void setProjectileItem(ScriptItemStack item);
void setProjectileItem(IItemStack item);
/**
*
@@ -288,7 +285,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots
* @param item Item to be set as armor
*/
void setArmor(int slot, ScriptItemStack item);
void setArmor(int slot, IItemStack item);
/**
*
@@ -302,7 +299,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param slot The slot from the NPC's drop list to change
* @param item The item the drop list slot will be changed to
*/
void setLootItem(int slot, ScriptItemStack item);
void setLootItem(int slot, IItemStack item);
/**
*
@@ -488,7 +485,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param player The player this NPC becomes visible/invisible to
* @param visible True if you want the NPC to be invisible to the player, false otherwise
*/
void setVisibleTo(ScriptPlayer player, boolean visible);
void setVisibleTo(IPlayer player, boolean visible);
/**
*
@@ -497,7 +494,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* If setVisibleTo(player,visible) was not called to make this NPC invisible to the player at any point
* in the NPC's life, this function will return true regardless of the value of isVisible().
*/
boolean isVisibleTo(ScriptPlayer player);
boolean isVisibleTo(IPlayer player);
/**
* @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
@@ -621,7 +618,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param player The player to give the item to
* @param item The item given to the player
*/
void giveItem(ScriptPlayer player, ScriptItemStack item);
void giveItem(IPlayer player, IItemStack item);
/**
@@ -8,10 +8,9 @@ package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.Entity;
import noppes.npcs.scripted.ScriptParticle;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IEntity<T extends Entity> {
@@ -129,14 +128,14 @@ public interface IEntity<T extends Entity> {
* @param range The search range for entities around this entity
* @return Array of entities within range
*/
ScriptEntity[] getSurroundingEntities(int range);
IEntity[] getSurroundingEntities(int range);
/**
* @param range The search range for entities around this entity
* @param type The EntityType you want to find
* @return Array of entities within range
*/
ScriptEntity[] getSurroundingEntities(int range, int type);
IEntity[] getSurroundingEntities(int range, int type);
/**
* @return Whether the entity is alive or not
@@ -249,27 +248,27 @@ public interface IEntity<T extends Entity> {
/**
* @param item Item to be dropped
*/
void dropItem(ScriptItemStack item);
void dropItem(IItemStack item);
/**
* @return Return the rider
*/
ScriptEntity getRider();
IEntity getRider();
/**
* @param entity The entity to ride this entity
*/
void setRider(ScriptEntity entity);
void setRider(IEntity entity);
/**
* @return Return the entity, this entity is riding
*/
ScriptEntity getMount();
IEntity getMount();
/**
* @param entity The entity this entity will mount
*/
void setMount(ScriptEntity entity);
void setMount(IEntity entity);
/**
* @see noppes.npcs.scripted.constants.EntityType
@@ -1,11 +1,8 @@
package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.wrapper.ScriptDamageSource;
import noppes.npcs.scripted.ScriptDamageSource;
public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T> {
/**
@@ -20,7 +17,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
void hurt(float damage);
void hurt(float damage, ScriptEntity source);
void hurt(float damage, IEntity source);
void hurt(float damage, ScriptDamageSource damageSource);
@@ -36,12 +33,12 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
/**
* @param living Entity which this entity will attack
*/
void setAttackTarget(ScriptLivingBase living);
void setAttackTarget(IEntityLivingBase living);
/**
* @return The entity which this entity is attacking
*/
ScriptLivingBase getAttackTarget();
IEntityLivingBase getAttackTarget();
int getType();
@@ -51,7 +48,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @param entity Entity to check
* @return Whether or not this entity can see the given entity
*/
boolean canSeeEntity(ScriptEntity entity);
boolean canSeeEntity(IEntity entity);
/**
* Expert use only
@@ -97,7 +94,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @since 1.7.10c
* @param item The item to be set
*/
void setHeldItem(ScriptItemStack item);
void setHeldItem(IItemStack item);
/**
* Note not all Living Entities support this
@@ -112,5 +109,5 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head
* @param item Item to be set
*/
void setArmor(int slot, ScriptItemStack item);
void setArmor(int slot, IItemStack item);
}
@@ -4,13 +4,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.ScriptBlock;
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T> {
@@ -103,7 +101,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param item The item to be checked
* @return How many of this item the player has
*/
int inventoryItemCount(ScriptItemStack item);
int inventoryItemCount(IItemStack item);
/**
* @since 1.7.10d
@@ -116,7 +114,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param amount How many will be removed
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given
*/
boolean removeItem(ScriptItemStack item, int amount);
boolean removeItem(IItemStack item, int amount);
/**
* @since 1.7.10c
@@ -133,7 +131,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param amount The amount of the item to be added
* @return Returns whether or not it gave the item succesfully
*/
boolean giveItem(ScriptItemStack item, int amount);
boolean giveItem(IItemStack item, int amount);
/**
* @since 1.7.10c
@@ -157,7 +155,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
/**
* @param item The item to be removed from the players inventory
*/
void removeAllItems(ScriptItemStack item);
void removeAllItems(IItemStack item);
void setRotation(float rotationYaw, float rotationPitch);
@@ -169,11 +167,11 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
void mountEntity(Entity ridingEntity);
ScriptEntity dropOneItem(boolean dropStack);
IEntity dropOneItem(boolean dropStack);
boolean canHarvestBlock(ScriptBlock block);
boolean interactWith(ScriptEntity entity);
boolean interactWith(IEntity entity);
/**
* @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements
@@ -1,6 +1,36 @@
package noppes.npcs.scripted.interfaces.item;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public interface IItemCustom extends IItemStack {
void callScript(EnumScriptType type, Event event);
boolean isClient();
boolean getEnabled();
void setEnabled(boolean bo);
String getLanguage();
void setLanguage(String lang);
List<ScriptContainer> getScripts();
String noticeString();
Map<Long, String> getConsoleText();
void clearConsole();
String getTexture();
void setTexture(String var2);
@@ -22,11 +22,10 @@ import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.ScriptNbt;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class ScriptItemStack implements IItemStack {
public ItemStack item;
private NBTTagCompound storedData = new NBTTagCompound();
public ScriptItemStack(ItemStack item){
this.item = item;
@@ -4,7 +4,6 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.overlay.*;
@@ -113,7 +112,7 @@ public class ScriptOverlay implements ICustomOverlay {
}
public void update(IPlayer player) {
CustomGuiController.updateOverlay((ScriptPlayer)player, this);
CustomGuiController.updateOverlay(player, this);
}
public ICustomOverlay fromNBT(NBTTagCompound tag) {
@@ -2,8 +2,8 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobFollower;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
public class ScriptJobFollower extends ScriptJobInterface{
private JobFollower job;
@@ -20,10 +20,10 @@ public class ScriptJobFollower extends ScriptJobInterface{
job.name = name;
}
public ScriptNpc getFollowingNpc(){
public ICustomNpc getFollowingNpc(){
if(!isFollowing())
return null;
return (ScriptNpc)job.following.script.dummyNpc;
return job.following.script.dummyNpc;
}
public boolean isFollowing(){
@@ -2,8 +2,8 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobHealer;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptJobHealer extends ScriptJobInterface{
private JobHealer job;
@@ -12,7 +12,7 @@ public class ScriptJobHealer extends ScriptJobInterface{
this.job = (JobHealer) npc.jobInterface;
}
public void heal(ScriptLivingBase entity, float amount){
public void heal(IEntityLivingBase entity, float amount){
job.heal(entity.getMCEntity(), amount);
}
@@ -3,11 +3,11 @@ package noppes.npcs.scripted.roles;
import java.util.ArrayList;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public class ScriptJobSpawner extends ScriptJobInterface{
private JobSpawner job;
@@ -26,12 +26,12 @@ public class ScriptJobSpawner extends ScriptJobInterface{
* @param number The entity going to be spawned (1-6)
* @return Returns spawned entity
*/
public ScriptLivingBase spawnEntity(int number){
public IEntityLivingBase spawnEntity(int number){
EntityLivingBase base = job.spawnEntity(number);
if(base == null)
return null;
return (ScriptLivingBase) ScriptController.Instance.getScriptForEntity(base);
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base);
}
/**
@@ -1,11 +1,11 @@
package noppes.npcs.scripted.roles;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptRoleFollower extends ScriptRoleInterface{
private RoleFollower role;
@@ -18,7 +18,7 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
* @since 1.7.10c
* @param player Player who is set as the owner. If null given everything resets
*/
public void setOwner(ScriptPlayer player){
public void setOwner(IPlayer player){
if(player == null || player.getMCEntity() == null){
role.setOwner(null);
return;
@@ -31,11 +31,11 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
* @since 1.7.10c
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
*/
public ScriptPlayer getOwner(){
public IPlayer getOwner(){
if(role.owner == null)
return null;
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(role.owner);
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
}
/**
@@ -2,7 +2,7 @@ package noppes.npcs.scripted.roles;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTrader;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.constants.RoleType;
import foxz.utils.Market;
@@ -19,7 +19,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
* @param currency2 Currency item number two
* @param sold Item to be sold by this npc
*/
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack currency2, ScriptItemStack sold){
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){
if(sold == null || slot >= 18 || slot < 0)
return;
if(currency == null)
@@ -42,7 +42,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
* @param currency Currency item
* @param sold Item to be sold by this npc
*/
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack sold){
public void setSellOption(int slot, IItemStack currency, IItemStack sold){
setSellOption(slot, currency, null, sold);
}
@@ -1,59 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.wrapper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.scripted.entity.*;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public class WrapperEntityData{
public IEntity base;
private static final ResourceLocation key = new ResourceLocation("customnpcs", "entitydata");
public WrapperEntityData(IEntity base) {
this.base = base;
}
public static IEntity get(Entity entity) {
if (entity == null) {
return null;
} else {
WrapperEntityData data = new WrapperEntityData(new ScriptEntity(entity));
if (data == null) {
return getData(entity).base;
} else {
return data.base;
}
}
}
private static WrapperEntityData getData(Entity entity) {
if (entity != null && entity.worldObj != null && !entity.worldObj.isRemote) {
if (entity instanceof EntityPlayerMP) {
return new WrapperEntityData(new ScriptPlayer((EntityPlayerMP)entity));
} else if (PixelmonHelper.isPixelmon(entity)) {
return new WrapperEntityData(new ScriptPixelmon((EntityTameable)entity));
} else if (entity instanceof EntityAnimal) {
return new WrapperEntityData(new ScriptAnimal((EntityAnimal)entity));
} else if (entity instanceof EntityMob) {
return new WrapperEntityData(new ScriptMonster((EntityMob)entity));
} else if (entity instanceof EntityLiving) {
return new WrapperEntityData(new ScriptLiving((EntityLiving)entity));
} else if (entity instanceof EntityLivingBase) {
return new WrapperEntityData(new ScriptLivingBase((EntityLivingBase)entity));
}
}
return null;
}
}