mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 05:02:37 +00:00
Used interfaces in implementations instead of the real classes for most scripted classes.
This commit is contained in:
1 parent
6896cec417
commit
cf33b90b26
63 files changed
+466
-551
No files matched your search
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user