Merge pull request #20 from c0508383/master

Flight Fix and API update
This commit is contained in:
Kamron Vaswani authored and GitHub committed 2022-01-13 20:31:09 -05:00
commit 4ba6f3086f
112 files changed
+5602 -381

No files matched your search

+7 -2
View File
@@ -2,7 +2,10 @@ 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;
@@ -10,6 +13,8 @@ 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",
@@ -43,7 +48,7 @@ public class CmdFaction extends ChMcLogger {
for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, points);
playerfactiondata.increasePoints(factionid, points, playerdata.player);
}
return true;
}
@@ -64,7 +69,7 @@ public class CmdFaction extends ChMcLogger {
int factionid = this.selectedFaction.id;
for(PlayerData playerdata : data){
PlayerFactionData playerfactiondata = playerdata.factionData;
playerfactiondata.increasePoints(factionid, -points);
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
}
return true;
}
+1 -2
View File
@@ -33,7 +33,6 @@ import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly;
import foxz.commandhelper.permissions.ParamCheck;
import foxz.commandhelper.permissions.PlayerOnly;
import foxz.utils.Utils;
@Command(
name = "noppes",
@@ -89,7 +88,7 @@ public class CmdNoppes extends ChMcLogger {
return false;
}
try{
cmdfaction.selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
}
catch(NumberFormatException e){
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
+5 -20
View File
@@ -4,32 +4,14 @@ import net.minecraft.client.model.ModelBiped;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.Item;
import net.minecraft.stats.Achievement;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.ContainerCarpentryBench;
import noppes.npcs.containers.ContainerCrate;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.containers.ContainerMerchantAdd;
import noppes.npcs.containers.ContainerNPCBankLarge;
import noppes.npcs.containers.ContainerNPCBankSmall;
import noppes.npcs.containers.ContainerNPCBankUnlock;
import noppes.npcs.containers.ContainerNPCBankUpgrade;
import noppes.npcs.containers.ContainerNPCCompanion;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.containers.ContainerNPCFollowerSetup;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.containers.ContainerNPCTraderSetup;
import noppes.npcs.containers.ContainerNpcItemGiver;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -59,6 +41,9 @@ public class CommonProxy implements IGuiHandler {
return getContainer(gui, player, x, y, z, npc);
}
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
if(gui == EnumGuiType.CustomGui)
return new ContainerCustomGui(new InventoryBasic("", false, x));
if(gui == EnumGuiType.MainMenuInv)
return new ContainerNPCInv(npc, player);
+4 -1
View File
@@ -180,7 +180,10 @@ public class CustomNpcs {
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler);
FMLCommonHandler.instance().bus().register(new ScriptForgeEventHandler().registerForgeEvents());
ScriptForgeEventHandler forgeEventHandler = (new ScriptForgeEventHandler()).registerForgeEvents();
MinecraftForge.EVENT_BUS.register(forgeEventHandler);
FMLCommonHandler.instance().bus().register(forgeEventHandler);
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
+14
View File
@@ -37,6 +37,8 @@ public class DataAI {
public int movementType = 0;
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public boolean hasFlyLimit = true;
public int flyHeightLimit = 2;
public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody;
@@ -110,6 +112,16 @@ public class DataAI {
else
flyGravity = compound.getDouble("FlyGravity");
if(!compound.hasKey("HasFlyLimit"))
hasFlyLimit = false;
else
hasFlyLimit = compound.getBoolean("HasFlyLimit");
if(!compound.hasKey("FlyHeightLimit"))
flyHeightLimit = 5;
else
flyHeightLimit = compound.getInteger("FlyHeightLimit");
startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3){
startPos = new int[] {
@@ -159,6 +171,8 @@ public class DataAI {
compound.setInteger("MovingType", movementType);
compound.setDouble("FlySpeed",flySpeed);
compound.setDouble("FlyGravity",flyGravity);
compound.setBoolean("HasFlyLimit",hasFlyLimit);
compound.setInteger("FlyHeightLimit", flyHeightLimit);
npc.setAvoidWater(avoidsWater);
+4 -3
View File
@@ -23,6 +23,7 @@ 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.ICustomNpc;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
@@ -36,7 +37,7 @@ public class DataScript implements IScriptHandler {
private EntityNPCInterface npc;
public boolean enabled = false;
public ScriptNpc dummyNpc;
public ICustomNpc dummyNpc;
public IWorld dummyWorld;
public boolean clientNeedsUpdate = false;
public boolean aiNeedsUpdate = false;
@@ -48,8 +49,8 @@ public class DataScript implements IScriptHandler {
}
this.npc = npc;
if(npc instanceof EntityCustomNpc)
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
dummyNpc = new ScriptNpc<>(npc);
if(npc.worldObj instanceof WorldServer)
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
}
+70
View File
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
@@ -18,6 +19,8 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
@@ -33,6 +36,7 @@ import noppes.npcs.scripted.event.PlayerEvent.LoginEvent;
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IEntity;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IWorld;
@@ -47,6 +51,8 @@ public class EventHooks {
public EventHooks() {
}
public static void onNPCTimer(EntityNPCInterface npc, int id) {
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
@@ -311,4 +317,68 @@ public class EventHooks {
}
}
public static void onCustomGuiButton(ScriptPlayer 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) {
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId));
CustomGuiController.onSlotChange(event);
}
public static void onCustomGuiScrollClick(ScriptPlayer 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) {
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);
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
WrapperNpcAPI.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);
handler.callScript(EnumScriptType.QUEST_START, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.QUEST_TURNIN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onFactionPoints(FactionEvent.FactionPoints event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.FACTION_POINTS, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogOpen(DialogEvent.DialogOpen event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPEN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogOption(DialogEvent.DialogOption event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPTION, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onDialogClosed(DialogEvent.DialogClosed event){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_CLOSE, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
}
@@ -34,6 +34,10 @@ public class ModelDataShared{
public byte armwear = 0;
public byte legwear = 0;
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
public byte solidArmwear = 0;
public byte solidLegwear = 0;
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
public byte hideHead = 0;
public byte hideBody = 0;
@@ -58,6 +62,9 @@ public class ModelDataShared{
compound.setByte("Armwear", armwear);
compound.setByte("Legwear", legwear);
compound.setByte("SolidArmwear", solidArmwear);
compound.setByte("SolidLegwear", solidLegwear);
compound.setByte("hideHead", hideHead);
compound.setByte("hideBody", hideBody);
compound.setByte("hideArms", hideArms);
@@ -92,6 +99,9 @@ public class ModelDataShared{
armwear = compound.getByte("Armwear");
legwear = compound.getByte("Legwear");
solidArmwear = compound.getByte("SolidArmwear");
solidLegwear = compound.getByte("SolidLegwear");
hideHead = compound.getByte("hideHead");
hideBody = compound.getByte("hideBody");
hideArms = compound.getByte("hideArms");
+79 -23
View File
@@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -43,6 +44,11 @@ import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.QuestEvent;
import noppes.npcs.scripted.interfaces.IItemStack;
public class NoppesUtilPlayer {
@@ -259,13 +265,19 @@ public class NoppesUtilPlayer {
Dialog dialog = DialogController.instance.dialogs.get(dialogId);
if(dialog == null)
return;
npc.script.callScript(EnumScriptType.DIALOG_OPTION, "player", player, "dialog", dialogId, "option", optionId + 1);
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions())
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) 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)
return;
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));
return;
}
if(option.optionType == EnumOptionType.RoleOption){
if(npc.roleInterface != null)
npc.roleInterface.interact(player);
@@ -293,41 +305,58 @@ public class NoppesUtilPlayer {
public static void questCompletion(EntityPlayerMP player, int questId) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
QuestData data = playerdata.activeQuests.get(questId);
if(data == null)
return;
if(!data.quest.questInterface.isCompleted(player))
return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
event.expReward = data.quest.rewardExp;
List<IItemStack> list = new ArrayList();
Iterator var8 = data.quest.rewardItems.items.values().iterator();
while(var8.hasNext()) {
ItemStack item = (ItemStack)var8.next();
if (item.stackSize > 0) {
list.add(NpcAPI.Instance().getIItemStack(item));
}
}
if (!data.quest.randomReward) {
event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]);
} else if (!list.isEmpty()) {
event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))};
}
EventHooks.onQuestTurnedIn(event);
IItemStack[] var12 = event.itemRewards;
int var14 = var12.length;
for(int var10 = 0; var10 < var14; ++var10) {
IItemStack item = var12[var10];
if (item != null) {
NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack());
}
}
data.quest.questInterface.handleComplete(player);
if(data.quest.rewardExp > 0){
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
player.addExperience(data.quest.rewardExp);
player.addExperience(data.quest.rewardExp);
}
data.quest.factionOptions.addPoints(player);
if(data.quest.mail.isValid()){
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
}
if(!data.quest.randomReward){
for(ItemStack item : data.quest.rewardItems.items.values()){
NoppesUtilServer.GivePlayerItem(player, player, item);
}
}
else{
List<ItemStack> list = new ArrayList<ItemStack>();
for(ItemStack item : data.quest.rewardItems.items.values()){
if(item != null && item.getItem() != null)
list.add(item);
}
if(!list.isEmpty()){
NoppesUtilServer.GivePlayerItem(player, player, list.get(player.getRNG().nextInt(list.size())));
}
}
if(!data.quest.command.isEmpty()){
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
}
PlayerQuestController.setQuestFinished(data.quest, player);
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player);
}
@@ -400,4 +429,31 @@ public class NoppesUtilPlayer {
public static void isGUIOpen(EntityPlayerMP player){
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
}
public static List<ItemStack> countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) {
List<ItemStack> list = new ArrayList();
for(int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack item = inv.getStackInSlot(i);
if (!NoppesUtilServer.IsItemStackNull(item)) {
boolean found = false;
Iterator var7 = list.iterator();
while(var7.hasNext()) {
ItemStack is = (ItemStack)var7.next();
if (compareItems(item, is, ignoreDamage, ignoreNBT)) {
is.stackSize = is.stackSize + item.stackSize;
found = true;
break;
}
}
if (!found) {
list.add(item.copy());
}
}
}
return list;
}
}
@@ -72,6 +72,8 @@ 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.event.DialogEvent;
import noppes.npcs.scripted.event.ScriptEventDialog;
public class NoppesUtilServer {
@@ -180,6 +182,9 @@ public class NoppesUtilServer {
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
Dialog dialog = dia.copy(player);
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
if(npc instanceof EntityDialogNpc){
dialog.hideNPC = true;
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
@@ -711,4 +716,8 @@ public class NoppesUtilServer {
boolean isGUIOpen = buffer.readBoolean();
playerdata.setGUIOpen(isGUIOpen);
}
public static boolean IsItemStackNull(ItemStack is) {
return is == null || is.stackSize == 0 || is.getItem() == null;
}
}
@@ -36,31 +36,10 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.Bank;
import noppes.npcs.controllers.BankController;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogCategory;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.LinkedNpcController;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityCustomNpc;
@@ -71,6 +50,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.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.gui.ScriptGui;
public class PacketHandlerServer{
@@ -93,6 +75,24 @@ public class PacketHandlerServer{
if(type == EnumPacketServer.IsGuiOpen) {
isGuiOpenPacket(buffer, player);
return;
} else if (type == EnumPacketServer.CustomGuiButton) {
if (player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiButton((ScriptPlayer)NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
return;
}
} else if (type == EnumPacketServer.CustomGuiSlotChange) {
if (player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((ScriptPlayer) 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) 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)NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
}
if(type.needsNpc && npc == null){
@@ -103,24 +103,28 @@ public class PacketHandlerServer{
}
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
else if(item.getItem() == CustomItems.wand)
wandPackets(type, buffer, player, npc);
else if(item.getItem() == CustomItems.moving)
movingPackets(type, buffer, player, npc);
else if(item.getItem() == CustomItems.mount)
mountPackets(type, buffer, player);
else if(item.getItem() == CustomItems.cloner)
clonePackets(type, buffer, player);
else if(item.getItem() == CustomItems.teleporter)
featherPackets(type, buffer, player);
else if(type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player);
else if(type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player);
else if(item.getItem() == CustomItems.scripter)
scriptPackets(type, buffer, player, npc);
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
blockPackets(type, buffer, player);
else {
if (item != null) {
if (item.getItem() == CustomItems.wand)
wandPackets(type, buffer, player, npc);
else if (item.getItem() == CustomItems.moving)
movingPackets(type, buffer, player, npc);
else if (item.getItem() == CustomItems.mount)
mountPackets(type, buffer, player);
else if (item.getItem() == CustomItems.cloner)
clonePackets(type, buffer, player);
else if (item.getItem() == CustomItems.teleporter)
featherPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
playerScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player);
else if (item.getItem() == CustomItems.scripter)
scriptPackets(type, buffer, player, npc);
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
blockPackets(type, buffer, player);
}
}
} catch (Exception e) {
LogWriter.error("Error with EnumPacketServer." + type, e);
}
@@ -264,7 +268,7 @@ public class PacketHandlerServer{
}
else if(type == EnumPacketServer.FactionGet){
NBTTagCompound compound = new NBTTagCompound();
Faction faction = FactionController.getInstance().getFaction(buffer.readInt());
Faction faction = FactionController.getInstance().get(buffer.readInt());
faction.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
@@ -380,7 +384,7 @@ public class PacketHandlerServer{
NoppesUtilServer.setRecipeGui(player,recipe);
}
else if(type == EnumPacketServer.RecipeRemove){
RecipeCarpentry recipe = RecipeController.instance.removeRecipe(buffer.readInt());
RecipeCarpentry recipe = RecipeController.instance.delete(buffer.readInt());
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
}
@@ -555,14 +559,14 @@ public class PacketHandlerServer{
else if(type == EnumPacketServer.FactionSave){
Faction faction = new Faction();
faction.readNBT(Server.readNBT(buffer));
FactionController.getInstance().saveFaction(faction);
FactionController.getInstance().create(faction);
NoppesUtilServer.sendFactionDataAll(player);
NBTTagCompound compound = new NBTTagCompound();
faction.writeNBT(compound);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if(type == EnumPacketServer.FactionRemove){
FactionController.getInstance().removeFaction(buffer.readInt());
FactionController.getInstance().delete(buffer.readInt());
NoppesUtilServer.sendFactionDataAll(player);
NBTTagCompound compound = new NBTTagCompound();
(new Faction()).writeNBT(compound);
@@ -21,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -35,26 +36,20 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur;
import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.quests.QuestKill;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.scripted.event.ForgeEvent;
public class ServerEventsHandler {
public static EntityVillager Merchant;
public static Entity mounted;
// private HashMap<String, Integer> exps = new HashMap<String, Integer>();
//
// @SubscribeEvent
@@ -64,10 +59,10 @@ public class ServerEventsHandler {
// EntityPlayer player = (EntityPlayer) event.entityLiving;
// if(exps.containsKey(player.getCommandSenderName())){
// int prevExp = exps.get(player.getCommandSenderName());
// if(prevExp > player.experienceTotal){
// if(prevExp > player.experienceTotal){
// player.addChatMessage(new ChatComponentText("Omg exp was gotten:" + (player.experienceTotal - prevExp)));
// }
// else if(prevExp < player.experienceTotal){
// else if(prevExp < player.experienceTotal){
// player.addChatMessage(new ChatComponentText("Omg exp was lost:" + (prevExp - player.experienceTotal)));
// }
// }
@@ -85,11 +80,11 @@ public class ServerEventsHandler {
if(!isRemote && CustomNpcs.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){
return;
}
if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty && event.target instanceof EntityLivingBase) {
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
}
if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){
if (!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){
return;
@@ -111,43 +106,43 @@ public class ServerEventsHandler {
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
return;
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
event.setCanceled(true);
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
}
else if(item.getItem() == CustomItems.mount){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
return;
event.setCanceled(true);
mounted = event.target;
if(isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
mounted = event.target;
if(isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
}
else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
return;
event.setCanceled(true);
Merchant = (EntityVillager)event.target;
if(!isRemote){
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
if (merchantrecipelist != null)
{
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
}
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
if (merchantrecipelist != null)
{
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
}
}
}
}
@SubscribeEvent
public void invoke(LivingHurtEvent event) {
if(!(event.entityLiving instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if(event.source.isUnblockable() || event.source.isFireDamage())
return;
@@ -159,7 +154,7 @@ public class ServerEventsHandler {
if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9))
return;
float damage = item.getItemDamage() + event.ammount;
item.damageItem((int) event.ammount, player);
if(damage > item.getMaxDamage())
@@ -169,7 +164,7 @@ public class ServerEventsHandler {
event.setCanceled(true);
}
}
@SubscribeEvent
public void invoke(PlayerInteractEvent event) {
EntityPlayer player = event.entityPlayer;
@@ -177,50 +172,50 @@ public class ServerEventsHandler {
if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){
event.setCanceled(true);
}
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
RecipeController controller = RecipeController.instance;
NBTTagList list = new NBTTagList();
int i = 0;
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
list.appendTag(recipe.writeNBT());
i++;
if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList();
}
}
NBTTagList list = new NBTTagList();
int i = 0;
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
list.appendTag(recipe.writeNBT());
i++;
if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList();
}
}
if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
}
if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
}
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
RecipeController controller = RecipeController.instance;
NBTTagList list = new NBTTagList();
int i = 0;
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
list.appendTag(recipe.writeNBT());
i++;
if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList();
}
}
NBTTagList list = new NBTTagList();
int i = 0;
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
list.appendTag(recipe.writeNBT());
i++;
if(i % 10 == 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
list = new NBTTagList();
}
}
if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
if(i % 10 != 0){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("recipes", list);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
}
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
}
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
ItemStack item = player.inventory.getCurrentItem();
@@ -232,20 +227,20 @@ public class ServerEventsHandler {
y--;
TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z);
if(!tile.canEdit()){
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
tile.time = System.currentTimeMillis();
if(player.worldObj.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
tile.time = System.currentTimeMillis();
if(player.worldObj.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
return;
}
if(!player.worldObj.isRemote){
if(!player.worldObj.isRemote){
tile.icon = item.copy();
player.worldObj.markBlockForUpdate(event.x, y, event.z);
event.setCanceled(true);
}
player.worldObj.markBlockForUpdate(event.x, y, event.z);
event.setCanceled(true);
}
}
}
@@ -257,7 +252,7 @@ public class ServerEventsHandler {
if(event.source.getEntity() instanceof EntityPlayer){
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
}
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine();
@@ -266,7 +261,7 @@ public class ServerEventsHandler {
npc.script.callScript(EnumScriptType.KILLS, "target", event.entityLiving);
}
EntityPlayer player = null;
if(event.source.getEntity() instanceof EntityPlayer)
player = (EntityPlayer) event.source.getEntity();
@@ -274,7 +269,7 @@ public class ServerEventsHandler {
player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner;
if(player != null){
doQuest(player, event.entityLiving, true);
if(event.entityLiving instanceof EntityNPCInterface)
doFactionPoints(player, (EntityNPCInterface)event.entityLiving);
}
@@ -300,8 +295,8 @@ public class ServerEventsHandler {
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
boolean change = false;
String entityName = EntityList.getEntityString(entity);
String entityName = EntityList.getEntityString(entity);
for(QuestData data : playerdata.activeQuests.values()){
if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue;
@@ -310,7 +305,7 @@ public class ServerEventsHandler {
for(EntityPlayer pl : list)
if(pl != player)
doQuest(pl, entity, false);
}
String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface;
@@ -330,7 +325,7 @@ public class ServerEventsHandler {
}
if(!change)
return;
playerdata.checkQuestCompletion(player,EnumQuestType.Kill);
}
@@ -2,6 +2,7 @@ package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityMoveHelper;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface;
@@ -50,7 +51,18 @@ public class FlyingMoveHelper extends EntityMoveHelper{
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
verticalSpeed = Math.abs(this.entity.posY - this.posY);
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
int blockY = (int) this.posY;
double heightOffGround = 0;
if(this.entity.ai.hasFlyLimit) {
for (blockY = (int) this.posY; blockY > 0; blockY--) {
heightOffGround = this.posY - blockY;
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
break;
}
}
}
if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit)
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
}
double d5 = MathHelper.sqrt_double(d4);
@@ -297,23 +297,6 @@ public class PathNavigateFlying extends PathNavigate {
*/
private int getPathableYPos()
{
int i = (int)this.theEntity.boundingBox.minY;
Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
int j = 0;
do
{
if (block != Blocks.air)
{
return i;
}
++i;
block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
++j;
}
while (j <= 16);
return (int)(this.theEntity.boundingBox.minY + 0.5D);
}
@@ -65,6 +65,7 @@ import noppes.npcs.client.fx.EntityElementalStaffFX;
import noppes.npcs.client.fx.EntityEnderFX;
import noppes.npcs.client.fx.EntityRainbowFX;
import noppes.npcs.client.gui.*;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
@@ -128,22 +129,7 @@ import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.ContainerCarpentryBench;
import noppes.npcs.containers.ContainerCrate;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCCompanion;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.containers.ContainerNPCFollowerSetup;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.containers.ContainerNPCTraderSetup;
import noppes.npcs.containers.ContainerNpcItemGiver;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.entity.*;
@@ -437,6 +423,10 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.CompanionInv)
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
else if (gui == EnumGuiType.CustomGui)
return new GuiCustom((ContainerCustomGui)container);
return null;
}
@@ -42,6 +42,16 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
addTextField(new GuiNpcTextField(19,this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + ""));
getTextField(19).doublesOnly = true;
getTextField(19).setMinMaxDefaultDouble(0.0D,1.0D,0.0D);
this.addLabel(new GuiNpcLabel(20, "Limit Height", guiLeft + 150, y + 116));
addButton(new GuiNpcButton(20, guiLeft + 210, y + 110, 40, 20, new String[]{"gui.no","gui.yes"}, ai.hasFlyLimit?1:0));
if(ai.hasFlyLimit) {
this.addLabel(new GuiNpcLabel(21, "Height", guiLeft + 150, y + 140));
addTextField(new GuiNpcTextField(21, this, guiLeft + 185, y + 135, 40, 20, ai.flyHeightLimit + ""));
getTextField(21).integersOnly = true;
getTextField(21).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D);
}
}
if(ai.movingType == EnumMovingType.Wandering){
@@ -159,10 +169,12 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
else if (button.id == 15) {
ai.movementType = button.getValue();
initGui();
} else if (button.id == 20) {
ai.hasFlyLimit = button.getValue() == 1;
initGui();
} else if (button.id == 66) {
close();
}
else if(button.id == 66){
close();
}
}
@Override
@@ -191,6 +203,9 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
else if(textfield.id == 19){
ai.flyGravity = textfield.getDouble();
}
else if(textfield.id == 21){
ai.flyHeightLimit = textfield.getInteger();
}
}
}
@@ -0,0 +1,885 @@
package noppes.npcs.client.gui.custom;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.custom.components.*;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.gui.*;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.*;
public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiData {
ScriptGui gui;
int xSize;
int ySize;
public static int guiLeft;
public static int guiTop;
ResourceLocation background;
public String[] hoverText;
Map<Integer, IGuiComponent> components = new HashMap();
List<IClickListener> clickListeners = new ArrayList();
List<CustomGuiTextField> keyListeners = new ArrayList();
List<IDataHolder> dataHolders = new ArrayList();
public Container inventorySlots;
private Slot theSlot;
private Slot clickedSlot;
private boolean isRightMouseClick;
private ItemStack draggedStack;
private int field_147011_y;
private int field_147010_z;
private Slot returningStackDestSlot;
private long returningStackTime;
private ItemStack returningStack;
private Slot field_146985_D;
private long field_146986_E;
protected final Set field_147008_s = new HashSet();
protected boolean field_147007_t;
private int field_146987_F;
private int field_146988_G;
private boolean field_146995_H;
private int field_146996_I;
private long field_146997_J;
private Slot field_146998_K;
private int field_146992_L;
private boolean field_146993_M;
private ItemStack field_146994_N;
public GuiCustom(ContainerCustomGui container) {
this.inventorySlots = container;
this.field_146995_H = true;
this.allowUserInput = true;
}
public void initGui() {
super.initGui();
this.mc.thePlayer.openContainer = this.inventorySlots;
if (this.gui != null) {
guiLeft = (this.width - this.xSize)/2;
guiTop = (this.height - this.ySize)/2;
this.components.clear();
this.clickListeners.clear();
this.keyListeners.clear();
this.dataHolders.clear();
Iterator var1 = this.gui.getComponents().iterator();
while(var1.hasNext()) {
ICustomGuiComponent c = (ICustomGuiComponent)var1.next();
this.addComponent(c);
}
}
}
public void updateScreen() {
super.updateScreen();
Iterator var1 = this.dataHolders.iterator();
while(var1.hasNext()) {
IDataHolder component = (IDataHolder)var1.next();
if (component instanceof GuiTextField) {
((GuiTextField)component).updateCursorCounter();
}
}
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
{
this.mc.thePlayer.closeScreen();
}
}
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.hoverText = null;
//this.drawDefaultBackground();
if (this.background != null) {
this.drawBackgroundTexture();
}
Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) {
IGuiComponent component = (IGuiComponent)var4.next();
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
}
if (this.hoverText != null) {
this.func_146283_a(Arrays.asList(this.hoverText), mouseX, mouseY);
}
drawScreenSuper(mouseX, mouseY, partialTicks);
}
public void drawScreenSuper(int mouseX, int mouseY, float partialTicks)
{
//this.drawDefaultBackground();
int k = this.guiLeft;
int l = this.guiTop;
//this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
super.drawScreen(mouseX, mouseY, partialTicks);
RenderHelper.enableGUIStandardItemLighting();
GL11.glPushMatrix();
GL11.glTranslatef((float)k, (float)l, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
this.theSlot = null;
short short1 = 240;
short short2 = 240;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int k1;
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1)
{
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
this.drawSlot(slot);
if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b())
{
this.theSlot = slot;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
int j1 = slot.xDisplayPosition;
k1 = slot.yDisplayPosition;
GL11.glColorMask(true, true, true, false);
this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
GL11.glColorMask(true, true, true, true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
//Forge: Force lighting to be disabled as there are some issue where lighting would
//incorrectly be applied based on items that are in the inventory.
GL11.glDisable(GL11.GL_LIGHTING);
//this.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
if (itemstack != null)
{
byte b0 = 8;
k1 = this.draggedStack == null ? 8 : 16;
String s = null;
if (this.draggedStack != null && this.isRightMouseClick)
{
itemstack = itemstack.copy();
itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F);
}
else if (this.field_147007_t && this.field_147008_s.size() > 1)
{
itemstack = itemstack.copy();
itemstack.stackSize = this.field_146996_I;
if (itemstack.stackSize == 0)
{
s = "" + EnumChatFormatting.YELLOW + "0";
}
}
this.drawItemStack(itemstack, mouseX - k - b0, mouseY - l - k1, s);
}
if (this.returningStack != null)
{
float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
if (f1 >= 1.0F)
{
f1 = 1.0F;
this.returningStack = null;
}
k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y;
int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z;
int l1 = this.field_147011_y + (int)((float)k1 * f1);
int i2 = this.field_147010_z + (int)((float)j2 * f1);
this.drawItemStack(this.returningStack, l1, i2, (String)null);
}
GL11.glPopMatrix();
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
{
ItemStack itemstack1 = this.theSlot.getStack();
this.renderToolTip(itemstack1, mouseX, mouseY);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_)
{
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
itemRender.zLevel = 200.0F;
FontRenderer font = null;
if (p_146982_1_ != null) font = p_146982_1_.getItem().getFontRenderer(p_146982_1_);
if (font == null) font = fontRendererObj;
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_ - (this.draggedStack == null ? 0 : 8), p_146982_4_);
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
private boolean isMouseOverSlot(Slot slot, int posX, int posY)
{
return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, posX, posY);
}
protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY)
{
int k1 = this.guiLeft;
int l1 = this.guiTop;
posX -= k1;
posY -= l1;
return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1;
}
private void drawSlot(Slot p_146977_1_)
{
int i = p_146977_1_.xDisplayPosition;
int j = p_146977_1_.yDisplayPosition;
ItemStack itemstack = p_146977_1_.getStack();
boolean flag = false;
boolean flag1 = p_146977_1_ == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
String s = null;
if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
{
itemstack = itemstack.copy();
itemstack.stackSize /= 2;
}
else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null)
{
if (this.field_147008_s.size() == 1)
{
return;
}
if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_))
{
itemstack = itemstack1.copy();
flag = true;
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize);
if (itemstack.stackSize > itemstack.getMaxStackSize())
{
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
itemstack.stackSize = itemstack.getMaxStackSize();
}
if (itemstack.stackSize > p_146977_1_.getSlotStackLimit())
{
s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit();
itemstack.stackSize = p_146977_1_.getSlotStackLimit();
}
}
else
{
this.field_147008_s.remove(p_146977_1_);
this.func_146980_g();
}
}
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
if (itemstack == null)
{
IIcon iicon = p_146977_1_.getBackgroundIconIndex();
if (iicon != null)
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
this.drawTexturedModelRectFromIcon(i, j, iicon, 16, 16);
GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up
GL11.glEnable(GL11.GL_LIGHTING);
flag1 = true;
}
}
if (!flag1)
{
if (flag)
{
drawRect(i, j, i + 16, j + 16, -2130706433);
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j);
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s);
}
itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
}
private void func_146980_g()
{
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (itemstack != null && this.field_147007_t)
{
this.field_146996_I = itemstack.stackSize;
ItemStack itemstack1;
int i;
for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i)
{
Slot slot = (Slot)iterator.next();
itemstack1 = itemstack.copy();
i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i);
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
{
itemstack1.stackSize = itemstack1.getMaxStackSize();
}
if (itemstack1.stackSize > slot.getSlotStackLimit())
{
itemstack1.stackSize = slot.getSlotStackLimit();
}
}
}
}
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
}
void drawBackgroundTexture() {
this.mc.getTextureManager().bindTexture(this.background);
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
}
private void addComponent(ICustomGuiComponent component) {
ScriptGuiComponent c = (ScriptGuiComponent)component;
switch(c.getType()) {
case 0:
CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton)component);
button.setParent(this);
this.components.put(button.getID(), button);
this.addClickListener(button);
break;
case 1:
CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel)component);
lbl.setParent(this);
this.components.put(lbl.getID(), lbl);
break;
case 2:
CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect)component);
rect.setParent(this);
this.components.put(rect.getID(), rect);
break;
case 3:
CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField)component);
textField.setParent(this);
this.components.put(textField.getID(), textField);
this.addDataHolder(textField);
this.addClickListener(textField);
this.addKeyListener(textField);
break;
case 4:
CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll)component).isMultiSelect());
scroll.fromComponent((ScriptGuiScroll)component);
scroll.setParent(this);
this.components.put(scroll.getID(), scroll);
this.addDataHolder(scroll);
this.addClickListener(scroll);
}
}
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
}
public void buttonClick(CustomGuiButton button) {
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
}
public void slotChange(CustomGuiSlot slot) {
Client.sendData(EnumPacketServer.CustomGuiSlotChange, new Object[]{this.updateGui().toNBT(), slot.slotNumber});
}
public String prevScrollClicked = null;
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false});
if(Integer.toString(scroll.selected).equals(prevScrollClicked)){
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true});
}
prevScrollClicked = Integer.toString(scroll.selected);
}
public void onGuiClosed() {
if (this.gui != null) {
Client.sendData(EnumPacketServer.CustomGuiClose, new Object[]{this.updateGui().toNBT()});
}
if (this.mc.thePlayer != null)
{
this.inventorySlots.onContainerClosed(this.mc.thePlayer);
}
}
ScriptGui updateGui() {
Iterator var1 = this.dataHolders.iterator();
while(var1.hasNext()) {
IDataHolder component = (IDataHolder)var1.next();
this.gui.updateComponent(component.toComponent());
}
return this.gui;
}
NBTTagCompound getScrollSelection(CustomGuiScrollComponent scroll) {
NBTTagList list = new NBTTagList();
if (scroll.multiSelect) {
Iterator var3 = scroll.getSelectedList().iterator();
while(var3.hasNext()) {
String s = (String)var3.next();
list.appendTag(new NBTTagString(s));
}
} else {
list.appendTag(new NBTTagString(scroll.getSelected()));
}
NBTTagCompound selection = new NBTTagCompound();
selection.setTag("selection", list);
return selection;
}
protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
{
this.mc.thePlayer.closeScreen();
}
this.checkHotbarKeys(keyCode);
if (this.theSlot != null && this.theSlot.getHasStack())
{
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3);
}
else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4);
}
}
Iterator var3 = this.keyListeners.iterator();
while(var3.hasNext()) {
CustomGuiTextField listener = (CustomGuiTextField) var3.next();
listener.keyTyped(typedChar, keyCode);
}
if (this.mc.gameSettings.keyBindInventory.getKeyCode() != keyCode && !this.mc.gameSettings.keyBindInventory.getIsKeyPressed()) {
super.keyTyped(typedChar, keyCode);
}
}
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100;
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
long l = Minecraft.getSystemTime();
this.field_146993_M = this.field_146998_K == slot && l - this.field_146997_J < 250L && this.field_146992_L == mouseButton;
this.field_146995_H = false;
if (mouseButton == 0 || mouseButton == 1 || flag) {
int i1 = guiLeft + ((ContainerCustomGui)this.inventorySlots).playerInvX;
int j1 = guiTop + ((ContainerCustomGui)this.inventorySlots).playerInvY;
boolean flag1 = mouseX < i1 || mouseY < j1 || mouseX >= i1 + this.xSize || mouseY >= j1 + this.ySize;
int k1 = -1;
if (slot != null) {
k1 = slot.slotNumber;
}
if (flag1) {
k1 = -999;
}
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) {
this.mc.displayGuiScreen((GuiScreen) null);
return;
}
if (k1 != -1) {
if (this.mc.gameSettings.touchscreen) {
if (slot != null && slot.getHasStack()) {
this.clickedSlot = slot;
this.draggedStack = null;
this.isRightMouseClick = mouseButton == 1;
} else {
this.clickedSlot = null;
}
} else if (!this.field_147007_t) {
if (this.mc.thePlayer.inventory.getItemStack() == null) {
if (mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) {
this.handleMouseClick(slot, k1, mouseButton, 3);
} else {
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
byte b0 = 0;
if (flag2) {
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
b0 = 1;
} else if (k1 == -999) {
b0 = 4;
}
this.handleMouseClick(slot, k1, mouseButton, b0);
}
this.field_146995_H = true;
} else {
this.field_147007_t = true;
this.field_146988_G = mouseButton;
this.field_147008_s.clear();
if (mouseButton == 0) {
this.field_146987_F = 0;
} else if (mouseButton == 1) {
this.field_146987_F = 1;
}
}
}
}
}
this.field_146998_K = slot;
this.field_146997_J = l;
this.field_146992_L = mouseButton;
Iterator var4 = this.clickListeners.iterator();
while(var4.hasNext()) {
IClickListener listener = (IClickListener)var4.next();
listener.mouseClicked(this, mouseX, mouseY, mouseButton);
}
}
public boolean doesGuiPauseGame() {
return this.gui == null || this.gui.getDoesPauseGame();
}
public void addDataHolder(IDataHolder component) {
this.dataHolders.add(component);
}
public void addKeyListener(CustomGuiTextField component) {
this.keyListeners.add(component);
}
public void addClickListener(IClickListener component) {
this.clickListeners.add(component);
}
public void setGuiData(NBTTagCompound compound) {
Minecraft mc = Minecraft.getMinecraft();
ScriptGui gui = (ScriptGui)(new ScriptGui()).fromNBT(compound);
((ContainerCustomGui)this.inventorySlots).setGui(gui, mc.thePlayer);
this.gui = gui;
this.xSize = gui.getWidth();
this.ySize = gui.getHeight();
if (!gui.getBackgroundTexture().isEmpty()) {
this.background = new ResourceLocation(gui.getBackgroundTexture());
}
this.initGui();
}
/**
* This function is what controls the hotbar shortcut check when you press a number key when hovering a stack.
*/
protected boolean checkHotbarKeys(int p_146983_1_)
{
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
{
for (int j = 0; j < 9; ++j)
{
if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2);
return true;
}
}
}
return false;
}
protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_)
{
if (slot != null)
{
index = slot.slotNumber;
}
this.mc.playerController.windowClick(this.inventorySlots.windowId, index, p_146984_3_, p_146984_4_, this.mc.thePlayer);
}
protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_)
{
super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons
Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_);
int l = this.guiLeft;
int i1 = this.guiTop;
boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize;
int j1 = -1;
if (slot != null)
{
j1 = slot.slotNumber;
}
if (flag)
{
j1 = -999;
}
Slot slot1;
Iterator iterator;
if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot))
{
if (isShiftKeyDown())
{
if (slot != null && slot.inventory != null && this.field_146994_N != null)
{
iterator = this.inventorySlots.inventorySlots.iterator();
while (iterator.hasNext())
{
slot1 = (Slot)iterator.next();
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true))
{
this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1);
}
}
}
}
else
{
this.handleMouseClick(slot, j1, p_146286_3_, 6);
}
this.field_146993_M = false;
this.field_146997_J = 0L;
}
else
{
if (this.field_147007_t && this.field_146988_G != p_146286_3_)
{
this.field_147007_t = false;
this.field_147008_s.clear();
this.field_146995_H = true;
return;
}
if (this.field_146995_H)
{
this.field_146995_H = false;
return;
}
boolean flag1;
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (p_146286_3_ == 0 || p_146286_3_ == 1)
{
if (this.draggedStack == null && slot != this.clickedSlot)
{
this.draggedStack = this.clickedSlot.getStack();
}
flag1 = Container.func_94527_a(slot, this.draggedStack, false);
if (j1 != -1 && this.draggedStack != null && flag1)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
this.handleMouseClick(slot, j1, 0, 0);
if (this.mc.thePlayer.inventory.getItemStack() != null)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
this.field_147011_y = p_146286_1_ - l;
this.field_147010_z = p_146286_2_ - i1;
this.returningStackDestSlot = this.clickedSlot;
this.returningStack = this.draggedStack;
this.returningStackTime = Minecraft.getSystemTime();
}
else
{
this.returningStack = null;
}
}
else if (this.draggedStack != null)
{
this.field_147011_y = p_146286_1_ - l;
this.field_147010_z = p_146286_2_ - i1;
this.returningStackDestSlot = this.clickedSlot;
this.returningStack = this.draggedStack;
this.returningStackTime = Minecraft.getSystemTime();
}
this.draggedStack = null;
this.clickedSlot = null;
}
}
else if (this.field_147007_t && !this.field_147008_s.isEmpty())
{
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5);
iterator = this.field_147008_s.iterator();
while (iterator.hasNext())
{
slot1 = (Slot)iterator.next();
this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5);
}
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5);
}
else if (this.mc.thePlayer.inventory.getItemStack() != null)
{
if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
{
this.handleMouseClick(slot, j1, p_146286_3_, 3);
}
else
{
flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
if (flag1)
{
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
}
this.handleMouseClick(slot, j1, p_146286_3_, flag1 ? 1 : 0);
}
}
}
if (this.mc.thePlayer.inventory.getItemStack() == null)
{
this.field_146997_J = 0L;
}
this.field_147007_t = false;
}
private Slot getSlotAtPosition(int posX, int posY)
{
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k)
{
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k);
if (this.isMouseOverSlot(slot, posX, posY))
{
return slot;
}
}
return null;
}
protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_)
{
Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_);
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (p_146273_3_ == 0 || p_146273_3_ == 1)
{
if (this.draggedStack == null)
{
if (slot != this.clickedSlot)
{
this.draggedStack = this.clickedSlot.getStack().copy();
}
}
else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false))
{
long i1 = Minecraft.getSystemTime();
if (this.field_146985_D == slot)
{
if (i1 - this.field_146986_E > 500L)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.field_146986_E = i1 + 750L;
--this.draggedStack.stackSize;
}
}
else
{
this.field_146985_D = slot;
this.field_146986_E = i1;
}
}
}
}
else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
this.field_147008_s.add(slot);
this.func_146980_g();
}
}
}
@@ -0,0 +1,155 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.scripted.gui.ScriptGuiButton;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiButton extends GuiButton implements IClickListener {
GuiCustom parent;
ResourceLocation texture;
public int textureX;
public int textureY;
boolean field_146123_n;
String label;
int colour;
String[] hoverText;
public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText);
this.colour = 16777215;
}
public CustomGuiButton(int id, String buttonText, int x, int y, int width, int height) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height, buttonText);
this.colour = 16777215;
}
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture) {
this(buttonId, buttonText, x, y, width, height, texture, 0, 0);
}
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
this(buttonId, buttonText, x, y, width, height);
this.textureX = textureX;
this.textureY = textureY;
this.label = buttonText;
this.texture = new ResourceLocation(texture);
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public static CustomGuiButton fromComponent(ScriptGuiButton component) {
CustomGuiButton btn;
if (component.hasTexture()) {
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture(), component.getTextureX(), component.getTextureY());
} else {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture());
}
} else if (component.getWidth() >= 0 && component.getHeight() >= 0) {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
} else {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY());
}
if (component.hasHoverText()) {
btn.hoverText = component.getHoverText();
}
return btn;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
//GL11.func_179094_E();
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
FontRenderer fontRenderer = mc.fontRenderer;
int i;
if (this.texture == null) {
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (this.packedFGColour != 0) {
j = this.packedFGColour;
} else if (!this.enabled) {
j = 10526880;
} else if (this.field_146123_n) {
j = 16777120;
}
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j);
} else {
mc.getTextureManager().bindTexture(this.texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.hoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.colour);
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
GL11.glPopMatrix();
}
public ICustomGuiComponent toComponent() {
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture.toString(), this.textureX, this.textureY);
component.setHoverText(this.hoverText);
return component;
}
public void setColour(int colour) {
this.colour = colour;
}
protected int hoverState(boolean mouseOver) {
int i = 0;
if (mouseOver) {
i = 1;
}
return i;
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
if (mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
//Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(SoundEvents.field_187909_gi, 1.0F));
gui.buttonClick(this);
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,100 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.renderer.OpenGlHelper;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiLabel;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiLabel extends GuiLabel implements IGuiComponent {
int x, y, width, height;
GuiCustom parent;
String fullLabel;
int color;
String[] hoverText;
float scale;
int id;
int border = 2;
boolean labelBgEnabled = true;
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f;
this.drawLabel();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public int getID() {
return this.id;
}
public void setScale(float scale) {
this.scale = scale;
}
public static CustomGuiLabel fromComponent(ScriptGuiLabel component) {
CustomGuiLabel lbl = new CustomGuiLabel();
lbl.scale = 1.0F;
lbl.fullLabel = component.getText();
lbl.color = component.getColor();
lbl.field_146172_j = true;
lbl.id = component.getID();
lbl.x = GuiCustom.guiLeft + component.getPosX();
lbl.y = GuiCustom.guiTop + component.getPosY();
lbl.width = component.getWidth();
lbl.height = component.getHeight();
lbl.setScale(component.getScale());
if (component.hasHoverText()) {
lbl.hoverText = component.getHoverText();
}
return lbl;
}
public ICustomGuiComponent toComponent() {
ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color);
component.setHoverText(this.hoverText);
return component;
}
public void drawLabel()
{
if (this.field_146172_j)
{
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawLabelBackground();
this.drawString(Minecraft.getMinecraft().fontRenderer, fullLabel, this.x, this.y, this.color);
}
}
protected void drawLabelBackground()
{
if (this.labelBgEnabled)
{
int k = this.width + this.border * 2;
int l = this.height + this.border * 2;
int i1 = this.x - this.border;
int j1 = this.y - this.border;
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor
}
}
}
@@ -0,0 +1,111 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import java.util.Arrays;
import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.scripted.gui.ScriptGuiScroll;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener {
GuiCustom parent;
String[] hoverText;
public boolean multiSelect = false;
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
super(parent, id);
this.mc = mc;
this.fontRendererObj = mc.fontRenderer;
}
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id, boolean multiSelect) {
super(parent, id, multiSelect);
this.mc = mc;
this.fontRendererObj = mc.fontRenderer;
this.multiSelect = multiSelect;
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize;
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
GL11.glPopMatrix();
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
return this.isMouseOver(mouseX, mouseY);
}
public void fromComponent(ScriptGuiScroll component) {
this.guiLeft = GuiCustom.guiLeft + component.getPosX();
this.guiTop = GuiCustom.guiTop + component.getPosY();
this.setSize(component.getWidth(), component.getHeight());
this.setUnsortedList(Arrays.asList(component.getList()));
if (component.getDefaultSelection() >= 0) {
int defaultSelect = component.getDefaultSelection();
if (defaultSelect < this.getList().size()) {
this.selected = defaultSelect;
}
}
if (component.hasHoverText()) {
this.hoverText = component.getHoverText();
}
}
public ICustomGuiComponent toComponent() {
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0]));
component.setHoverText(this.hoverText);
return component;
}
public NBTTagCompound toNBT() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("id", this.id);
if (!this.getSelectedList().isEmpty()) {
NBTTagList tagList = new NBTTagList();
Iterator var3 = this.getSelectedList().iterator();
while(var3.hasNext()) {
String s = (String)var3.next();
tagList.appendTag(new NBTTagString(s));
}
nbt.setTag("selectedList", tagList);
} else if (this.getSelected() != null && !this.getSelected().isEmpty()) {
nbt.setString("selected", this.getSelected());
} else {
nbt.setString("selected", "Null");
}
return nbt;
}
}
@@ -0,0 +1,30 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import noppes.npcs.client.gui.custom.GuiCustom;
public class CustomGuiSlot extends Slot {
public boolean clientSide;
public int slotNumber;
public CustomGuiSlot(IInventory inventoryIn, int index, int xPosition, int yPosition, boolean clientSide) {
super(inventoryIn, index, xPosition, yPosition);
this.clientSide = clientSide;
this.slotNumber = index;
}
public void onSlotChanged() {
if (this.clientSide) {
((GuiCustom)Minecraft.getMinecraft().currentScreen).slotChange(this);
}
super.onSlotChanged();
}
}
@@ -0,0 +1,80 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
import noppes.npcs.client.gui.custom.interfaces.IKeyListener;
import noppes.npcs.scripted.gui.ScriptGuiTextField;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
GuiCustom parent;
String[] hoverText;
int id;
public CustomGuiTextField(int id, int x, int y, int width, int height) {
super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
this.id = id;
this.setMaxStringLength(500);
}
public void keyTyped(char typedChar, int keyCode) {
this.textboxKeyTyped(typedChar, keyCode);
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
this.drawTextBox();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public NBTTagCompound toNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("id", this.id);
tag.setString("text", this.getText());
return tag;
}
public ICustomGuiComponent toComponent() {
ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height);
component.setText(this.getText());
component.setHoverText(this.hoverText);
return component;
}
public static CustomGuiTextField fromComponent(ScriptGuiTextField component) {
CustomGuiTextField txt = new CustomGuiTextField(component.getID(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
if (component.hasHoverText()) {
txt.hoverText = component.getHoverText();
}
if (component.getText() != null && !component.getText().isEmpty()) {
txt.setText(component.getText());
}
return txt;
}
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
this.mouseClicked(mouseX, mouseY, mouseButton);
return true;
}
}
@@ -0,0 +1,88 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent;
ResourceLocation texture;
int id;
int x;
int y;
int width;
int height;
int textureX;
int textureY;
float scale;
String[] hoverText;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = GuiCustom.guiLeft + x;
this.y = GuiCustom.guiTop + y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(this.texture);
this.drawTexturedModalRect(this.textureX, this.textureY, 0, 0, (int)(this.width*this.scale), (int)(this.height*this.scale));
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
public ICustomGuiComponent toComponent() {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setScale(this.scale);
return component;
}
public static CustomGuiTexturedRect fromComponent(ScriptGuiTexturedRect component) {
CustomGuiTexturedRect rect;
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTextureX(), component.getTextureY());
} else {
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
}
rect.scale = component.getScale();
if (component.hasHoverText()) {
rect.hoverText = component.getHoverText();
}
return rect;
}
}
@@ -0,0 +1,12 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import noppes.npcs.client.gui.custom.GuiCustom;
public interface IClickListener extends IGuiComponent {
boolean mouseClicked(GuiCustom var1, int var2, int var3, int var4);
}
@@ -0,0 +1,12 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import net.minecraft.nbt.NBTTagCompound;
public interface IDataHolder extends IGuiComponent {
NBTTagCompound toNBT();
}
@@ -0,0 +1,17 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
import net.minecraft.client.Minecraft;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
public interface IGuiComponent {
int getID();
void onRender(Minecraft var1, int var2, int var3, int var4, float var5);
ICustomGuiComponent toComponent();
}
@@ -0,0 +1,10 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.custom.interfaces;
public interface IKeyListener extends IGuiComponent {
void keyTyped(char var1, int var2);
}
@@ -12,6 +12,7 @@ public class GuiModelArms extends GuiModelInterface{
private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"};
private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrSolidArmwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"};
private GuiScreen parent;
@@ -32,6 +33,9 @@ public class GuiModelArms extends GuiModelInterface{
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear));
addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF));
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidArmwear, playerdata.solidArmwear));
addLabel(new GuiNpcLabel(9, "Solid Armwear", guiLeft, y + 5, 0xFFFFFF));
}
ModelPartData claws = playerdata.getPartData("claws");
@@ -50,6 +54,9 @@ public class GuiModelArms extends GuiModelInterface{
if(button.id == 8){
playerdata.armwear = (byte) button.getValue();
}
if(button.id == 9){
playerdata.solidArmwear = (byte) button.getValue();
}
if(button.id == 30){
playerdata.hideArms = (byte) button.getValue();
}
@@ -12,7 +12,7 @@ public class GuiModelBody extends GuiModelInterface{
private GuiScreen parent;
private final String[] arrBody = new String[]{"gui.no","gui.yes"};
private final String[] arrBodywear = new String[]{"gui.no","gui.yes"};
private final String[] arrBodywear = new String[]{"gui.no","gui.yes","Solid"};
private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9",
"Type10","Type11","Type12","Type13"};
private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"};
@@ -13,6 +13,7 @@ public class GuiModelLegs extends GuiModelInterface{
private GuiScreen parent;
private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"};
private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrSolidLegwear = new String[]{"gui.no","Both","Left","Right"};
private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"};
private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather"};
public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){
@@ -32,6 +33,9 @@ public class GuiModelLegs extends GuiModelInterface{
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear));
addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF));
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidLegwear, playerdata.solidLegwear));
addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF));
}
addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts)));
@@ -91,6 +95,9 @@ public class GuiModelLegs extends GuiModelInterface{
if(button.id == 8){
playerdata.legwear = (byte) button.getValue();
}
if(button.id == 9){
playerdata.solidLegwear = (byte) button.getValue();
}
if(button.id == 30){
playerdata.hideLegs = (byte) button.getValue();
}
@@ -20,6 +20,7 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
@@ -134,6 +135,17 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
hookList.add("playSound");
hookList.add("lightning");
hookList.add("changedDim");
hookList.add("questStart");
hookList.add("questCompleted");
hookList.add("questTurnIn");
hookList.add("factionPoints");
hookList.add("dialogOpen");
hookList.add("dialogOption");
hookList.add("dialogClose");
hookList.add("customGuiClosed");
hookList.add("customGuiButton");
hookList.add("customGuiSlot");
hookList.add("customGuiScroll");
}
else if(handler instanceof ForgeDataScript) {
hooks.setSize(238, 198);
@@ -240,9 +252,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
@Override
public void unFocused(GuiNpcTextField textfield) {
/*if(textfield.id == 1){
this.handler.getScripts().get(this.activeTab - 1).setType(textfield.getText());
}*/
}
private String getConsoleText() {
@@ -20,7 +20,7 @@ public class GuiCustomScroll extends GuiScreen
public int id;
public int guiLeft = 0;
public int guiTop = 0;
private int xSize, ySize;
public int xSize, ySize;
public int selected;
private HashSet<String> selectedList;
private int hover;
@@ -43,17 +43,18 @@ public class ModelMPM extends ModelNPCMale{
// New
public ModelRenderer bipedBodywear;
public ModelRenderer bipedRightArmwear;
public ModelRenderer bipedRightArmWear;
public ModelRenderer bipedLeftArmwear;
public ModelRenderer bipedRightLegWear;
public ModelRenderer bipedLeftLegWear;
private ModelLegs legs;
private ModelScaleRenderer headwear;
// private ModelScaleRenderer bodywear;
// private ModelScaleRenderer armwear;
// private ModelScaleRenderer legwear;
private ModelScaleRenderer bodywear;
private final ModelScaleRenderer solidLeftArmWear;
private final ModelScaleRenderer solidRightArmWear;
private final ModelScaleRenderer solidLeftLegWear;
private final ModelScaleRenderer solidRightLegWear;
private ModelTail tail;
public ModelBase entityModel;
@@ -110,15 +111,17 @@ public class ModelMPM extends ModelNPCMale{
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1);
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
this.bipedRightArmwear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmwear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmwear);
// this.bipedRightArmWear.setRotationPoint(-5.0F, 2.5F + par2, 0.0F);
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmWear);
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
this.bipedRightArm.addChild(this.solidRightArmWear);
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
// this.bipedLeftArmWear.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
this.bipedLeftArm.addChild(this.solidLeftArmWear);
}
else{
// Steve Version
@@ -130,15 +133,17 @@ public class ModelMPM extends ModelNPCMale{
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1);
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
this.bipedRightArmwear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmwear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmwear);
//this.bipedRightArmWear.setRotationPoint(-5.0F, 2.0F + par2, 0.0F);
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedRightArm.addChild(this.bipedRightArmWear);
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
this.bipedRightArm.addChild(this.solidRightArmWear);
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
//this.bipedLeftArmWear.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
this.bipedLeftArm.addChild(this.solidLeftArmWear);
}
this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16));
@@ -152,15 +157,19 @@ public class ModelMPM extends ModelNPCMale{
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedRightLeg.addChild(this.bipedRightLegWear);
// this.bipedRightLegWear.setRotationPoint(-1.9F, 12.0F + par2, 0.0F);
this.solidRightLegWear = new ModelLimbWear(this,"leg","right");
this.bipedRightLeg.addChild(this.solidRightLegWear);
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left");
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
headwear = new ModelHeadwear(this);
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 64);
// bodywear = new ModelBodywear(this);
bodywear = new ModelBodywear(this);
this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 64));
if(!isArmor){
@@ -235,16 +244,24 @@ public class ModelMPM extends ModelNPCMale{
this.bipedBody.addChild(this.bipedBodywear);
// Arms
this.bipedRightArmwear = (new ModelScaleRenderer(this, 0, 0));
this.bipedRightArm.addChild(this.bipedRightArmwear);
this.bipedRightArmWear = (new ModelScaleRenderer(this, 0, 0));
this.bipedRightArm.addChild(this.bipedRightArmWear);
this.solidRightArmWear = (new ModelScaleRenderer(this, 0, 0));
this.bipedRightArm.addChild(this.solidRightArmWear);
this.bipedLeftArmwear = new ModelScaleRenderer(this, 0, 0);
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
this.solidLeftArmWear = (new ModelScaleRenderer(this, 0, 0));
this.bipedLeftArm.addChild(this.solidLeftArmWear);
// Legs
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 0));
this.bipedRightLeg.addChild(this.bipedRightLegWear);
this.solidRightLegWear = new ModelScaleRenderer(this, 0, 0);
this.bipedRightLeg.addChild(this.solidRightLegWear);
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 0);
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
this.solidLeftLegWear = new ModelScaleRenderer(this, 0, 0);
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
headwear = new ModelHeadwear(this, true);
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 32);
@@ -539,7 +556,24 @@ public class ModelMPM extends ModelNPCMale{
((ModelScaleRenderer)this.bipedBody).isHidden = entity.modelData.hideBody == 1;
// Hide Bodywear
((ModelScaleRenderer)this.bipedBodywear).isHidden = entity.modelData.bodywear != 1;
((ModelScaleRenderer)this.bipedBodywear).isHidden = entity.modelData.bodywear == 0;
if(bipedBodywear.showModel && !bipedBodywear.isHidden){
if(entity.modelData.bodywear == 1 || isArmor){
((ModelScaleRenderer)this.bipedBodywear).setConfig(entity.modelData.body,x,y,z);
((ModelScaleRenderer)this.bipedBodywear).render(f);
}
else if(entity.modelData.bodywear == 2){
this.bodywear.rotateAngleX = bipedBodywear.rotateAngleX;
this.bodywear.rotateAngleY = bipedBodywear.rotateAngleY;
this.bodywear.rotateAngleZ = bipedBodywear.rotateAngleZ;
this.bodywear.rotationPointX = bipedBodywear.rotationPointX;
this.bodywear.rotationPointY = bipedBodywear.rotationPointY;
this.bodywear.rotationPointZ = bipedBodywear.rotationPointZ;
this.bodywear.setConfig(entity.modelData.body,x,y,z);
this.bodywear.render(f);
}
}
((ModelScaleRenderer)this.bipedBody).setConfig(body,x,y,z);
((ModelScaleRenderer)this.bipedBody).render(f);
@@ -581,20 +615,31 @@ public class ModelMPM extends ModelNPCMale{
// Hide Armwear
if(entity.modelData.armwear == 1){
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = false;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = false;
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2;
this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2;
this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3;
}
else if(entity.modelData.armwear == 2){
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = true;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = false;
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2;
this.solidRightArmWear.isHidden = true;
this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3;
}
else if(entity.modelData.armwear == 3){
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = false;
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2;
this.solidLeftArmWear.isHidden = true;
}
else{
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = true;
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true;
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
this.solidRightArmWear.isHidden = true;
this.solidLeftArmWear.isHidden = true;
}
if(!bo){
@@ -641,20 +686,31 @@ public class ModelMPM extends ModelNPCMale{
// Hide Legwear
if(entity.modelData.legwear == 1){
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = false;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = false;
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2;
this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2;
this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3;
}
else if(entity.modelData.legwear == 2){
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = false;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2;
this.solidRightLegWear.isHidden = true;
this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3;
}
else if(entity.modelData.legwear == 3){
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = false;
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2;
this.solidLeftLegWear.isHidden = true;
}
else{
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
this.solidRightLegWear.isHidden = true;
this.solidLeftLegWear.isHidden = true;
}
this.legs.setConfig(legs,x,y,z);
@@ -10,54 +10,47 @@ public class ModelBodywear extends ModelScaleRenderer{
public ModelBodywear(ModelBase base) {
super(base);
float scaler = 0.81f;
float thick = 0.65f;
float x = -0.10f;
float y = 12.76f;
float z = -0.5f;
float z1 = 0.27f;
float thick = 0.50f;
Model2DRenderer front = new Model2DRenderer(base, 20, 36, 8, 12, 64, 64);
front.setRotationPoint(-4.588f, 0 + y, -2.302f + z);
front.setScale(scaler);
front.setRotationPoint(-4.53f, 12.535f, -2.52f);
front.setScale(0.85f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 32, 36, 8, 12, 64, 64);
back.setRotationPoint(4.588f, 0 + y, 2.302f);
back.setScale(scaler);
back.setRotationPoint(4.53f, 12.535f, 2.52f);
back.setScale(0.85f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 28, 36, 4, 12, 64, 64);
right.setRotationPoint(3.9425f, 0 + y, 2.29695f);
right.setScale(scaler);
right.setRotationPoint(4.03f, 12.55f, 2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 16, 36, 4, 12, 64, 64);
left.setRotationPoint(-3.9425f, 0 + y, -2.29695f + z);
left.setScale(scaler);
left.setRotationPoint(-4.03f, 12.55f, -2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 20, 32, 8, 4, 64, 64);
top.setRotationPoint(-4.588f, -13.0f + y, -2.29695f);
top.setScale(scaler/3);
top.setRotationPoint(-4.5f, -0.6f, -2.525f);
top.setScale(0.2815f,0.315f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 28, 32, 8, 4, 64, 64);
bottom.setRotationPoint(-4.588f, -0.65f + y, -2.29695f);
bottom.setScale(scaler/3);
bottom.setRotationPoint(-4.5f, 12.11f, -2.525f);
bottom.setScale(0.2815f,0.315f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
@@ -0,0 +1,235 @@
package noppes.npcs.client.model.part;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import noppes.npcs.client.model.util.Model2DRenderer;
import noppes.npcs.client.model.util.ModelScaleRenderer;
public class ModelLimbWear extends ModelScaleRenderer {
public ModelLimbWear(ModelBase base, String limb, String side) {
super(base);
float thick = 0.55f;
switch (limb){
case "arm":
switch (side){
case "right":
rightArm(base,thick);
break;
case "left":
leftArm(base,thick);
break;
}
break;
case "leg":
switch (side){
case "right":
rightLeg(base,thick);
break;
case "left":
leftLeg(base,thick);
break;
}
break;
}
}
public void rightArm(ModelBase base, float thick){
float x = 0.95f;
float y = -2.0f;
Model2DRenderer front = new Model2DRenderer(base, 44, 36, 4, 12, 64, 64);
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 52, 36, 4, 12, 64, 64);
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
right.setRotationPoint(0.1f+x, 12.55f+y, 2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
left.setRotationPoint(-3.98f+x, 12.55f+y, -2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 48, 32, 4, 4, 64, 64);
bottom.setRotationPoint(-4.5f+x, 12.0f+y, -2.525f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void leftArm(ModelBase base,float thick){
float x = 2.95f;
float y = -2.0f;
Model2DRenderer front = new Model2DRenderer(base, 52, 52, 4, 12, 64, 64);
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 60, 52, 4, 12, 64, 64);
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
right.setRotationPoint(0.06f+x, 12.55f+y, 2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 52, 48, 4, 4, 64, 64);
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 56, 48, 4, 4, 64, 64);
bottom.setRotationPoint(-4.56f+x, 12.0f+y, -2.55f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void rightLeg(ModelBase base, float thick){
float x = 1.8f;
float y = 0.0f;
Model2DRenderer front = new Model2DRenderer(base, 4, 36, 4, 12, 64, 64);
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 12, 36, 4, 12, 64, 64);
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 4, 32, 4, 4, 64, 64);
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 8, 32, 4, 4, 64, 64);
bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void leftLeg(ModelBase base,float thick){
float x = 2.05f;
float y = 0.0f;
Model2DRenderer front = new Model2DRenderer(base, 4, 52, 4, 12, 64, 64);
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
front.setScale(0.96f,0.8175f);
front.setThickness(thick);
setRotation(front, 0, 0, 0);
this.addChild(front);
Model2DRenderer back = new Model2DRenderer(base, 12, 52, 4, 12, 64, 64);
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
back.setScale(0.96f,0.8175f);
back.setThickness(thick);
setRotation(back, 0, (float)(Math.PI), 0);
this.addChild(back);
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
right.setScale(0.96f,0.82f);
right.setThickness(thick);
setRotation(right, 0, (float)(Math.PI/2f), 0);
this.addChild(right);
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
left.setScale(0.96f,0.82f);
left.setThickness(thick);
setRotation(left, 0, (float)(Math.PI/-2f), 0);
this.addChild(left);
Model2DRenderer top = new Model2DRenderer(base, 4, 48, 4, 4, 64, 64);
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
top.setScale(0.32f);
top.setThickness(thick);
setRotation(top, (float)(Math.PI / -2), 0, 0);
this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 8, 48, 4, 4, 64, 64);
bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f);
bottom.setScale(0.32f);
bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
this.addChild(bottom);
}
public void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}
@@ -1,5 +1,5 @@
package noppes.npcs.constants;
public enum EnumGuiType {
MainMenuDisplay, MainMenuInv, MainMenuStats, ManageFactions, MainMenuAdvanced, MainMenuGlobal, PlayerBankSmall, PlayerFollowerHire, PlayerFollower, SetupItemGiver, SetupTrader, SetupFollower, PlayerTrader, PlayerTransporter, RedstoneBlock, SetupTransporter, ManageTransport, ManageBanks, MobSpawner, SetupBank, ManageDialogs, ManageQuests, PlayerAnvil, QuestReward, ManageRecipes, QuestItem, NpcRemote, ScriptEvent, MoneyBag, MainMenuAI, MovingPath, PlayerBankUnlock, PlayerBankUprade, PlayerBankLarge, MobSpawnerAdd, PlayerMailbox, PlayerMailman, Waypoint, MerchantAdd, MobSpawnerMounter, Crate, NpcDimensions, Border, BigSign, Script, Companion, CompanionInv, CompanionTalent, CompanionTrader, ManageLinked
MainMenuDisplay, MainMenuInv, MainMenuStats, ManageFactions, MainMenuAdvanced, MainMenuGlobal, PlayerBankSmall, PlayerFollowerHire, PlayerFollower, SetupItemGiver, SetupTrader, SetupFollower, PlayerTrader, PlayerTransporter, RedstoneBlock, SetupTransporter, ManageTransport, ManageBanks, MobSpawner, SetupBank, ManageDialogs, ManageQuests, PlayerAnvil, QuestReward, ManageRecipes, QuestItem, NpcRemote, ScriptEvent, MoneyBag, MainMenuAI, MovingPath, PlayerBankUnlock, PlayerBankUprade, PlayerBankLarge, MobSpawnerAdd, PlayerMailbox, PlayerMailman, Waypoint, MerchantAdd, MobSpawnerMounter, Crate, NpcDimensions, Border, BigSign, Script, Companion, CompanionInv, CompanionTalent, CompanionTrader, ManageLinked, CustomGui;
}
@@ -76,7 +76,9 @@ public enum EnumPacketServer {
RemoteTpToNpc,QuestGet, QuestCategoryGet,
SaveTileEntity,
NaturalSpawnGetAll, MailOpenSetup,
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen;
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen,
CustomGuiButton,CustomGuiSlotChange,CustomGuiScrollClick,CustomGuiClose;
public CustomNpcsPermissions.Permission permission = null;
public boolean needsNpc = false;
@@ -11,7 +11,7 @@ public enum EnumScriptType {
TARGET("target"),
COLLIDE("collide"),
KILLS("kills"),
DIALOG_OPTION("dialogOption"),
DIALOG_CLOSE("dialogClose"),
TIMER("timer"),
ATTACK_MELEE("meleeAttack"),
@@ -36,7 +36,6 @@ public enum EnumScriptType {
LOGOUT("logout"),
CHAT("chat"),
DAMAGED_ENTITY("damagedEntity"),
DIALOG_CLOSE("dialogClose"),
SPAWN("spawn"),
TOSSED("tossed"),
PICKEDUP("pickedUp"),
@@ -44,10 +43,13 @@ public enum EnumScriptType {
PROJECTILE_TICK("projectileTick"),
PROJECTILE_IMPACT("projectileImpact"),
LEVEL_UP("levelUp"),
KEY_PRESSED("keyPressed"),
QUEST_START("questStart"),
QUEST_COMPLETED("questCompleted"),
QUEST_TURNIN("questTurnIn"),
KEY_PRESSED("keyPressed"),
FACTION_POINTS("factionPoints"),
DIALOG_OPEN("dialogOpen"),
DIALOG_OPTION("dialogOption"),
CUSTOM_CHEST_CLOSED("customChestClosed"),
CUSTOM_CHEST_CLICKED("customChestClicked"),
SCRIPT_COMMAND("scriptCommand"),
@@ -0,0 +1,103 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.containers;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import noppes.npcs.scripted.interfaces.IItemSlot;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
public class ContainerCustomGui extends Container {
public ScriptGui customGui;
public IInventory guiInventory;
int slotCount = 0;
public int playerInvX;
public int playerInvY;
public ContainerCustomGui(IInventory inventory) {
this.guiInventory = inventory;
}
public void setGui(ScriptGui gui, EntityPlayer player) {
this.customGui = gui;
if (this.customGui.getShowPlayerInv()) {
this.addPlayerInventory(player, this.customGui.getPlayerInvX(), this.customGui.getPlayerInvY());
}
Iterator var3 = this.customGui.getSlots().iterator();
while(var3.hasNext()) {
IItemSlot slot = (IItemSlot)var3.next();
if (slot.hasStack()) {
this.addSlot(slot.getPosX(), slot.getPosY(), slot.getStack().getMCItemStack(), player.worldObj.isRemote);
} else {
this.addSlot(slot.getPosX(), slot.getPosY(), player.worldObj.isRemote);
}
}
}
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < this.guiInventory.getSizeInventory()) {
if (!this.mergeItemStack(itemstack1, this.guiInventory.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 0, this.guiInventory.getSizeInventory(), false)) {
return null;
}
if (itemstack1.stackSize <= 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
void addSlot(int x, int y, boolean clientSide) {
this.addSlotToContainer(new CustomGuiSlot(this.guiInventory, this.slotCount++, x, y, clientSide));
}
void addSlot(int x, int y, ItemStack itemStack, boolean clientSide) {
this.guiInventory.setInventorySlotContents(this.slotCount, itemStack);
this.addSlotToContainer(new CustomGuiSlot(this.guiInventory, this.slotCount++, x, y, clientSide));
}
void addPlayerInventory(EntityPlayer player, int x, int y) {
this.playerInvX = x;
this.playerInvY = y;
int row;
for(row = 0; row < 3; ++row) {
for(int col = 0; col < 9; ++col) {
this.addSlotToContainer(new Slot(player.inventory, col + row * 9 + 9, x + col * 18, y + row * 18));
}
}
for(row = 0; row < 9; ++row) {
this.addSlotToContainer(new Slot(player.inventory, row, x + row * 18, y + 58));
}
}
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
public boolean canDragIntoSlot(Slot p_94531_1_) { return true; }
}
@@ -2,6 +2,7 @@ package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import noppes.npcs.ICompatibilty;
import noppes.npcs.VersionCompatibility;
import noppes.npcs.constants.EnumAvailabilityDialog;
@@ -9,8 +10,11 @@ import noppes.npcs.constants.EnumAvailabilityFaction;
import noppes.npcs.constants.EnumAvailabilityFactionType;
import noppes.npcs.constants.EnumAvailabilityQuest;
import noppes.npcs.constants.EnumDayTime;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IAvailability;
import noppes.npcs.scripted.interfaces.IPlayer;
public class Availability implements ICompatibilty {
public class Availability implements ICompatibilty, IAvailability {
public int version = VersionCompatibility.ModRev;
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
@@ -178,7 +182,7 @@ public class Availability implements ICompatibilty {
if(available == EnumAvailabilityFactionType.Always)
return true;
Faction faction = FactionController.getInstance().getFaction(id);
Faction faction = FactionController.getInstance().get(id);
if(faction == null)
return true;
@@ -233,4 +237,170 @@ public class Availability implements ICompatibilty {
public void setVersion(int version) {
this.version = version;
}
public boolean isAvailable(IPlayer player) {
return this.isAvailable((EntityPlayer)player.getMCEntity());
}
public int getDaytime() {
return this.daytime.ordinal();
}
public void setDaytime(int type) {
this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)];
}
public int getMinPlayerLevel() {
return this.minPlayerLevel;
}
public void setMinPlayerLevel(int level) {
this.minPlayerLevel = level;
}
public int getDialog(int i) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.dialogId;
} else if (i == 1) {
return this.dialog2Id;
} else {
return i == 2 ? this.dialog3Id : this.dialog4Id;
}
}
public void setDialog(int i, int id, int type) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)];
if (i == 0) {
this.dialogId = id;
this.dialogAvailable = e;
} else if (i == 1) {
this.dialog2Id = id;
this.dialog2Available = e;
} else if (i == 2) {
this.dialog3Id = id;
this.dialog3Available = e;
} else if (i == 3) {
this.dialog4Id = id;
this.dialog4Available = e;
}
}
}
public void removeDialog(int i) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.dialogId = -1;
this.dialogAvailable = EnumAvailabilityDialog.Always;
} else if (i == 1) {
this.dialog2Id = -1;
this.dialog2Available = EnumAvailabilityDialog.Always;
} else if (i == 2) {
this.dialog3Id = -1;
this.dialog3Available = EnumAvailabilityDialog.Always;
} else if (i == 3) {
this.dialog4Id = -1;
this.dialog4Available = EnumAvailabilityDialog.Always;
}
}
}
public int getQuest(int i) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else if (i == 0) {
return this.questId;
} else if (i == 1) {
return this.quest2Id;
} else {
return i == 2 ? this.quest3Id : this.quest4Id;
}
}
public void setQuest(int i, int id, int type) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)];
if (i == 0) {
this.questId = id;
this.questAvailable = e;
} else if (i == 1) {
this.quest2Id = id;
this.quest2Available = e;
} else if (i == 2) {
this.quest3Id = id;
this.quest3Available = e;
} else if (i == 3) {
this.quest4Id = id;
this.quest4Available = e;
}
}
}
public void removeQuest(int i) {
if (i < 0 && i > 3) {
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
} else {
if (i == 0) {
this.questId = -1;
this.questAvailable = EnumAvailabilityQuest.Always;
} else if (i == 1) {
this.quest2Id = -1;
this.quest2Available = EnumAvailabilityQuest.Always;
} else if (i == 2) {
this.quest3Id = -1;
this.quest3Available = EnumAvailabilityQuest.Always;
} else if (i == 3) {
this.quest4Id = -1;
this.quest4Available = EnumAvailabilityQuest.Always;
}
}
}
public void setFaction(int i, int id, int type, int stance) {
if (i < 0 && i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)];
EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)];
if (i == 0) {
this.factionId = id;
this.factionAvailable = e;
this.factionStance = ee;
} else if (i == 1) {
this.faction2Id = id;
this.faction2Available = e;
this.faction2Stance = ee;
}
}
}
public void removeFaction(int i) {
if (i < 0 && i > 1) {
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
} else {
if (i == 0) {
this.factionId = -1;
this.factionAvailable = EnumAvailabilityFactionType.Always;
this.factionStance = EnumAvailabilityFaction.Friendly;
} else if (i == 1) {
this.faction2Id = -1;
this.faction2Available = EnumAvailabilityFactionType.Always;
this.faction2Stance = EnumAvailabilityFaction.Friendly;
}
}
}
}
@@ -0,0 +1,122 @@
package noppes.npcs.controllers;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.CustomGuiEvent;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import java.io.IOException;
public class CustomGuiController {
public CustomGuiController() {
}
public static void openGui(ScriptPlayer 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) {
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
return true;
} else {
return false;
}
}
static boolean checkGui(CustomGuiEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (!(player.openContainer instanceof ContainerCustomGui)) {
return false;
} else {
return ((ContainerCustomGui)player.openContainer).customGui.getID() == event.gui.getID();
}
}
public static IItemStack[] getSlotContents(EntityPlayer player) {
IItemStack[] slotContents = new IItemStack[0];
if (player.openContainer instanceof ContainerCustomGui) {
ContainerCustomGui container = (ContainerCustomGui)player.openContainer;
slotContents = new IItemStack[container.guiInventory.getSizeInventory()];
for(int i = 0; i < container.guiInventory.getSizeInventory(); ++i) {
slotContents[i] = NpcAPI.Instance().getIItemStack(container.guiInventory.getStackInSlot(i));
}
}
return slotContents;
}
public static void onButton(CustomGuiEvent.ButtonEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event);
}
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onSlotChange(CustomGuiEvent.SlotEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SLOT, event);
}
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onScrollClick(CustomGuiEvent.ScrollEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event);
}
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onClose(CustomGuiEvent.CloseEvent event) {
if (ScriptController.Instance.playerScripts != null) {
ScriptController.Instance.playerScripts.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event);
}
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static ScriptGui getOpenGui(EntityPlayer player) {
return player.openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)player.openContainer).customGui : null;
}
public static String[] readScrollSelection(ByteBuf buffer) {
try {
NBTTagList list = Server.readNBT(buffer).getTagList("selection", 8);
String[] selection = new String[list.tagCount()];
for(int i = 0; i < list.tagCount(); ++i) {
selection[i] = list.getStringTagAt(i);
}
return selection;
} catch (IOException var4) {
var4.printStackTrace();
return null;
}
}
}
@@ -1,6 +1,8 @@
package noppes.npcs.controllers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -8,8 +10,10 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.ICompatibilty;
import noppes.npcs.VersionCompatibility;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.*;
public class Dialog implements ICompatibilty {
public class Dialog implements ICompatibilty, IDialog {
public int version = VersionCompatibility.ModRev;
public int id = -1;
public String title = "";
@@ -108,9 +112,7 @@ public class Dialog implements ICompatibilty {
public boolean hasQuest() {
return getQuest() != null;
}
public Quest getQuest() {
return QuestController.instance.quests.get(quest);
}
public boolean hasOtherOptions() {
for(DialogOption option: options.values())
if(option != null && option.optionType != EnumOptionType.Disabled)
@@ -148,5 +150,74 @@ public class Dialog implements ICompatibilty {
public void setVersion(int version) {
this.version = version;
}
public int getId() {
return this.id;
}
public String getName() {
return this.title;
}
public List<IDialogOption> getOptions() {
return new ArrayList(this.options.values());
}
public IDialogOption getOption(int slot) {
IDialogOption option = (IDialogOption)this.options.get(slot);
if (option == null) {
throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]);
} else {
return option;
}
}
public IAvailability getAvailability() {
return this.availability;
}
public IDialogCategory getCategory() {
return this.category;
}
public void save() {
DialogController.instance.saveDialog(this.category.id, this);
}
public void setName(String name) {
this.title = name;
}
public String getText() {
return this.text;
}
public void setText(String text) {
this.text = text;
}
public void setQuest(IQuest quest) {
if (quest == null) {
this.quest = -1;
} else {
if (quest.getId() < 0) {
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
}
this.quest = quest.getId();
}
}
public Quest getQuest() {
return QuestController.instance == null ? null : (Quest)QuestController.instance.quests.get(this.quest);
}
public String getCommand() {
return this.command;
}
public void setCommand(String command) {
this.command = command;
}
}
@@ -1,11 +1,15 @@
package noppes.npcs.controllers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.scripted.handler.data.IDialog;
import noppes.npcs.scripted.handler.data.IDialogCategory;
public class DialogCategory {
public class DialogCategory implements IDialogCategory {
public int id = -1;
public String title = "";
@@ -43,4 +47,18 @@ public class DialogCategory {
nbtfactions.setTag("Dialogs", dialogs);
return nbtfactions;
}
public List<IDialog> dialogs() {
return new ArrayList(this.dialogs.values());
}
public String getName() {
return this.title;
}
public IDialog create() {
Dialog dialog = new Dialog();
dialog.category = this;
return dialog;
}
}
@@ -2,9 +2,7 @@ package noppes.npcs.controllers;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -13,9 +11,12 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.scripted.handler.IDialogHandler;
import noppes.npcs.scripted.handler.data.IDialog;
import noppes.npcs.scripted.handler.data.IDialogCategory;
import noppes.npcs.util.NBTJsonUtil;
public class DialogController {
public class DialogController implements IDialogHandler {
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
public static DialogController instance;
@@ -312,4 +313,12 @@ public class DialogController {
}
return map;
}
public List<IDialogCategory> categories() {
return new ArrayList(this.categories.values());
}
public IDialog get(int id) {
return (IDialog)this.dialogs.get(id);
}
}
@@ -1,13 +1,18 @@
package noppes.npcs.controllers;
import java.util.HashSet;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IFaction;
import noppes.npcs.scripted.interfaces.ICustomNpc;
import noppes.npcs.scripted.interfaces.IPlayer;
public class Faction {
public class Faction implements IFaction {
public String name = "";
public int color = Integer.parseInt("FF00", 16);
@@ -85,4 +90,90 @@ public class Faction {
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
return attackFactions.contains(entity.faction.id);
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public int getDefaultPoints() {
return this.defaultPoints;
}
public int getColor() {
return this.color;
}
public int playerStatus(IPlayer player) {
PlayerFactionData data = PlayerData.get((EntityPlayer) player.getMCEntity()).factionData;
int points = data.getFactionPoints(this.id);
if (points >= this.friendlyPoints) {
return 1;
} else {
return points < this.neutralPoints ? -1 : 0;
}
}
public boolean hostileToNpc(ICustomNpc npc) {
return this.attackFactions.contains(npc.getFaction().getId());
}
public void setDefaultPoints(int points) {
this.defaultPoints = points;
}
public boolean hostileToFaction(int factionId) {
return this.attackFactions.contains(factionId);
}
public int[] getHostileList() {
int[] a = new int[this.attackFactions.size()];
int i = 0;
Integer val;
for(Iterator var3 = this.attackFactions.iterator(); var3.hasNext(); a[i++] = val) {
val = (Integer)var3.next();
}
return a;
}
public void addHostile(int id) {
if (this.attackFactions.contains(id)) {
throw new CustomNPCsException("Faction " + this.id + " is already hostile to " + id, new Object[0]);
} else {
this.attackFactions.add(id);
}
}
public void removeHostile(int id) {
this.attackFactions.remove(id);
}
public boolean hasHostile(int id) {
return this.attackFactions.contains(id);
}
public boolean getIsHidden() {
return this.hideFaction;
}
public void setIsHidden(boolean bo) {
this.hideFaction = bo;
}
public boolean getAttackedByMobs() {
return this.getsAttacked;
}
public void setAttackedByMobs(boolean bo) {
this.getsAttacked = bo;
}
public void save() {
FactionController.getInstance().saveFaction(this);
}
}
@@ -6,7 +6,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
@@ -15,8 +17,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.scripted.handler.IFactionHandler;
import noppes.npcs.scripted.handler.data.IFaction;
public class FactionController {
public class FactionController implements IFactionHandler {
public HashMap<Integer,Faction> factions;
private static FactionController instance;
@@ -124,10 +130,14 @@ public class FactionController {
}
}
public Faction getFaction(int faction) {
public Faction get(int faction) {
return factions.get(faction);
}
public List<IFaction> list() {
return new ArrayList(this.factions.values());
}
public void saveFaction(Faction faction) {
if(faction.id < 0){
@@ -145,6 +155,30 @@ public class FactionController {
factions.put(faction.id, faction);
saveFactions();
}
public Faction create(Faction faction) {
String name = faction.getName();
int color = faction.getColor();
for(faction = new Faction(); this.hasName(name); name = name + "_") {
}
faction.name = name;
faction.color = color;
this.saveFaction(faction);
return faction;
}
public Faction create(String name, int color) {
Faction faction;
for(faction = new Faction(); this.hasName(name); name = name + "_") {
}
faction.name = name;
faction.color = color;
this.saveFaction(faction);
return faction;
}
public int getUnusedId(){
if(lastUsedID == 0){
@@ -155,11 +189,20 @@ public class FactionController {
lastUsedID++;
return lastUsedID;
}
public void removeFaction(int id) {
if(id < 0 || factions.size() <= 1)
return;
factions.remove(id);
saveFactions();
public IFaction delete(int id) {
if (id >= 0 && this.factions.size() > 1) {
Faction faction = (Faction)this.factions.remove(id);
saveFactions();
if (faction == null) {
return null;
} else {
this.saveFactions();
faction.id = -1;
return faction;
}
} else {
return null;
}
}
public int getFirstFactionId() {
@@ -1,8 +1,12 @@
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 {
@@ -52,16 +56,16 @@ public class FactionOptions {
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
}
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
Faction faction = FactionController.getInstance().getFaction(factionId);
Faction faction = FactionController.getInstance().get(factionId);
if(faction == null)
return;
if(!faction.hideFaction){
String message = decrease?"faction.decreasepoints":"faction.increasepoints";
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
}
data.increasePoints(factionId, decrease?-points:points);
data.increasePoints(factionId, decrease?-points:points,player);
}
}
@@ -2,8 +2,13 @@ package noppes.npcs.controllers;
import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer;
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.event.FactionEvent;
public class PlayerFactionData {
public HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
@@ -39,15 +44,16 @@ public class PlayerFactionData {
public int getFactionPoints(int id) {
if(!factionData.containsKey(id)){
Faction faction = FactionController.getInstance().getFaction(id);
Faction faction = FactionController.getInstance().get(id);
factionData.put(id, faction == null? -1 : faction.defaultPoints);
}
return factionData.get(id);
}
public void increasePoints(int factionId, int points) {
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));
if(!factionData.containsKey(factionId)){
Faction faction = FactionController.getInstance().getFaction(factionId);
Faction faction = FactionController.getInstance().get(factionId);
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
}
factionData.put(factionId, factionData.get(factionId) + points);
@@ -59,7 +65,7 @@ public class PlayerFactionData {
NBTTagList list = new NBTTagList();
for(int id : factionData.keySet()){
Faction faction = FactionController.getInstance().getFaction(id);
Faction faction = FactionController.getInstance().get(id);
if(faction == null || faction.hideFaction)
continue;
NBTTagCompound com = new NBTTagCompound();
@@ -4,6 +4,7 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.EventHooks;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat;
@@ -30,6 +31,10 @@ public class PlayerQuestController {
public static void addActiveQuest(Quest quest, EntityPlayer player) {
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
if(canQuestBeAccepted(quest, player)){
if (EventHooks.onQuestStarted(player, quest)) {
return;
}
data.activeQuests.put(quest.id,new QuestData(quest));
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.EventHooks;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestCompletion;
@@ -103,6 +104,7 @@ public class PlayerQuestData {
}
data.isCompleted = true;
bo = true;
EventHooks.onQuestFinished(player,data.quest);
}
}
else
@@ -16,8 +16,15 @@ import noppes.npcs.quests.QuestInterface;
import noppes.npcs.quests.QuestItem;
import noppes.npcs.quests.QuestKill;
import noppes.npcs.quests.QuestLocation;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory;
import noppes.npcs.scripted.handler.data.IQuestObjective;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.IPlayer;
public class Quest implements ICompatibilty {
public class Quest implements ICompatibilty, IQuest {
public int version = VersionCompatibility.ModRev;
public int id = -1;
public EnumQuestType type = EnumQuestType.Item;
@@ -148,4 +155,91 @@ public class Quest implements ICompatibilty {
public void setVersion(int version) {
this.version = version;
}
public int getId() {
return this.id;
}
public String getName() {
return this.title;
}
public int getType() {
return this.type.ordinal();
}
public void setType(int questType) {
if(questType < 0 || questType >= EnumQuestType.values().length)
return;
EnumQuestType type = EnumQuestType.values()[questType];
setType(type);
}
public IQuestCategory getCategory() {
return this.category;
}
public void save() {
QuestController.instance.saveQuest(this.category.id, this);
}
public void setName(String name) {
this.title = name;
}
public String getLogText() {
return this.logText;
}
public void setLogText(String text) {
this.logText = text;
}
public String getCompleteText() {
return this.completeText;
}
public void setCompleteText(String text) {
this.completeText = text;
}
public void setNextQuest(IQuest quest) {
if (quest == null) {
this.nextQuestid = -1;
this.nextQuestTitle = "";
} else {
if (quest.getId() < 0) {
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
}
this.nextQuestid = quest.getId();
this.nextQuestTitle = quest.getName();
}
}
public String getNpcName() {
return this.completerNpc;
}
public void setNpcName(String name) {
this.completerNpc = name;
}
public IQuestObjective[] getObjectives(IPlayer player) {
if (!player.hasActiveQuest(this.id)) {
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
} else {
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
}
}
public boolean getIsRepeatable() {
return this.repeat != EnumQuestRepeat.NONE;
}
public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems);
}
}
@@ -1,11 +1,15 @@
package noppes.npcs.controllers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory;
public class QuestCategory {
public class QuestCategory implements IQuestCategory {
public HashMap<Integer,Quest> quests;
public int id = -1;
public String title = "";
@@ -43,4 +47,18 @@ public class QuestCategory {
return nbttagcompound;
}
public List<IQuest> quests() {
return new ArrayList(this.quests.values());
}
public String getName() {
return this.title;
}
public IQuest create() {
Quest quest = new Quest();
quest.category = this;
return quest;
}
}
@@ -2,9 +2,7 @@ package noppes.npcs.controllers;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -12,9 +10,12 @@ import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.scripted.handler.IQuestHandler;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory;
import noppes.npcs.util.NBTJsonUtil;
public class QuestController {
public class QuestController implements IQuestHandler {
public HashMap<Integer,QuestCategory> categories = new HashMap<Integer, QuestCategory>();
public HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
@@ -232,5 +233,12 @@ public class QuestController {
private File getDir(){
return new File(CustomNpcs.getWorldSaveDirectory(), "quests");
}
public List<IQuestCategory> categories() {
return new ArrayList(this.categories.values());
}
public IQuest get(int id) {
return (IQuest)this.quests.get(id);
}
}
@@ -1,20 +1,24 @@
package noppes.npcs.controllers;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.handler.data.IRecipe;
public class RecipeCarpentry extends ShapedRecipes{
public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
public int id = -1;
public String name = "";
public Availability availability = new Availability();
@@ -222,4 +226,64 @@ public class RecipeCarpentry extends ShapedRecipes{
}
return false;
}
public String getName() {
return this.name;
}
public ItemStack getResult() {
return this.getRecipeOutput();
}
public boolean isGlobal() {
return this.isGlobal;
}
public void setIsGlobal(boolean bo) {
this.isGlobal = bo;
}
public boolean getIgnoreNBT() {
return this.ignoreNBT;
}
public void setIgnoreNBT(boolean bo) {
this.ignoreNBT = bo;
}
public boolean getIgnoreDamage() {
return this.ignoreDamage;
}
public void setIgnoreDamage(boolean bo) {
this.ignoreDamage = bo;
}
public int getWidth() {
return this.recipeWidth;
}
public int getHeight() {
return this.recipeHeight;
}
public void save() {
try {
RecipeController.instance.saveRecipe(this.writeNBT());
} catch (IOException var2) {
}
}
public void delete() {
RecipeController.instance.delete(this.id);
}
public ItemStack[] getRecipe() {
return this.recipeItems;
}
public int getId() {
return this.id;
}
}
@@ -4,10 +4,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.*;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
@@ -16,8 +13,10 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs;
import noppes.npcs.scripted.handler.IRecipeHandler;
import noppes.npcs.scripted.handler.data.IRecipe;
public class RecipeController {
public class RecipeController implements IRecipeHandler {
private static Collection<RecipeCarpentry> prevRecipes;
public HashMap<Integer,RecipeCarpentry> globalRecipes = new HashMap<Integer, RecipeCarpentry>();
public HashMap<Integer,RecipeCarpentry> anvilRecipes = new HashMap<Integer, RecipeCarpentry>();
@@ -198,7 +197,7 @@ public class RecipeController {
return false;
}
public RecipeCarpentry removeRecipe(int id) {
public RecipeCarpentry delete(int id) {
RecipeCarpentry recipe = getRecipe(id);
globalRecipes.remove(recipe.id);
anvilRecipes.remove(recipe.id);
@@ -214,4 +213,46 @@ public class RecipeController {
RecipeController.instance.globalRecipes.put(recipeAnvil.id, recipeAnvil);
}
}
public List<IRecipe> getGlobalList() {
return new ArrayList(this.globalRecipes.values());
}
public List<IRecipe> getCarpentryList() {
return new ArrayList(this.anvilRecipes.values());
}
public void addRecipe(String name, boolean global, ItemStack result, Object... objects) {
RecipeCarpentry recipe = new RecipeCarpentry(name);
recipe.isGlobal = global;
recipe = RecipeCarpentry.saveRecipe(recipe, result, objects);
try {
this.saveRecipe(recipe.writeNBT());
} catch (Exception var7) {
var7.printStackTrace();
}
}
public void addRecipe(String name, boolean global, ItemStack result, int width, int height, ItemStack... objects) {
ArrayList<ItemStack> list = new ArrayList<>();
int var9 = objects.length;
for(int var10 = 0; var10 < var9; ++var10) {
ItemStack item = objects[var10];
if (item.stackSize > 0) {
list.add(item);
}
}
RecipeCarpentry recipe = new RecipeCarpentry(width, height, list.toArray(new ItemStack[0]), result);
recipe.isGlobal = global;
recipe.name = name;
try {
this.saveRecipe(recipe.writeNBT());
} catch (IOException var12) {
var12.printStackTrace();
}
}
}
@@ -31,13 +31,7 @@ import noppes.npcs.LogWriter;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.entity.ScriptAnimal;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.entity.ScriptLiving;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.entity.ScriptMonster;
import noppes.npcs.scripted.entity.ScriptPixelmon;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.entity.*;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.util.JsonException;
import noppes.npcs.util.NBTJsonUtil;
@@ -256,7 +250,7 @@ public class ScriptController {
if(entity == null)
return null;
if(entity instanceof EntityNPCInterface)
return ((EntityNPCInterface) entity).script.dummyNpc;
return (ScriptNpc)((EntityNPCInterface) entity).script.dummyNpc;
else{
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
if(data != null)
@@ -13,6 +13,7 @@ import java.util.Map;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -20,11 +21,17 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.handler.ICloneHandler;
import noppes.npcs.scripted.interfaces.IEntity;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.util.JsonException;
import noppes.npcs.util.NBTJsonUtil;
public class ServerCloneController {
public class ServerCloneController implements ICloneHandler {
public static ServerCloneController Instance;
public ServerCloneController(){
@@ -193,4 +200,39 @@ public class ServerCloneController {
nbttagcompound.setTag("TransformAI", adv);
}
}
public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) {
NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab);
if (compound == null) {
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 : NpcAPI.Instance().getIEntity(entity);
}
}
public IEntity get(int tab, String name, IWorld world) {
NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab);
if (compound == null) {
throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]);
} else {
Instance.cleanTags(compound);
Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld());
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
}
}
public void set(int tab, String name, IEntity entity) {
NBTTagCompound compound = new NBTTagCompound();
if (!entity.getMCEntity().isEntityAlive()) {
throw new CustomNPCsException("Cannot save dead entities", new Object[0]);
} else {
this.cleanTags(compound);
this.saveClone(tab, name, compound);
}
}
public void remove(int tab, String name) {
this.removeClone(name, tab);
}
}
@@ -3,6 +3,7 @@ package noppes.npcs.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@@ -36,10 +37,26 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
return;
}
int blockY = (int) this.posY;
double heightOffGround = 0;
if(this.ai.hasFlyLimit) {
for (blockY = (int) this.posY; blockY > 0; blockY--) {
heightOffGround = this.posY - blockY;
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
break;
}
}
}
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0)
{
this.motionY *= this.ai.flyGravity;
this.velocityChanged = true;
if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){
this.motionY *= 0.8D;
this.velocityChanged = true;
} else {
this.motionY *= this.ai.flyGravity;
this.velocityChanged = true;
}
}
}
@@ -313,10 +313,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
LinkedNpcController.Instance.loadNpcData(this);
}
if(updateClient){
NBTTagCompound compound = writeSpawnData();
compound.setInteger("EntityId", getEntityId());
Server.sendAssociatedData(this, EnumPacketClient.UPDATE_NPC, compound);
updateClient = false;
this.updateClient();
}
if(updateAI){
updateTasks();
@@ -365,6 +362,14 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
((JobBard)jobInterface).onLivingUpdate();
}
}
public void updateClient() {
NBTTagCompound compound = writeSpawnData();
compound.setInteger("EntityId", getEntityId());
Server.sendAssociatedData(this, EnumPacketClient.UPDATE_NPC, compound);
updateClient = false;
}
@Override
public boolean interact(EntityPlayer player) {
@@ -1417,10 +1422,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return fac;
}
else{
Faction fac = FactionController.getInstance().getFaction(faction);
Faction fac = FactionController.getInstance().get(faction);
if (fac == null) {
faction = FactionController.getInstance().getFirstFactionId();
fac = FactionController.getInstance().getFaction(faction);
fac = FactionController.getInstance().get(faction);
}
return fac;
}
@@ -1431,7 +1436,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public void setFaction(int integer) {
if(integer < 0|| isRemote())
return;
Faction faction = FactionController.getInstance().getFaction(integer);
Faction faction = FactionController.getInstance().get(integer);
if(faction == null)
return;
String str = faction.id + ":" + faction.color + ":" + faction.name;
@@ -1,14 +1,20 @@
package noppes.npcs.quests;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestDialog extends QuestInterface{
@@ -55,4 +61,69 @@ public class QuestDialog extends QuestInterface{
return vec;
}
public IQuestObjective[] getObjectives(EntityPlayer player) {
List<IQuestObjective> list = new ArrayList();
for(int i = 0; i < 3; ++i) {
if (this.dialogs.containsKey(i)) {
Dialog dialog = (Dialog)DialogController.instance.dialogs.get(this.dialogs.get(i));
if (dialog != null) {
list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, player, dialog));
}
}
}
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
class QuestDialogObjective implements IQuestObjective {
private final QuestDialog parent;
private final EntityPlayer player;
private final Dialog dialog;
public QuestDialogObjective(QuestDialog this$0, EntityPlayer player, Dialog dialog) {
this.parent = this$0;
this.player = player;
this.dialog = dialog;
}
public int getProgress() {
return this.isCompleted() ? 1 : 0;
}
public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) {
PlayerData data = PlayerData.get(this.player);
boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
if (progress == 0 && completed) {
data.dialogData.dialogsRead.remove(this.dialog.id);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
data.saveNBTData(data.getNBT());
}
if (progress == 1 && !completed) {
data.dialogData.dialogsRead.add(this.dialog.id);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
data.saveNBTData(data.getNBT());
}
} else {
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
}
}
public int getMaxProgress() {
return 1;
}
public boolean isCompleted() {
PlayerData data = PlayerData.get(this.player);
return data.dialogData.dialogsRead.contains(this.dialog.id);
}
public String getText() {
return this.dialog.title + (this.isCompleted() ? " (read)" : " (unread)");
}
}
}
@@ -4,6 +4,7 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public abstract class QuestInterface {
public int questId;
@@ -12,4 +13,5 @@ public abstract class QuestInterface {
public abstract boolean isCompleted(EntityPlayer player);
public abstract void handleComplete(EntityPlayer player);
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
}
@@ -1,13 +1,16 @@
package noppes.npcs.quests;
import java.util.HashMap;
import java.util.Vector;
import java.util.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.NpcMiscInventory;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestObjective;
import noppes.npcs.util.ValueUtil;
public class QuestItem extends QuestInterface{
public NpcMiscInventory items = new NpcMiscInventory(3);
@@ -119,5 +122,59 @@ public class QuestItem extends QuestInterface{
return vec;
}
public IQuestObjective[] getObjectives(EntityPlayer player) {
List<IQuestObjective> list = new ArrayList();
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
Iterator var4 = questItems.iterator();
while(var4.hasNext()) {
ItemStack stack = (ItemStack)var4.next();
if (stack.stackSize > 0) {
list.add(new noppes.npcs.quests.QuestItem.QuestItemObjective(this, player, stack));
}
}
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
class QuestItemObjective implements IQuestObjective {
private final QuestItem parent;
private final EntityPlayer player;
private final ItemStack questItem;
public QuestItemObjective(QuestItem this$0, EntityPlayer player, ItemStack item) {
this.parent = this$0;
this.player = player;
this.questItem = item;
}
public int getProgress() {
int count = 0;
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
ItemStack item = this.player.inventory.getStackInSlot(i);
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
count += item.stackSize;
}
}
return ValueUtil.CorrectInt(count, 0, this.questItem.stackSize);
}
public void setProgress(int progress) {
throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]);
}
public int getMaxProgress() {
return this.questItem.stackSize;
}
public boolean isCompleted() {
return NoppesUtilPlayer.compareItems(this.player, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT);
}
public String getText() {
return this.questItem.getDisplayName() + ": " + this.getProgress() + "/" + this.getMaxProgress();
}
}
}
@@ -1,16 +1,20 @@
package noppes.npcs.quests;
import java.util.HashMap;
import java.util.Vector;
import java.util.*;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestKill extends QuestInterface{
public HashMap<String,Integer> targets = new HashMap<String,Integer>();
@@ -74,4 +78,67 @@ public class QuestKill extends QuestInterface{
data.extraData.setTag("Killed", NBTTags.nbtStringIntegerMap(killed));
}
public IQuestObjective[] getObjectives(EntityPlayer player) {
List<IQuestObjective> list = new ArrayList();
Iterator var3 = this.targets.entrySet().iterator();
while(var3.hasNext()) {
Map.Entry<String, Integer> entry = (Map.Entry)var3.next();
list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, (String)entry.getKey(), (Integer)entry.getValue()));
}
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
class QuestKillObjective implements IQuestObjective {
private final QuestKill parent;
private final EntityPlayer player;
private final String entity;
private final int amount;
public QuestKillObjective(QuestKill parent, EntityPlayer player, String entity, int amount) {
this.parent = parent;
this.player = player;
this.entity = entity;
this.amount = amount;
}
public int getProgress() {
PlayerData data = PlayerData.get(this.player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
}
public void setProgress(int progress) {
if (progress >= 0 && progress <= this.amount) {
PlayerData data = PlayerData.get(this.player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
killed.put(this.entity, progress);
this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[4]);
data.saveNBTData(data.getNBT());
}
} else {
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
}
}
public int getMaxProgress() {
return this.amount;
}
public boolean isCompleted() {
return this.getProgress() >= this.amount;
}
public String getText() {
return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress();
}
}
}
@@ -1,13 +1,19 @@
package noppes.npcs.quests;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestLocation extends QuestInterface{
public String location = "";
@@ -95,4 +101,67 @@ public class QuestLocation extends QuestInterface{
return false;
}
public IQuestObjective[] getObjectives(EntityPlayer player) {
List<IQuestObjective> list = new ArrayList();
if (!this.location.isEmpty()) {
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location, "LocationFound"));
}
if (!this.location2.isEmpty()) {
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location2, "Location2Found"));
}
if (!this.location3.isEmpty()) {
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location3, "Location3Found"));
}
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
class QuestLocationObjective implements IQuestObjective {
private final QuestLocation parent;
private final EntityPlayer player;
private final String location;
private final String nbtName;
public QuestLocationObjective(QuestLocation this$0, EntityPlayer player, String location, String nbtName) {
this.parent = this$0;
this.player = player;
this.location = location;
this.nbtName = nbtName;
}
public int getProgress() {
return this.isCompleted() ? 1 : 0;
}
public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) {
PlayerData data = PlayerData.get(this.player);
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
boolean completed = questData.extraData.getBoolean (this.nbtName);
if ((!completed || progress != 1) && (completed || progress != 0)) {
questData.extraData.setBoolean(this.nbtName, progress == 1);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[3]);
data.saveNBTData(data.getNBT());
}
} else {
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
}
}
public int getMaxProgress() {
return 1;
}
public boolean isCompleted() {
PlayerData data = PlayerData.get(this.player);
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
return questData.extraData.getBoolean(this.nbtName);
}
public String getText() {
return this.location + ": " + (this.isCompleted() ? "Found" : "Not Found");
}
}
}
@@ -30,6 +30,11 @@ public class ScriptBlock implements IBlock {
this.block = block;
this.pos = pos;
this.bPos = new ScriptBlockPos(pos);
this.setTile(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ()));
}
protected void setTile(TileEntity tile) {
this.tile = tile;
}
public IPos getPos() {
@@ -72,7 +77,7 @@ public class ScriptBlock implements IBlock {
}
public boolean isContainer() {
return this.tile != null && this.tile instanceof IInventory?((IInventory)this.tile).getSizeInventory() > 0:false;
return this.tile != null && this.tile instanceof IInventory && ((IInventory) this.tile).getSizeInventory() > 0;
}
public IContainer getContainer() {
@@ -10,6 +10,7 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.IItemStack;
@@ -82,4 +83,8 @@ public class ScriptContainer implements IContainer {
return items;
}
public boolean isCustomGUI() {
return this.container instanceof ContainerCustomGui;
}
}
@@ -112,6 +112,8 @@ public class ScriptItemStack implements IItemStack {
* @return Returns whether or not the key exists
*/
public boolean hasTag(String key){
if(item.stackTagCompound == null)
return false;
return getTag().hasKey(key);
}
@@ -120,6 +122,9 @@ public class ScriptItemStack implements IItemStack {
* @return Returns the value associated with the key. Returns null of it doesnt exist
*/
public Object getTag(String key){
if(item.stackTagCompound == null)
return null;
NBTBase tag = getTag().getTag(key);
if(tag == null)
return null;
@@ -129,6 +134,12 @@ public class ScriptItemStack implements IItemStack {
return ((NBTTagString)tag).func_150285_a_();
return tag;
}
public INbt removeTags() {
ScriptNbt nbt = (ScriptNbt)NpcAPI.Instance().getINbt(item.stackTagCompound);
item.stackTagCompound = null;
return nbt;
}
public boolean isEnchanted(){
return item.isItemEnchanted();
@@ -475,7 +475,20 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level);
}
public int getFormLevel(){
return Integer.parseInt(player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX").replace("TR",""));
String formString = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX");
if(formString.length() < 1)
return 0;
StringBuilder digitString = new StringBuilder();
for(char c : formString.toCharArray()){
if(Character.isDigit(c))
digitString.append(c);
}
if(digitString.length() < 1)
return 0;
return Integer.parseInt(digitString.toString());
}
public void setSkills(String skills){
@@ -18,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.DamageSource;
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;
@@ -27,6 +28,7 @@ import noppes.npcs.scripted.*;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.IEntity;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IPos;
public class ScriptEntity<T extends Entity> implements IEntity {
protected T entity;
@@ -101,7 +103,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param x The entities x position
*/
public void setX(double x){
entity.posX = x;
entity.setPosition(x, entity.posY, entity.posZ);;
}
/**
@@ -115,7 +117,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param y The entities y position
*/
public void setY(double y){
entity.posY = y;
entity.setPosition(entity.posX, y, entity.posZ);
}
/**
@@ -129,7 +131,52 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param z The entities x position
*/
public void setZ(double z){
entity.posZ = z;
entity.setPosition(entity.posX, entity.posY, z);;
}
/**
* @return The entities z motion
*/
public double getMotionX(){
return entity.motionX;
}
/**
* @param x The entities x motion
*/
public void setMotionX(double x){
entity.motionX = x;
entity.velocityChanged = true;
}
/**
* @return The entities x motion
*/
public double getMotionY(){
return entity.motionY;
}
/**
* @param y The entities y motion
*/
public void setMotionY(double y){
entity.motionY = y;
entity.velocityChanged = true;
}
/**
* @return The entities y motion
*/
public double getMotionZ(){
return entity.motionZ;
}
/**
* @param z The entities z motion
*/
public void setMotionZ(double z){
entity.motionZ = z;
entity.velocityChanged = true;
}
/**
@@ -162,6 +209,13 @@ public class ScriptEntity<T extends Entity> implements IEntity {
entity.setPosition(x, y, z);
}
public IPos getPos() {
return new ScriptBlockPos(new BlockPos(entity.posX,entity.posY,entity.posZ));
}
public void setPos(IPos pos) {
this.entity.setPosition((double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F));
}
/**
* @param range The search range for entities around this entity
@@ -2,10 +2,7 @@ package noppes.npcs.scripted.entity;
import net.minecraft.item.ItemStack;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumNavType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.*;
import noppes.npcs.controllers.Line;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -90,6 +87,17 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.ai.orientation = (int)rotation;
super.setRotation(rotation);
}
public void setRotationType(int rotationType){
for (EnumStandingType e : EnumStandingType.values()) {
if (e.ordinal() == rotationType) {
npc.ai.standingType = e;
break;
}
}
}
public int getRotationType(){
return npc.ai.standingType.ordinal();
}
/**
* @param name The name of the npc
*/
@@ -303,6 +311,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return new ScriptRoleTransporter(npc);
return new ScriptRoleInterface(npc);
}
public void setRole(int role){
for (EnumRoleType e : EnumRoleType.values()) {
if (e.ordinal() == role) {
npc.advanced.role = e;
break;
}
}
}
/**
* @return Returns the npcs current job
@@ -326,6 +342,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return new ScriptJobSpawner(npc);
return new ScriptJobInterface(npc);
}
public void setJob(int job){
for (EnumJobType e : EnumJobType.values()) {
if (e.ordinal() == job) {
npc.advanced.job = e;
break;
}
}
}
/**
* @return The item held in the right hand
@@ -398,6 +422,55 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.stats.aimWhileShooting = aimWhileShooting;
}
public void setMinProjectileDelay(int minDelay){
npc.stats.minDelay = minDelay;
}
public int getMinProjectileDelay(){
return npc.stats.minDelay;
}
public void setMaxProjectileDelay(int maxDelay){
npc.stats.maxDelay = maxDelay;
}
public int getMaxProjectileDelay(){
return npc.stats.maxDelay;
}
public void setRangedRage(int rangedRange) {
npc.stats.rangedRange = rangedRange;
}
public int getRangedRage() {
return npc.stats.rangedRange;
}
public void setFireRate(int rate) {
npc.stats.fireRate = rate;
}
public int getFireRate() {
return npc.stats.fireRate;
}
public void setBurstCount(int burstCount) {
npc.stats.burstCount = burstCount;
}
public int getBurstCount() {
return npc.stats.burstCount;
}
public void setShotCount(int shotCount) {
npc.stats.shotCount = shotCount;
}
public int getShotCount() {
return npc.stats.shotCount;
}
public void setAccuracy(int accuracy) {
npc.stats.accuracy = accuracy;
}
public int getAccuracy() {
return npc.stats.accuracy;
}
public String getFireSound() {
return npc.stats.fireSound;
}
@@ -967,6 +1040,23 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc.ai.flyGravity;
}
public void setFlyHeightLimit(int flyHeightLimit){
if(flyHeightLimit < 0)
flyHeightLimit = 0;
this.npc.ai.flyHeightLimit = flyHeightLimit;
}
public int getFlyHeightLimit(int flyHeightLimit){
return this.npc.ai.flyHeightLimit;
}
public void limitFlyHeight(boolean limit){
this.npc.ai.hasFlyLimit = limit;
}
public boolean isFlyHeightLimited(boolean limit){
return this.npc.ai.hasFlyLimit;
}
public void setSpeed(int speed) {
npc.ai.setWalkingSpeed(speed);
}
@@ -1014,4 +1104,6 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public String getOverlayTexture() {
return npc.display.glowTexture;
}
public void updateClient() { this.npc.updateClient(); };
}
@@ -4,40 +4,42 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.WorldSettings;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.Server;
import noppes.npcs.*;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerDialogData;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.event.FactionEvent;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
public T player;
private PlayerData data;
public ScriptPlayer(T player){
super(player);
this.player = player;
@@ -83,6 +85,14 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
return data.activeQuests.containsKey(id);
}
public void showDialog(int id){
Dialog dialog = (Dialog) DialogController.instance.get(id);
if(dialog == null)
return;
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog);
}
public boolean hasReadDialog(int id){
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
@@ -158,7 +168,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
*/
public void addFactionPoints(int faction, int points){
PlayerData data = PlayerDataController.instance.getPlayerData(player);
data.factionData.increasePoints(faction, points);
data.factionData.increasePoints(faction, points, player);
}
/**
@@ -388,6 +398,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
return data.getGUIOpen();
}
public void checkQuestCompleted() {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
for(EnumQuestType e : EnumQuestType.values())
playerdata.checkQuestCompletion((EntityPlayer)this.entity, e);
}
public ScriptDBCPlayer<T> getDBCPlayer() {
Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c();
Iterator iterator = keySet.iterator();
@@ -404,4 +420,61 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
public boolean blocking() {
return player.isBlocking();
}
private PlayerData getData() {
if (this.data == null) {
this.data = PlayerDataController.instance.getPlayerData(player);
}
return this.data;
}
public IQuest[] getActiveQuests() {
PlayerQuestData data = this.getData().questData;
List<IQuest> quests = new ArrayList();
Iterator var3 = data.activeQuests.keySet().iterator();
while(var3.hasNext()) {
int id = (Integer)var3.next();
IQuest quest = (IQuest)QuestController.instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
return (IQuest[])quests.toArray(new IQuest[quests.size()]);
}
public IContainer getOpenContainer() {
return NpcAPI.Instance().getIContainer(((EntityPlayerMP)this.entity).openContainer);
}
public void showCustomGui(ICustomGui gui) {
CustomGuiController.openGui(this, (ScriptGui) gui);
}
public ICustomGui getCustomGui() {
return ((EntityPlayerMP)this.entity).openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)((EntityPlayerMP)this.entity).openContainer).customGui : null;
}
public void closeGui() {
((EntityPlayerMP)this.entity).closeContainer();
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, new Object[]{-1, new NBTTagCompound()});
}
public IQuest[] getFinishedQuests() {
PlayerQuestData data = this.getData().questData;
List<IQuest> quests = new ArrayList();
Iterator var3 = data.finishedQuests.keySet().iterator();
while(var3.hasNext()) {
int id = (Integer)var3.next();
IQuest quest = (IQuest)QuestController.instance.quests.get(id);
if (quest != null) {
quests.add(quest);
}
}
return (IQuest[])quests.toArray(new IQuest[quests.size()]);
}
}
@@ -0,0 +1,57 @@
package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IPlayer;
public class CustomGuiEvent extends Event {
public final IPlayer player;
public final ICustomGui gui;
public CustomGuiEvent(IPlayer player, ICustomGui gui) {
this.player = player;
this.gui = gui;
}
public static class ButtonEvent extends CustomGuiEvent {
public final int buttonId;
public ButtonEvent(IPlayer player, ICustomGui gui, int buttonId) {
super(player, gui);
this.buttonId = buttonId;
}
}
public static class CloseEvent extends CustomGuiEvent {
public CloseEvent(IPlayer player, ICustomGui gui) {
super(player, gui);
}
}
public static class ScrollEvent extends CustomGuiEvent {
public final int scrollId;
public final String[] selection;
public final boolean doubleClick;
public final int scrollIndex;
public ScrollEvent(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
super(player, gui);
this.scrollId = scrollId;
this.selection = selection;
this.doubleClick = doubleClick;
this.scrollIndex = scrollIndex;
}
}
public static class SlotEvent extends CustomGuiEvent {
public final int slotId;
public final IItemStack stack;
public SlotEvent(IPlayer player, ICustomGui gui, int slotId, IItemStack stack) {
super(player, gui);
this.slotId = slotId;
this.stack = stack;
}
}
}
@@ -0,0 +1,32 @@
package noppes.npcs.scripted.event;
import noppes.npcs.scripted.handler.data.IDialog;
import noppes.npcs.scripted.interfaces.IPlayer;
public class DialogEvent extends CustomNPCsEvent {
public final IDialog dialog;
public final IPlayer player;
public DialogEvent(IPlayer player, IDialog dialog){
this.dialog = dialog;
this.player = player;
}
public static class DialogOpen extends DialogEvent {
public DialogOpen(IPlayer player, IDialog dialog) {
super(player, dialog);
}
}
public static class DialogOption extends DialogEvent {
public DialogOption(IPlayer player, IDialog dialog) {
super(player, dialog);
}
}
public static class DialogClosed extends DialogEvent {
public DialogClosed(IPlayer player, IDialog dialog){
super(player, dialog);
}
}
}
@@ -0,0 +1,25 @@
package noppes.npcs.scripted.event;
import noppes.npcs.scripted.handler.data.IFaction;
import noppes.npcs.scripted.interfaces.IPlayer;
public class FactionEvent extends CustomNPCsEvent {
public final IFaction faction;
public final IPlayer player;
public FactionEvent(IPlayer player, IFaction faction){
this.faction = faction;
this.player = player;
}
public static class FactionPoints extends FactionEvent {
public boolean decrease;
public int points;
public FactionPoints(IPlayer player, IFaction faction, boolean decrease, int points) {
super(player, faction);
this.decrease = decrease;
this.points = points;
}
}
}
@@ -0,0 +1,40 @@
package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IPlayer;
public class QuestEvent extends CustomNPCsEvent {
public final IQuest quest;
public final IPlayer player;
public QuestEvent(IPlayer player, IQuest quest) {
this.quest = quest;
this.player = player;
}
public static class QuestCompletedEvent extends QuestEvent {
public QuestCompletedEvent(IPlayer player, IQuest quest) {
super(player, quest);
}
}
@Cancelable
public static class QuestStartEvent extends QuestEvent {
public QuestStartEvent(IPlayer player, IQuest quest) {
super(player, quest);
}
}
public static class QuestTurnedInEvent extends QuestEvent {
public int expReward;
public IItemStack[] itemRewards = new IItemStack[0];
public QuestTurnedInEvent(IPlayer player, IQuest quest) {
super(player, quest);
this.expReward = 0;
}
}
}
@@ -0,0 +1,298 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.gui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.IButton;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.IItemSlot;
import noppes.npcs.scripted.interfaces.ILabel;
import noppes.npcs.scripted.interfaces.IScroll;
import noppes.npcs.scripted.interfaces.ITextField;
import noppes.npcs.scripted.interfaces.ITexturedRect;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.scripted.interfaces.ICustomGui;
public class ScriptGui implements ICustomGui {
int id;
int width;
int height;
int playerInvX;
int playerInvY;
boolean pauseGame;
boolean showPlayerInv;
String backgroundTexture = "";
//ScriptContainer scriptHandler;
List<ICustomGuiComponent> components = new ArrayList();
List<IItemSlot> slots = new ArrayList();
public ScriptGui() {
}
public ScriptGui(int id, int width, int height, boolean pauseGame) {
this.id = id;
this.width = width;
this.height = height;
this.pauseGame = pauseGame;
//this.scriptHandler = ScriptContainer.Current;
}
public int getID() {
return this.id;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public List<ICustomGuiComponent> getComponents() {
return this.components;
}
public List<IItemSlot> getSlots() {
return this.slots;
}
public PlayerDataScript getScriptHandler() {
return ScriptController.Instance.playerScripts;//this.scriptHandler;
}
public void setSize(int width, int height) {
this.width = width;
this.height = height;
}
public void setDoesPauseGame(boolean pauseGame) {
this.pauseGame = pauseGame;
}
public boolean getDoesPauseGame() {
return this.pauseGame;
}
public void setBackgroundTexture(String resourceLocation) {
this.backgroundTexture = resourceLocation;
}
public String getBackgroundTexture() {
return this.backgroundTexture;
}
public IButton addButton(int id, String label, int x, int y) {
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y);
this.components.add(component);
return (IButton)this.components.get(this.components.size() - 1);
}
public IButton addButton(int id, String label, int x, int y, int width, int height) {
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height);
this.components.add(component);
return (IButton)this.components.get(this.components.size() - 1);
}
public IButton addTexturedButton(int id, String label, int x, int y, int width, int height, String texture) {
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height, texture);
this.components.add(component);
return (IButton)this.components.get(this.components.size() - 1);
}
public IButton addTexturedButton(int id, String label, int x, int y, int width, int height, String texture, int textureX, int textureY) {
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height, texture, textureX, textureY);
this.components.add(component);
return (IButton)this.components.get(this.components.size() - 1);
}
public ILabel addLabel(int id, String label, int x, int y, int width, int height) {
ScriptGuiLabel component = new ScriptGuiLabel(id, label, x, y, width, height);
this.components.add(component);
return (ILabel)this.components.get(this.components.size() - 1);
}
public ILabel addLabel(int id, String label, int x, int y, int width, int height, int color) {
ScriptGuiLabel component = new ScriptGuiLabel(id, label, x, y, width, height, color);
this.components.add(component);
return (ILabel)this.components.get(this.components.size() - 1);
}
public ITextField addTextField(int id, int x, int y, int width, int height) {
ScriptGuiTextField component = new ScriptGuiTextField(id, x, y, width, height);
this.components.add(component);
return (ITextField)this.components.get(this.components.size() - 1);
}
public ITexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(id, texture, x, y, width, height);
this.components.add(component);
return (ITexturedRect)this.components.get(this.components.size() - 1);
}
public ITexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(id, texture, x, y, width, height, textureX, textureY);
this.components.add(component);
return (ITexturedRect)this.components.get(this.components.size() - 1);
}
public IItemSlot addItemSlot(int x, int y) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
public IItemSlot addItemSlot(int x, int y, IItemStack stack) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y, stack);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
public IScroll addScroll(int id, int x, int y, int width, int height, String[] list) {
ScriptGuiScroll component = new ScriptGuiScroll(id, x, y, width, height, list);
this.components.add(component);
return (IScroll)this.components.get(this.components.size() - 1);
}
public void showPlayerInventory(int x, int y) {
this.showPlayerInv = true;
this.playerInvX = x;
this.playerInvY = y;
}
public ICustomGuiComponent getComponent(int componentID) {
Iterator var2 = this.components.iterator();
ICustomGuiComponent component;
do {
if (!var2.hasNext()) {
return null;
}
component = (ICustomGuiComponent)var2.next();
} while(component.getID() != componentID);
return component;
}
public void removeComponent(int componentID) {
for(int i = 0; i < this.components.size(); ++i) {
if (((ICustomGuiComponent)this.components.get(i)).getID() == componentID) {
this.components.remove(i);
return;
}
}
}
public void updateComponent(ICustomGuiComponent component) {
for(int i = 0; i < this.components.size(); ++i) {
ICustomGuiComponent c = (ICustomGuiComponent)this.components.get(i);
if (c.getID() == component.getID()) {
this.components.set(i, component);
return;
}
}
}
public void update(IPlayer player) {
CustomGuiController.updateGui((ScriptPlayer)player, this);
}
public boolean getShowPlayerInv() {
return this.showPlayerInv;
}
public int getPlayerInvX() {
return this.playerInvX;
}
public int getPlayerInvY() {
return this.playerInvY;
}
public ICustomGui fromNBT(NBTTagCompound tag) {
this.id = tag.getInteger("id");
this.width = tag.getIntArray("size")[0];
this.height = tag.getIntArray("size")[1];
this.pauseGame = tag.getBoolean("pause");
this.backgroundTexture = tag.getString("bgTexture");
List<ICustomGuiComponent> components = new ArrayList();
NBTTagList list = tag.getTagList("components", 10);
for(int i = 0; i < list.tagCount(); i++){
NBTBase b = list.getCompoundTagAt(i);
ScriptGuiComponent component = ScriptGuiComponent.createFromNBT((NBTTagCompound)b);
components.add(component);
}
this.components = components;
List<IItemSlot> slots = new ArrayList();
list = tag.getTagList("slots", 10);
for(int i = 0; i < list.tagCount(); i++){
NBTBase b = list.getCompoundTagAt(i);
ScriptGuiItemSlot component = (ScriptGuiItemSlot)ScriptGuiComponent.createFromNBT((NBTTagCompound)b);
slots.add(component);
}
this.slots = slots;
this.showPlayerInv = tag.getBoolean("showPlayerInv");
if (this.showPlayerInv) {
this.playerInvX = tag.getIntArray("pInvPos")[0];
this.playerInvY = tag.getIntArray("pInvPos")[1];
}
return this;
}
public NBTTagCompound toNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("id", this.id);
tag.setIntArray("size", new int[]{this.width, this.height});
tag.setBoolean("pause", this.pauseGame);
tag.setString("bgTexture", this.backgroundTexture);
NBTTagList list = new NBTTagList();
Iterator var3 = this.components.iterator();
ICustomGuiComponent c;
while(var3.hasNext()) {
c = (ICustomGuiComponent)var3.next();
list.appendTag(((ScriptGuiComponent)c).toNBT(new NBTTagCompound()));
}
tag.setTag("components", list);
list = new NBTTagList();
var3 = this.slots.iterator();
while(var3.hasNext()) {
c = (ICustomGuiComponent)var3.next();
list.appendTag(((ScriptGuiComponent)c).toNBT(new NBTTagCompound()));
}
tag.setTag("slots", list);
tag.setBoolean("showPlayerInv", this.showPlayerInv);
if (this.showPlayerInv) {
tag.setIntArray("pInvPos", new int[]{this.playerInvX, this.playerInvY});
}
return tag;
}
}
@@ -0,0 +1,149 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.interfaces.IButton;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
public class ScriptGuiButton extends ScriptGuiComponent implements IButton {
int width;
int height;
String label;
String texture;
int textureX;
int textureY;
public ScriptGuiButton() {
this.height = -1;
this.textureY = -1;
}
public ScriptGuiButton(int id, String label, int x, int y) {
this.height = -1;
this.textureY = -1;
this.setID(id);
this.setLabel(label);
this.setPos(x, y);
}
public ScriptGuiButton(int id, String label, int x, int y, int width, int height) {
this(id, label, x, y);
this.setSize(width, height);
}
public ScriptGuiButton(int id, String label, int x, int y, int width, int height, String texture) {
this(id, label, x, y, width, height);
this.setTexture(texture);
}
public ScriptGuiButton(int id, String label, int x, int y, int width, int height, String texture, int textureX, int textureY) {
this(id, label, x, y, width, height, texture);
this.setTextureOffset(textureX, textureY);
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public IButton setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public String getLabel() {
return this.label;
}
public IButton setLabel(String label) {
this.label = label;
return this;
}
public String getTexture() {
return this.texture;
}
public boolean hasTexture() {
return this.texture != null;
}
public IButton setTexture(String texture) {
this.texture = texture;
return this;
}
public int getTextureX() {
return this.textureX;
}
public int getTextureY() {
return this.textureY;
}
public IButton setTextureOffset(int textureX, int textureY) {
this.textureX = textureX;
this.textureY = textureY;
return this;
}
public int getID() {
return this.id;
}
public ICustomGuiComponent setID(int id) {
this.id = id;
return this;
}
public int getPosX() {
return this.posX;
}
public int getPosY() {
return this.posY;
}
public int getType() {
return 0;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
if (this.width > 0 && this.height > 0) {
nbt.setIntArray("size", new int[]{this.width, this.height});
}
nbt.setString("label", this.label);
if (this.hasTexture()) {
nbt.setString("texture", this.texture);
}
if (this.textureX >= 0 && this.textureY >= 0) {
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
}
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
if (nbt.hasKey("size")) {
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
}
this.setLabel(nbt.getString("label"));
if (nbt.hasKey("texture")) {
this.setTexture(nbt.getString("texture"));
}
if (nbt.hasKey("texPos")) {
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
}
return this;
}
}
@@ -0,0 +1,119 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
public abstract class ScriptGuiComponent implements ICustomGuiComponent {
int id;
int posX;
int posY;
String[] hoverText;
public ScriptGuiComponent() {
}
public int getID() {
return this.id;
}
public ICustomGuiComponent setID(int id) {
this.id = id;
return this;
}
public int getPosX() {
return this.posX;
}
public int getPosY() {
return this.posY;
}
public ICustomGuiComponent setPos(int x, int y) {
this.posX = x;
this.posY = y;
return this;
}
public boolean hasHoverText() {
return this.hoverText != null && this.hoverText.length > 0;
}
public String[] getHoverText() {
return this.hoverText;
}
public ICustomGuiComponent setHoverText(String text) {
this.hoverText = new String[]{text};
return this;
}
public ICustomGuiComponent setHoverText(String[] text) {
this.hoverText = text;
return this;
}
public abstract int getType();
public NBTTagCompound toNBT(NBTTagCompound nbt) {
nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
if (this.hoverText != null) {
NBTTagList list = new NBTTagList();
String[] var3 = this.hoverText;
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
String s = var3[var5];
if (s != null && !s.isEmpty()) {
list.appendTag(new NBTTagString(s));
}
}
if (list.tagCount() > 0) {
nbt.setTag("hover", list);
}
}
nbt.setInteger("type", this.getType());
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
this.setID(nbt.getInteger("id"));
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]);
if (nbt.hasKey("hover")) {
NBTTagList list = nbt.getTagList("hover", 8);
String[] hoverText = new String[list.tagCount()];
for(int i = 0; i < list.tagCount(); ++i) {
hoverText[i] = list.getStringTagAt(i);
}
this.setHoverText(hoverText);
}
return this;
}
public static ScriptGuiComponent createFromNBT(NBTTagCompound nbt) {
switch(nbt.getInteger("type")) {
case 0:
return (new ScriptGuiButton()).fromNBT(nbt);
case 1:
return (new ScriptGuiLabel()).fromNBT(nbt);
case 2:
return (new ScriptGuiTexturedRect()).fromNBT(nbt);
case 3:
return (new ScriptGuiTextField()).fromNBT(nbt);
case 4:
return (new ScriptGuiScroll()).fromNBT(nbt);
case 5:
return (new ScriptGuiItemSlot()).fromNBT(nbt);
default:
return null;
}
}
}
@@ -0,0 +1,63 @@
package noppes.npcs.scripted.gui;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IItemSlot;
import noppes.npcs.scripted.interfaces.IItemStack;
public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot {
IItemStack stack;
public ScriptGuiItemSlot() {
}
public ScriptGuiItemSlot(int x, int y) {
this.setPos(x, y);
}
public ScriptGuiItemSlot(int x, int y, IItemStack stack) {
this(x, y);
this.setStack(stack);
}
public boolean hasStack() {
return this.stack != null && this.stack.getStackSize() > 0;
}
public IItemStack getStack() {
return this.stack;
}
public IItemSlot setStack(IItemStack itemStack) {
this.stack = itemStack;
return this;
}
public Slot getMCSlot() {
return null;
}
public int getType() {
return 5;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
if (this.hasStack()) {
nbt.setTag("stack", this.stack.getItemNbt().getMCNBT());
}
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
if (nbt.hasKey("stack")) {
this.setStack(NpcAPI.Instance().getIItemStack(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"))));
}
return this;
}
}
@@ -0,0 +1,94 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.interfaces.ILabel;
public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
String label;
int width;
int height;
int color;
float scale;
public ScriptGuiLabel() {
this.color = 16777215;
this.scale = 1.0F;
}
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) {
this.color = 16777215;
this.scale = 1.0F;
this.setID(id);
this.setText(label);
this.setPos(x, y);
this.setSize(width, height);
}
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) {
this(id, label, x, y, width, height);
this.setColor(color);
}
public String getText() {
return this.label;
}
public ILabel setText(String label) {
this.label = label;
return this;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public ILabel setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public int getColor() {
return this.color;
}
public ILabel setColor(int color) {
this.color = color;
return this;
}
public float getScale() {
return this.scale;
}
public ILabel setScale(float scale) {
this.scale = scale;
return this;
}
public int getType() {
return 1;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setInteger("color", this.color);
nbt.setFloat("scale", this.scale);
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setText(nbt.getString("label"));
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setColor(nbt.getInteger("color"));
this.setScale(nbt.getFloat("scale"));
return this;
}
}
@@ -0,0 +1,109 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.scripted.interfaces.IScroll;
public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll {
int width;
int height;
int defaultSelection = -1;
String[] list;
boolean multiSelect = false;
public ScriptGuiScroll() {
}
public ScriptGuiScroll(int id, int x, int y, int width, int height, String[] list) {
this.setID(id);
this.setPos(x, y);
this.setSize(width, height);
this.setList(list);
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public IScroll setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public String[] getList() {
return this.list;
}
public IScroll setList(String[] list) {
this.list = list;
return this;
}
public int getDefaultSelection() {
return this.defaultSelection;
}
public IScroll setDefaultSelection(int defaultSelection) {
this.defaultSelection = defaultSelection;
return this;
}
public boolean isMultiSelect() {
return this.multiSelect;
}
public IScroll setMultiSelect(boolean multiSelect) {
this.multiSelect = multiSelect;
return this;
}
public int getType() {
return 4;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setIntArray("size", new int[]{this.width, this.height});
if (this.defaultSelection >= 0) {
nbt.setInteger("default", this.defaultSelection);
}
NBTTagList list = new NBTTagList();
String[] var3 = this.list;
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
String s = var3[var5];
list.appendTag(new NBTTagString(s));
}
nbt.setTag("list", list);
nbt.setBoolean("multiSelect", this.multiSelect);
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
if (nbt.hasKey("default")) {
this.setDefaultSelection(nbt.getInteger("default"));
}
NBTTagList tagList = nbt.getTagList("list", 8);
String[] list = new String[tagList.tagCount()];
for(int i = 0; i < tagList.tagCount(); ++i) {
list[i] = tagList.getStringTagAt(i);
}
this.setList(list);
this.setMultiSelect(nbt.getBoolean("multiSelect"));
return this;
}
}
@@ -0,0 +1,66 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.interfaces.ITextField;
public class ScriptGuiTextField extends ScriptGuiComponent implements ITextField {
int width;
int height;
String defaultText;
public ScriptGuiTextField() {
}
public ScriptGuiTextField(int id, int x, int y, int width, int height) {
this.setID(id);
this.setPos(x, y);
this.setSize(width, height);
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public ITextField setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public String getText() {
return this.defaultText;
}
public ITextField setText(String defaultText) {
this.defaultText = defaultText;
return this;
}
public int getType() {
return 3;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setIntArray("size", new int[]{this.width, this.height});
if (this.defaultText != null && !this.defaultText.isEmpty()) {
nbt.setString("default", this.defaultText);
}
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
if (nbt.hasKey("default")) {
this.setText(nbt.getString("default"));
}
return this;
}
}
@@ -0,0 +1,107 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.scripted.interfaces.ITexturedRect;
public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect {
int width;
int height;
int textureX;
int textureY;
float scale;
String texture;
public ScriptGuiTexturedRect() {
this.textureY = -1;
this.scale = 1.0F;
}
public ScriptGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this.textureY = -1;
this.scale = 1.0F;
this.setID(id);
this.setTexture(texture);
this.setPos(GuiCustom.guiLeft + x, GuiCustom.guiTop + y);
this.setSize(width, height);
}
public ScriptGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this(id, texture, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
this.setTextureOffset(textureX, textureY);
}
public String getTexture() {
return this.texture;
}
public ITexturedRect setTexture(String texture) {
this.texture = texture;
return this;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public ITexturedRect setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public float getScale() {
return this.scale;
}
public ITexturedRect setScale(float scale) {
this.scale = scale;
return this;
}
public int getTextureX() {
return this.textureX;
}
public int getTextureY() {
return this.textureY;
}
public ITexturedRect setTextureOffset(int offsetX, int offsetY) {
this.textureX = offsetX;
this.textureY = offsetY;
return this;
}
public int getType() {
return 2;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setFloat("scale", this.scale);
nbt.setString("texture", this.texture);
if (this.textureX >= 0 && this.textureY >= 0) {
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
}
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setScale(nbt.getFloat("scale"));
this.setTexture(nbt.getString("texture"));
if (nbt.hasKey("texPos")) {
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
}
return this;
}
}
@@ -0,0 +1,19 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.IEntity;
public interface ICloneHandler {
IEntity spawn(double var1, double var3, double var5, int var7, String var8, IWorld var9);
IEntity get(int var1, String var2, IWorld var3);
void set(int var1, String var2, IEntity var3);
void remove(int var1, String var2);
}
@@ -0,0 +1,17 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler;
import noppes.npcs.scripted.handler.data.IDialog;
import noppes.npcs.scripted.handler.data.IDialogCategory;
import java.util.List;
public interface IDialogHandler {
List<IDialogCategory> categories();
IDialog get(int var1);
}
@@ -0,0 +1,20 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler;
import noppes.npcs.scripted.handler.data.IFaction;
import java.util.List;
public interface IFactionHandler {
List<IFaction> list();
IFaction delete(int var1);
IFaction create(String var1, int var2);
IFaction get(int var1);
}
@@ -0,0 +1,17 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory;
import java.util.List;
public interface IQuestHandler {
List<IQuestCategory> categories();
IQuest get(int var1);
}
@@ -0,0 +1,22 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler;
import java.util.List;
import net.minecraft.item.ItemStack;
import noppes.npcs.scripted.handler.data.IRecipe;
public interface IRecipeHandler {
List<IRecipe> getGlobalList();
List<IRecipe> getCarpentryList();
void addRecipe(String var1, boolean var2, ItemStack var3, Object... var4);
void addRecipe(String var1, boolean var2, ItemStack var3, int var4, int var5, ItemStack... var6);
IRecipe delete(int var1);
}
@@ -0,0 +1,36 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import noppes.npcs.scripted.interfaces.IPlayer;
public interface IAvailability {
boolean isAvailable(IPlayer var1);
int getDaytime();
void setDaytime(int var1);
int getMinPlayerLevel();
void setMinPlayerLevel(int var1);
int getDialog(int var1);
void setDialog(int var1, int var2, int var3);
void removeDialog(int var1);
int getQuest(int var1);
void setQuest(int var1, int var2, int var3);
void removeQuest(int var1);
void setFaction(int var1, int var2, int var3, int var4);
void removeFaction(int var1);
}
@@ -0,0 +1,38 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import java.util.List;
public interface IDialog {
int getId();
String getName();
void setName(String var1);
String getText();
void setText(String var1);
IQuest getQuest();
void setQuest(IQuest var1);
String getCommand();
void setCommand(String var1);
List<IDialogOption> getOptions();
IDialogOption getOption(int var1);
IAvailability getAvailability();
IDialogCategory getCategory();
void save();
}
@@ -0,0 +1,16 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import java.util.List;
public interface IDialogCategory {
List<IDialog> dialogs();
String getName();
IDialog create();
}
@@ -0,0 +1,14 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
public interface IDialogOption {
int getSlot();
String getName();
int getType();
}
@@ -0,0 +1,45 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import noppes.npcs.scripted.interfaces.ICustomNpc;
import noppes.npcs.scripted.interfaces.IPlayer;
public interface IFaction {
int getId();
String getName();
int getDefaultPoints();
void setDefaultPoints(int var1);
int getColor();
int playerStatus(IPlayer var1);
boolean hostileToNpc(ICustomNpc var1);
boolean hostileToFaction(int var1);
int[] getHostileList();
void addHostile(int var1);
void removeHostile(int var1);
boolean hasHostile(int var1);
boolean getIsHidden();
void setIsHidden(boolean var1);
boolean getAttackedByMobs();
void setAttackedByMobs(boolean var1);
void save();
}
@@ -0,0 +1,47 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.IPlayer;
public interface IQuest {
int getId();
String getName();
void setName(String var1);
int getType();
void setType(int var1);
String getLogText();
void setLogText(String var1);
String getCompleteText();
void setCompleteText(String var1);
IQuest getNextQuest();
void setNextQuest(IQuest var1);
IQuestObjective[] getObjectives(IPlayer var1);
IQuestCategory getCategory();
IContainer getRewards();
String getNpcName();
void setNpcName(String var1);
void save();
boolean getIsRepeatable();
}
@@ -0,0 +1,16 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import java.util.List;
public interface IQuestCategory {
List<IQuest> quests();
String getName();
IQuest create();
}
@@ -0,0 +1,18 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
public interface IQuestObjective {
int getProgress();
void setProgress(int var1);
int getMaxProgress();
boolean isCompleted();
String getText();
}
@@ -0,0 +1,36 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.handler.data;
import net.minecraft.item.ItemStack;
public interface IRecipe {
String getName();
boolean isGlobal();
void setIsGlobal(boolean var1);
boolean getIgnoreNBT();
void setIgnoreNBT(boolean var1);
boolean getIgnoreDamage();
void setIgnoreDamage(boolean var1);
int getWidth();
int getHeight();
ItemStack getResult();
ItemStack[] getRecipe();
void delete();
int getId();
}
@@ -0,0 +1,30 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface IButton extends ICustomGuiComponent {
int getWidth();
int getHeight();
IButton setSize(int var1, int var2);
String getLabel();
IButton setLabel(String var1);
String getTexture();
boolean hasTexture();
IButton setTexture(String var1);
int getTextureX();
int getTextureY();
IButton setTextureOffset(int var1, int var2);
}
@@ -22,4 +22,6 @@ public interface IContainer {
int count(IItemStack var1, boolean var2, boolean var3);
IItemStack[] getItems();
boolean isCustomGUI();
}
@@ -0,0 +1,60 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
import java.util.List;
public interface ICustomGui {
int getID();
int getWidth();
int getHeight();
List<ICustomGuiComponent> getComponents();
List<IItemSlot> getSlots();
void setSize(int var1, int var2);
void setDoesPauseGame(boolean var1);
void setBackgroundTexture(String var1);
IButton addButton(int var1, String var2, int var3, int var4);
IButton addButton(int var1, String var2, int var3, int var4, int var5, int var6);
IButton addTexturedButton(int var1, String var2, int var3, int var4, int var5, int var6, String var7);
IButton addTexturedButton(int var1, String var2, int var3, int var4, int var5, int var6, String var7, int var8, int var9);
ILabel addLabel(int var1, String var2, int var3, int var4, int var5, int var6);
ILabel addLabel(int var1, String var2, int var3, int var4, int var5, int var6, int var7);
ITextField addTextField(int var1, int var2, int var3, int var4, int var5);
ITexturedRect addTexturedRect(int var1, String var2, int var3, int var4, int var5, int var6);
ITexturedRect addTexturedRect(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8);
IScroll addScroll(int var1, int var2, int var3, int var4, int var5, String[] var6);
IItemSlot addItemSlot(int var1, int var2);
IItemSlot addItemSlot(int var1, int var2, IItemStack var3);
void showPlayerInventory(int var1, int var2);
ICustomGuiComponent getComponent(int var1);
void removeComponent(int var1);
void updateComponent(ICustomGuiComponent var1);
void update(IPlayer var1);
}
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more