mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 08:45:11 +00:00
IEntityItem added
This commit is contained in:
1 parent
f5cf78e1fb
commit
fd7f550316
2 files changed
+74
No files matched your search
@@ -14,6 +14,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.INpc;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
@@ -205,6 +206,8 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
data = new ScriptEntityData(new ScriptLivingBase<>((EntityLivingBase)entity));
|
||||
else if(entity instanceof EntityProjectile)
|
||||
data = new ScriptEntityData(new ScriptProjectile<>((EntityProjectile)entity));
|
||||
else if(entity instanceof EntityItem)
|
||||
data = new ScriptEntityData(new ScriptEntityItem<>((EntityItem)entity));
|
||||
else
|
||||
data = new ScriptEntityData(new ScriptEntity<>(entity));
|
||||
entity.registerExtendedProperties("ScriptedObject", data);
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.api.entity.IEntityItem;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptEntityItem<T extends EntityItem> extends ScriptEntity<T> implements IEntityItem {
|
||||
private T entity;
|
||||
|
||||
public ScriptEntityItem(T entityItem) {
|
||||
super(entityItem);
|
||||
this.entity = entityItem;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return this.entity.func_145798_i();
|
||||
}
|
||||
|
||||
public void setOwner(String name) {
|
||||
this.entity.func_145797_a(name);
|
||||
}
|
||||
|
||||
public String getThrower() {
|
||||
return this.entity.func_145800_j();
|
||||
}
|
||||
|
||||
public void setThrower(String name) {
|
||||
this.entity.func_145799_b(name);
|
||||
}
|
||||
|
||||
public int getPickupDelay() {
|
||||
return this.entity.delayBeforeCanPickup;
|
||||
}
|
||||
|
||||
public void setPickupDelay(int delay) {
|
||||
this.entity.delayBeforeCanPickup = delay;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return EntityType.ITEM;
|
||||
}
|
||||
|
||||
public long getAge() {
|
||||
return this.entity.age;
|
||||
}
|
||||
|
||||
public void setAge(long age) {
|
||||
age = Math.max(Math.min(age, Integer.MAX_VALUE), Integer.MIN_VALUE);
|
||||
this.entity.age = (int)age;
|
||||
}
|
||||
|
||||
public int getLifeSpawn() {
|
||||
return this.entity.lifespan;
|
||||
}
|
||||
|
||||
public void setLifeSpawn(int age) {
|
||||
this.entity.lifespan = age;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return NpcAPI.Instance().getIItemStack(this.entity.getEntityItem());
|
||||
}
|
||||
|
||||
public void setItem(IItemStack item) {
|
||||
ItemStack stack = item == null? null : item.getMCItemStack();
|
||||
this.entity.setEntityItemStack(stack);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user