mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 05:45:03 +00:00
Implement ScriptArrow, ScriptThrowable, ScriptFishHook
This commit is contained in:
1 parent
1b76f1ab7e
commit
3867ab43b7
6 files changed
+125
-1
No files matched your search
@@ -17,6 +17,9 @@ import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityFishHook;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -327,6 +330,12 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
data = new ScriptEntityData(new ScriptProjectile<>((EntityProjectile) entity));
|
||||
else if (entity instanceof EntityItem)
|
||||
data = new ScriptEntityData(new ScriptEntityItem<>((EntityItem) entity));
|
||||
else if (entity instanceof EntityThrowable)
|
||||
data = new ScriptEntityData(new ScriptThrowable<>((EntityThrowable) entity));
|
||||
else if (entity instanceof EntityArrow)
|
||||
data = new ScriptEntityData(new ScriptArrow<>((EntityArrow) entity));
|
||||
else if (entity instanceof EntityFishHook)
|
||||
data = new ScriptEntityData(new ScriptFishHook<>((EntityFishHook) entity));
|
||||
else
|
||||
data = new ScriptEntityData(new ScriptEntity<>(entity));
|
||||
entity.registerExtendedProperties("ScriptedObject", data);
|
||||
|
||||
@@ -11,4 +11,7 @@ public class EntityType {
|
||||
public static final int PROJECTILE = 7;
|
||||
public static final int PIXELMON = 8;
|
||||
public static final int VILLAGER = 9;
|
||||
public static final int ARROW = 10;
|
||||
public static final int THROWABLE = 11;
|
||||
public static final int FISH_HOOK = 12;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import noppes.npcs.api.entity.IArrow;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptArrow<T extends EntityArrow> extends ScriptEntity<T> implements IArrow {
|
||||
|
||||
public ScriptArrow(T entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntity getShooter() {
|
||||
if(entity.shootingEntity != null)
|
||||
return NpcAPI.Instance().getIEntity(entity.shootingEntity);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage() {
|
||||
return entity.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
entity.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return EntityType.ARROW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type) {
|
||||
return type == EntityType.ARROW || super.typeOf(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityFishHook;
|
||||
import noppes.npcs.api.entity.IFishHook;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptFishHook<T extends EntityFishHook> extends ScriptEntity<T> implements IFishHook {
|
||||
|
||||
public ScriptFishHook(T entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getCaster() {
|
||||
if(entity.field_146042_b != null)
|
||||
return (IPlayer) NpcAPI.Instance().getIEntity(entity.field_146042_b);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
entity.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return EntityType.FISH_HOOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type) {
|
||||
return type == EntityType.FISH_HOOK || super.typeOf(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import noppes.npcs.api.entity.*;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptThrowable<T extends EntityThrowable> extends ScriptEntity<T> implements IThrowable {
|
||||
|
||||
public ScriptThrowable(T entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityLivingBase getThrower() {
|
||||
if(entity.getThrower() != null)
|
||||
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getThrower());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
entity.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return EntityType.THROWABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type) {
|
||||
return type == EntityType.THROWABLE || super.typeOf(type);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user