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

@@ -2,10 +2,7 @@ package foxz.command;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.EventHooks;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerFactionData;
import foxz.commandhelper.ChMcLogger;
@@ -13,8 +10,6 @@ import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly;
import foxz.commandhelper.permissions.ParamCheck;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.FactionEvent;
@Command(
name = "faction",
+1 -1
View File
@@ -26,7 +26,7 @@ import noppes.npcs.controllers.*;
import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.*;
import noppes.npcs.entity.old.*;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import java.io.File;
import java.util.Set;
+3 -4
View File
@@ -16,14 +16,13 @@ import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.event.ScriptEvent;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class DataScript implements IScriptHandler {
public List<ScriptContainer> scripts = new ArrayList();
@@ -47,7 +46,7 @@ public class DataScript implements IScriptHandler {
}
this.npc = npc;
dummyNpc = new ScriptNpc<>(npc);
dummyNpc = (ICustomNpc) NpcAPI.Instance().getIEntity(npc);
if(npc.worldObj instanceof WorldServer)
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
@@ -119,7 +118,7 @@ public class DataScript implements IScriptHandler {
for(int i = 0; i + 1 < obs.length; i += 2){
Object ob = obs[i + 1];
if(ob instanceof Entity)
ob = ScriptController.Instance.getScriptForEntity((Entity)ob);
ob = NpcAPI.Instance().getIEntity((Entity)ob);
script.engine.put(obs[i].toString(), ob);
}
+56 -59
View File
@@ -23,8 +23,6 @@ import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
@@ -38,10 +36,9 @@ import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
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.item.ScriptCustomItem;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.constants.EnumScriptType;
import org.apache.commons.lang3.StringUtils;
@@ -51,7 +48,7 @@ public class EventHooks {
public EventHooks() {
}
public static void onScriptItemInit(ScriptCustomItem handler) {
public static void onScriptItemInit(IItemCustom handler) {
if (!handler.isClient()) {
ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler);
handler.callScript(EnumScriptType.INIT, event);
@@ -59,61 +56,61 @@ public class EventHooks {
}
}
public static void onScriptItemUpdate(ScriptCustomItem handler, EntityLivingBase player) {
public static void onScriptItemUpdate(IItemCustom handler, EntityLivingBase player) {
if (!handler.isClient()) {
ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, ScriptController.Instance.getScriptForEntity(player));
ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, NpcAPI.Instance().getIEntity(player));
handler.callScript(EnumScriptType.TICK, event);
NpcAPI.EVENT_BUS.post(event);
}
}
public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) {
ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ScriptController.Instance.getScriptForEntity(entity));
public static boolean onScriptItemTossed(IItemCustom handler, EntityPlayer player, EntityItem entity) {
ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity));
handler.callScript(EnumScriptType.TOSSED, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemPickedUp(ScriptCustomItem handler, EntityPlayer player) {
ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player));
public static boolean onScriptItemPickedUp(IItemCustom handler, EntityPlayer player) {
ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player));
handler.callScript(EnumScriptType.PICKEDUP, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) {
ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, ScriptController.Instance.getScriptForEntity(entity));
public static boolean onScriptItemSpawn(IItemCustom handler, EntityItem entity) {
ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, NpcAPI.Instance().getIEntity(entity));
handler.callScript(EnumScriptType.SPAWN, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemInteract(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) {
public static boolean onScriptItemInteract(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) {
handler.callScript(EnumScriptType.INTERACT, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemAttack(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) {
public static boolean onScriptItemAttack(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) {
handler.callScript(EnumScriptType.ATTACK, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) {
public static boolean onStartUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) {
public static boolean onUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) {
public static boolean onStopUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onFinishUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) {
public static boolean onFinishUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
@@ -262,13 +259,13 @@ public class EventHooks {
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerInit(PlayerDataScript handler, IPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
handler.callScript(EnumScriptType.INIT, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerTick(PlayerDataScript handler, IPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
handler.callScript(EnumScriptType.TICK, event);
NpcAPI.EVENT_BUS.post(event);
@@ -279,31 +276,31 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
public static boolean onPlayerDropItems(PlayerDataScript handler, IPlayer player, ArrayList<EntityItem> entityItems) {
IItemStack[] items = new IItemStack[entityItems.size()];
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
@@ -312,55 +309,55 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
public static void onPlayerPickupXP(PlayerDataScript handler, IPlayer player, EntityXPOrb orb) {
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
handler.callScript(EnumScriptType.PICKUP_XP, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
public static boolean onPlayerToss(PlayerDataScript handler, IPlayer player, EntityItem entityItem) {
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.TOSS, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
public static boolean onPlayerPickUp(PlayerDataScript handler, IPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.PICKUP, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
public static void onPlayerContainerOpen(PlayerDataScript handler, IPlayer player, Container container) {
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
public static void onPlayerUseHoe(PlayerDataScript handler, IPlayer player, ItemStack hoe, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
handler.callScript(EnumScriptType.USE_HOE, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
public static void onPlayerSleep(PlayerDataScript handler, IPlayer player, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
handler.callScript(EnumScriptType.SLEEP, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
public static void onPlayerWakeUp(PlayerDataScript handler, IPlayer player, boolean setSpawn) {
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
handler.callScript(EnumScriptType.WAKE_UP, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
public static void onPlayerDeath(PlayerDataScript handler, IPlayer player, DamageSource source, Entity entity) {
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
handler.callScript(EnumScriptType.KILLED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
public static void onPlayerKills(PlayerDataScript handler, IPlayer player, EntityLivingBase entityLiving) {
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
handler.callScript(EnumScriptType.KILLS, event);
NpcAPI.EVENT_BUS.post(event);
@@ -371,61 +368,61 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
public static boolean onPlayerLightning(PlayerDataScript handler, IPlayer player) {
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
handler.callScript(EnumScriptType.LIGHTNING, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
public static boolean onPlayerSound(PlayerDataScript handler, IPlayer player, String name, float pitch, float volume) {
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
handler.callScript(EnumScriptType.PLAYSOUND, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
public static void onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
handler.callScript(EnumScriptType.FALL, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerJump(PlayerDataScript handler, IPlayer player) {
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
handler.callScript(EnumScriptType.JUMP, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerLogin(PlayerDataScript handler, IPlayer player) {
LoginEvent event = new LoginEvent(player);
handler.callScript(EnumScriptType.LOGIN, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
public static void onPlayerAchievement(PlayerDataScript handler, IPlayer player, String description) {
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
public static void onPlayerFillBucket(PlayerDataScript handler, IPlayer player, ItemStack current, ItemStack result) {
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
handler.callScript(EnumScriptType.FILL_BUCKET, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
public static void onPlayerBonemeal(PlayerDataScript handler, IPlayer player, int x, int y, int z, World world) {
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
handler.callScript(EnumScriptType.BONEMEAL, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerRespawn(PlayerDataScript handler, IPlayer player) {
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
handler.callScript(EnumScriptType.RESPAWN, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerLogout(PlayerDataScript handler, IPlayer player) {
LogoutEvent event = new LogoutEvent(player);
handler.callScript(EnumScriptType.LOGOUT, event);
NpcAPI.EVENT_BUS.post(event);
@@ -451,7 +448,7 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
public static void onPlayerChangeDim(PlayerDataScript handler, IPlayer player, int fromDim, int toDim) {
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
handler.callScript(EnumScriptType.CHANGED_DIM, event);
NpcAPI.EVENT_BUS.post(event);
@@ -459,21 +456,21 @@ public class EventHooks {
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
KeyPressedEvent event = new KeyPressedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTimer(PlayerData data, int id) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer)NpcAPI.Instance().getIEntity(data.player), id);
handler.callScript(EnumScriptType.TIMER, event);
NpcAPI.EVENT_BUS.post(event);
}
@@ -484,7 +481,7 @@ public class EventHooks {
}
public static void onForgeEntityEvent(EntityEvent event) {
IEntity e = ScriptController.Instance.getScriptForEntity(event.entity);
IEntity e = NpcAPI.Instance().getIEntity(event.entity);
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event);
}
@@ -520,41 +517,41 @@ public class EventHooks {
}
}
public static void onCustomGuiButton(ScriptPlayer player, ICustomGui gui, int buttonId) {
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
CustomGuiEvent.ButtonEvent event = new CustomGuiEvent.ButtonEvent(player, gui, buttonId);
CustomGuiController.onButton(event);
}
public static void onCustomGuiSlot(ScriptPlayer player, ICustomGui gui, int slotId) {
public static void onCustomGuiSlot(IPlayer player, ICustomGui gui, int slotId) {
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId));
CustomGuiController.onSlotChange(event);
}
public static void onCustomGuiUnfocused(ScriptPlayer player, ICustomGui gui, int textfieldId) {
public static void onCustomGuiUnfocused(IPlayer player, ICustomGui gui, int textfieldId) {
CustomGuiEvent.UnfocusedEvent event = new CustomGuiEvent.UnfocusedEvent(player, gui, textfieldId);
CustomGuiController.onCustomGuiUnfocused(event);
}
public static void onCustomGuiScrollClick(ScriptPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
public static void onCustomGuiScrollClick(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
CustomGuiEvent.ScrollEvent event = new CustomGuiEvent.ScrollEvent(player, gui, scrollId, scrollIndex, selection, doubleClick);
CustomGuiController.onScrollClick(event);
}
public static void onCustomGuiClose(ScriptPlayer player, ICustomGui gui) {
public static void onCustomGuiClose(IPlayer player, ICustomGui gui) {
noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui);
CustomGuiController.onClose(event);
}
public static void onQuestFinished(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onQuestStarted(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_START, event);
return NpcAPI.EVENT_BUS.post(event);
}
@@ -29,11 +29,11 @@ import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.QuestEvent;
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 NoppesUtilPlayer {
@@ -255,16 +255,16 @@ public class NoppesUtilPlayer {
if(dialog == null)
return;
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
return;
}
DialogOption option = dialog.options.get(optionId);
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
return;
}
if(option.optionType == EnumOptionType.RoleOption){
@@ -302,7 +302,7 @@ public class NoppesUtilPlayer {
if(!data.quest.questInterface.isCompleted(playerData))
return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest);
event.expReward = data.quest.rewardExp;
List<IItemStack> list = new ArrayList();
@@ -72,9 +72,9 @@ import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTransporter;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.ScriptEventDialog;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class NoppesUtilServer {
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
@@ -183,7 +183,7 @@ public class NoppesUtilServer {
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
Dialog dialog = dia.copy(player);
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
if(npc instanceof EntityDialogNpc){
dialog.hideNPC = true;
@@ -51,8 +51,9 @@ import noppes.npcs.roles.RoleTrader;
import noppes.npcs.roles.RoleTransporter;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.item.ScriptCustomItem;
public class PacketHandlerServer{
@@ -78,22 +79,22 @@ public class PacketHandlerServer{
return;
} else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiButton((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
return;
} else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiUnfocused((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiScrollClick((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
EventHooks.onCustomGuiScrollClick((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
return;
} else if (type == EnumPacketServer.CustomGuiClose) {
EventHooks.onCustomGuiClose((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
return;
}
@@ -12,15 +12,13 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ItemEvent;
import noppes.npcs.scripted.interfaces.item.IItemCustom;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.item.ScriptCustomItem;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import java.util.HashMap;
@@ -42,13 +40,13 @@ public class ScriptItemEventHandler {
for (ItemStack stack : inventory.values()) {
if (stack != null && stack.getItem() == CustomItems.scripted_item) {
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
EventHooks.onScriptItemUpdate((ScriptCustomItem) istack, event.entityLiving);
EventHooks.onScriptItemUpdate((IItemCustom) istack, event.entityLiving);
}
}
}
} else if(event.entityLiving.getHeldItem() != null && event.entityLiving.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem());
EventHooks.onScriptItemUpdate((ScriptCustomItem) itemStack, event.entityLiving);
EventHooks.onScriptItemUpdate((IItemCustom) itemStack, event.entityLiving);
}
}
@@ -60,7 +58,7 @@ public class ScriptItemEventHandler {
if(event.player.worldObj instanceof WorldServer) {
try {
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem);
}
} catch (Exception e) {}
@@ -75,7 +73,7 @@ public class ScriptItemEventHandler {
if(event.player.worldObj instanceof WorldServer) {
try {
if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem());
IItemCustom isw = ItemScripted.GetWrapper(event.player.getHeldItem());
EventHooks.onScriptItemPickedUp(isw, event.player);
}
} catch(Exception e) {}
@@ -104,8 +102,8 @@ public class ScriptItemEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
try {
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ)));
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ)));
event.setCanceled(EventHooks.onScriptItemInteract(isw, eve));
}
} catch(Exception e) {}
@@ -118,9 +116,9 @@ public class ScriptItemEventHandler {
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
ScriptCustomItem handler = ItemScripted.GetWrapper(event.item);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingCustomItem(handler, scriptPlayer, event.duration));
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
@@ -129,9 +127,9 @@ public class ScriptItemEventHandler {
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
ScriptCustomItem handler = ItemScripted.GetWrapper(event.item);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingCustomItem(handler, scriptPlayer, event.duration));
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
@@ -140,9 +138,9 @@ public class ScriptItemEventHandler {
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
ScriptCustomItem handler = ItemScripted.GetWrapper(event.item);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingCustomItem(handler, scriptPlayer, event.duration));
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
@@ -151,9 +149,9 @@ public class ScriptItemEventHandler {
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
ScriptCustomItem handler = ItemScripted.GetWrapper(event.item);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onFinishUsingCustomItem(handler, scriptPlayer, event.duration);
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingCustomItem(handler, IPlayer, event.duration);
}
}
}
@@ -30,8 +30,8 @@ import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() {
@@ -46,7 +46,7 @@ public class ScriptPlayerEventHandler {
if(player.ticksExisted%10 == 0) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
}
@@ -71,8 +71,8 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, ScriptController.Instance.getScriptForEntity(event.target));
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
}
}
@@ -84,7 +84,7 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
EventHooks.onPlayerBowCharge(handler, ev);
}
@@ -97,7 +97,7 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
EventHooks.onPlayerRanged(handler, ev);
}
@@ -110,7 +110,7 @@ public class ScriptPlayerEventHandler {
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
event.setExpToDrop(ev.exp);
@@ -124,7 +124,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -135,7 +135,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -146,7 +146,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -157,7 +157,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
}
}
@@ -169,7 +169,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
}
}
@@ -181,7 +181,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
}
}
@@ -193,7 +193,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
}
}
@@ -205,7 +205,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
}
}
@@ -217,7 +217,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
}
}
@@ -229,7 +229,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
}
}
@@ -241,7 +241,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
}
}
@@ -253,7 +253,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
}
}
@@ -265,7 +265,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
}
}
@@ -277,7 +277,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
}
}
@@ -289,7 +289,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
}
}
@@ -301,7 +301,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
}
}
@@ -314,7 +314,7 @@ public class ScriptPlayerEventHandler {
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
}
}
@@ -328,7 +328,7 @@ public class ScriptPlayerEventHandler {
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerJump(handler, scriptPlayer);
}
}
@@ -342,7 +342,7 @@ public class ScriptPlayerEventHandler {
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
EventHooks.onPlayerLightning(handler, scriptPlayer);
}
}
@@ -356,7 +356,7 @@ public class ScriptPlayerEventHandler {
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
}
}
@@ -371,12 +371,12 @@ public class ScriptPlayerEventHandler {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
}
if(source instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity());
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
}
@@ -392,13 +392,13 @@ public class ScriptPlayerEventHandler {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
event.ammount = pevent.damage;
}
if(source instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
event.ammount = pevent1.damage;
}
@@ -412,7 +412,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);
}
}
@@ -424,7 +424,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
}
}
@@ -436,7 +436,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogout(handler, scriptPlayer);
}
}
@@ -450,7 +450,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
String message = event.message;
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
EventHooks.onPlayerChat(handler, ev);
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import noppes.npcs.CustomItems;
import noppes.npcs.items.ItemRenderInterface;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.item.ScriptCustomItem;
@@ -104,7 +105,7 @@ public class CustomItemRenderer implements IItemRenderer {
GL11.glTranslatef(0.9375F, 0.0625F, 0.0F);
GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F);
((ItemRenderInterface) itemStack.getItem()).renderSpecial();
((ItemScripted) itemStack.getItem()).renderOffset(scriptCustomItem);
GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ);
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
@@ -10,12 +10,12 @@ import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.CustomGuiEvent;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import java.io.IOException;
@@ -23,14 +23,14 @@ public class CustomGuiController {
public CustomGuiController() {
}
public static void openGui(ScriptPlayer player, ScriptGui gui) {
public static void openGui(IPlayer player, ScriptGui gui) {
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
}
public static boolean updateGui(ScriptPlayer player, ScriptGui gui) {
public static boolean updateGui(IPlayer player, ScriptGui gui) {
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
return true;
@@ -39,11 +39,11 @@ public class CustomGuiController {
}
}
public static void openOverlay(ScriptPlayer player, ScriptOverlay gui) {
public static void openOverlay(IPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()});
}
public static boolean updateOverlay(ScriptPlayer player, ScriptOverlay gui) {
public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()});
return true;
}
@@ -1,12 +1,8 @@
package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.EventHooks;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.FactionEvent;
public class FactionOptions {
@@ -7,8 +7,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.EventHooks;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.FactionEvent;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class PlayerFactionData {
public HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
@@ -51,7 +52,7 @@ public class PlayerFactionData {
}
public void increasePoints(int factionId, int points, EntityPlayer player) {
EventHooks.onFactionPoints(new FactionEvent.FactionPoints(new ScriptPlayer((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points));
EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points));
if(!factionData.containsKey(factionId)){
Faction faction = FactionController.getInstance().get(factionId);
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
@@ -23,7 +23,7 @@ import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface;
import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class Quest implements ICompatibilty, IQuest {
public int version = VersionCompatibility.ModRev;
@@ -19,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class ScriptContainer {
private static final String lock = "lock";
@@ -284,36 +284,8 @@ public class ScriptController {
return list;
}
public ScriptEntity getScriptForEntity(Entity entity) {
if(entity == null)
return null;
if(entity instanceof EntityNPCInterface)
return (ScriptNpc)((EntityNPCInterface) entity).script.dummyNpc;
else{
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
if(data != null)
return data.base;
if(entity instanceof EntityPlayerMP)
data = new ScriptEntityData(new ScriptPlayer((EntityPlayerMP) entity));
else if(PixelmonHelper.isPixelmon(entity))
return new ScriptPixelmon((EntityTameable) entity);
else if(entity instanceof EntityAnimal)
data = new ScriptEntityData(new ScriptAnimal((EntityAnimal) entity));
else if(entity instanceof EntityMob)
data = new ScriptEntityData(new ScriptMonster((EntityMob) entity));
else if(entity instanceof EntityLiving)
data = new ScriptEntityData(new ScriptLiving((EntityLiving) entity));
else if(entity instanceof EntityLivingBase)
data = new ScriptEntityData(new ScriptLivingBase((EntityLivingBase)entity));
else
data = new ScriptEntityData(new ScriptEntity(entity));
entity.registerExtendedProperties("ScriptedObject", data);
return data.base;
}
}
@SubscribeEvent
public void saveWorld(WorldEvent.Save event){
public void invoke(WorldEvent.Save event){
if(!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0])
return;
@@ -4,13 +4,14 @@ import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public class ScriptEntityData implements IExtendedEntityProperties{
public ScriptEntity base;
public ScriptEntityData(ScriptEntity base){
public IEntity base;
public ScriptEntityData(IEntity base){
this.base = base;
}
@Override
public void saveNBTData(NBTTagCompound compound) {
}
@@ -22,5 +23,4 @@ public class ScriptEntityData implements IExtendedEntityProperties{
@Override
public void init(Entity entity, World world) {
}
}
@@ -18,6 +18,7 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.handler.ICloneHandler;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.IWorld;
@@ -199,7 +200,7 @@ public class ServerCloneController implements ICloneHandler {
throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]);
} else {
Entity entity = NoppesUtilServer.spawnClone(compound, (int)x, (int)y, (int)z, world.getMCWorld());
return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity);
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
}
}
@@ -210,7 +211,7 @@ public class ServerCloneController implements ICloneHandler {
} else {
Instance.cleanTags(compound);
Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld());
return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity);
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
}
}
@@ -11,6 +11,7 @@ import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import javax.annotation.CheckForNull;
@@ -119,7 +120,7 @@ public class NPCDataScript implements IScriptHandler {
}
public ICustomNpc getNpc() {
if (this.npcAPI == null) {
this.npcAPI = (ICustomNpc) ScriptController.Instance.getScriptForEntity(this.npc);
this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc);
}
return this.npcAPI;
}
@@ -18,7 +18,7 @@ import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import javax.annotation.CheckForNull;
@@ -69,7 +69,7 @@ public class PlayerDataScript implements IScriptHandler {
if (type != EnumScriptType.INIT) {
noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event;
EventHooks.onPlayerInit(this, (ScriptPlayer) playerEvent.player);
EventHooks.onPlayerInit(this, playerEvent.player);
}
}
@@ -133,7 +133,7 @@ public class PlayerDataScript implements IScriptHandler {
}
public IPlayer getPlayer() {
if (this.playerAPI == null) {
this.playerAPI = (IPlayer) ScriptController.Instance.getScriptForEntity(this.player);
this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player);
}
return this.playerAPI;
}
@@ -80,6 +80,7 @@ import noppes.npcs.roles.JobInterface;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.roles.RoleInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.event.ScriptEventAttack;
import noppes.npcs.scripted.event.ScriptEventDamaged;
@@ -165,7 +166,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
this.updateTasks();
if (!this.isRemote()) {
this.wrappedNPC = new ScriptNpc(this);
this.wrappedNPC = new ScriptNpc<>(this);
}
}
catch(Exception e){
@@ -22,7 +22,7 @@ import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.event.ItemEvent;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptCustomItem;
import noppes.npcs.scripted.wrapper.NpcAPI;
import noppes.npcs.scripted.NpcAPI;
import org.lwjgl.opengl.GL11;
public class ItemScripted extends Item implements ItemRenderInterface {
@@ -75,7 +75,7 @@ public class ItemScripted extends Item implements ItemRenderInterface {
return false;
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(entityLivingBase), 2, null);
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, NpcAPI.Instance().getIEntity(entityLivingBase), 2, null);
return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve);
}
@@ -132,7 +132,7 @@ public class ItemScripted extends Item implements ItemRenderInterface {
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(attacker), 1, ScriptController.Instance.getScriptForEntity(target));
ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, NpcAPI.Instance().getIEntity(attacker), 1, NpcAPI.Instance().getIEntity(target));
return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve);
}
@@ -157,7 +157,9 @@ public class ItemScripted extends Item implements ItemRenderInterface {
}
@Override
public void renderSpecial() {
GL11.glTranslatef(0.135F, 0.2F, 0.07F);
public void renderSpecial() {}
public void renderOffset(ScriptCustomItem scriptCustomItem) {
GL11.glTranslatef(0.135F * scriptCustomItem.scaleX, 0.2F * scriptCustomItem.scaleY, 0.07F * scriptCustomItem.scaleZ);
}
}
@@ -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;
}
}