mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 21:05:06 +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
@@ -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){
|
||||
|
||||
Reference in new issue
Block a user