Merge branch 'master' into dev

# Conflicts:
#	src/main/java/noppes/npcs/scripted/ScriptFaction.java
#	src/main/java/noppes/npcs/scripted/ScriptWorld.java
#	src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java
#	src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java
#	src/main/java/noppes/npcs/scripted/interfaces/IEntity.java
#	src/main/java/noppes/npcs/scripted/interfaces/IWorld.java
#	src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java
#	src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java
This commit is contained in:
Luis C.M committed 2022-05-27 15:31:02 -05:00
commit ec5fc71413
300 files changed
+9920 -2959

No files matched your search

+3 -4
View File
@@ -1,16 +1,15 @@
package foxz.command;
import java.util.Arrays;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.client.EntityUtil;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityDialogNpc;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
+3 -8
View File
@@ -2,19 +2,14 @@ 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 noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerFactionData;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly;
import foxz.commandhelper.permissions.ParamCheck;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.FactionEvent;
@Command(
name = "faction",
+1 -1
View File
@@ -25,7 +25,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
+3 -8
View File
@@ -1,20 +1,15 @@
package foxz.command;
import static foxz.utils.Utils.getOnlinePlayer;
import java.util.List;
import net.minecraft.command.PlayerSelector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.data.QuestData;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
@@ -20,7 +20,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
+1 -2
View File
@@ -12,8 +12,7 @@ import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
import cpw.mods.fml.common.network.IGuiHandler;
import noppes.npcs.scripted.interfaces.IWorld;
+5 -52
View File
@@ -72,55 +72,7 @@ import noppes.npcs.blocks.tiles.TileWallBanner;
import noppes.npcs.blocks.tiles.TileWaypoint;
import noppes.npcs.blocks.tiles.TileWeaponRack;
import noppes.npcs.constants.EnumNpcToolMaterial;
import noppes.npcs.items.ItemBattleAxe;
import noppes.npcs.items.ItemBroadSword;
import noppes.npcs.items.ItemBullet;
import noppes.npcs.items.ItemClaw;
import noppes.npcs.items.ItemCrossbow;
import noppes.npcs.items.ItemDagger;
import noppes.npcs.items.ItemDaggerReversed;
import noppes.npcs.items.ItemElementalStaff;
import noppes.npcs.items.ItemExcalibur;
import noppes.npcs.items.ItemGlaive;
import noppes.npcs.items.ItemGun;
import noppes.npcs.items.ItemGunChainsaw;
import noppes.npcs.items.ItemKunai;
import noppes.npcs.items.ItemKunaiReversed;
import noppes.npcs.items.ItemLeafBlade;
import noppes.npcs.items.ItemMachineGun;
import noppes.npcs.items.ItemMounter;
import noppes.npcs.items.ItemMusic;
import noppes.npcs.items.ItemMusicBanjo;
import noppes.npcs.items.ItemMusicClarinet;
import noppes.npcs.items.ItemMusicOracina;
import noppes.npcs.items.ItemMusicViolin;
import noppes.npcs.items.ItemMusket;
import noppes.npcs.items.ItemNpcArmor;
import noppes.npcs.items.ItemNpcArmorColorable;
import noppes.npcs.items.ItemNpcBlock;
import noppes.npcs.items.ItemNpcCloner;
import noppes.npcs.items.ItemNpcColored;
import noppes.npcs.items.ItemNpcInterface;
import noppes.npcs.items.ItemNpcMovingPath;
import noppes.npcs.items.ItemNpcScripter;
import noppes.npcs.items.ItemNpcWand;
import noppes.npcs.items.ItemNpcWeaponInterface;
import noppes.npcs.items.ItemOrb;
import noppes.npcs.items.ItemPlaceholder;
import noppes.npcs.items.ItemRotatedShield;
import noppes.npcs.items.ItemScythe;
import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSkirt;
import noppes.npcs.items.ItemSlingshot;
import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.items.ItemSoulstoneFilled;
import noppes.npcs.items.ItemSpear;
import noppes.npcs.items.ItemStaff;
import noppes.npcs.items.ItemTeleporter;
import noppes.npcs.items.ItemThrowingShuriken;
import noppes.npcs.items.ItemThrowingWeapon;
import noppes.npcs.items.ItemWand;
import noppes.npcs.items.ItemWarhammer;
import noppes.npcs.items.*;
import cpw.mods.fml.common.registry.GameRegistry;
public class CustomItems {
@@ -130,7 +82,8 @@ public class CustomItems {
public static Item scripter;
public static Item moving;
public static Item mount;
public static Item teleporter;
public static Item teleporter;
public static Item scripted_item;
public static Item soulstoneEmpty;
public static Item soulstoneFull;
@@ -300,8 +253,7 @@ public class CustomItems {
public static CreativeTabNpcs tabWeapon;
public static CreativeTabNpcs tabBlocks = new CreativeTabNpcs("cnpcsb");
public static CreativeTabNpcs tabMisc = new CreativeTabNpcs("cnpcsm");
public static void load(){
GameRegistry.registerTileEntity(TileRedstoneBlock.class, "TileRedstoneBlock");
GameRegistry.registerTileEntity(TileBlockAnvil.class, "TileBlockAnvil");
@@ -338,6 +290,7 @@ public class CustomItems {
moving = new ItemNpcMovingPath().setUnlocalizedName("npcMovingPath").setFull3D();
mount = new ItemMounter().setUnlocalizedName("npcMounter").setFull3D();
teleporter = new ItemTeleporter().setUnlocalizedName("npcTeleporter").setFull3D();
scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D();
redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab);
carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
+21 -3
View File
@@ -1,6 +1,5 @@
package noppes.npcs;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
@@ -27,7 +26,8 @@ import noppes.npcs.controllers.*;
import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.*;
import noppes.npcs.entity.old.*;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.scripted.NpcAPI;
import java.io.File;
import java.util.Set;
@@ -63,6 +63,15 @@ public class CustomNpcs {
@ConfigProp(info = "The amount of time that passes before a player's quests are checked for completion in seconds.")
public static int PlayerQuestCheck = 300;
@ConfigProp(info = "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8.")
public static int TrackingInfoAlignment = 5;
@ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the X direction.")
public static int TrackingInfoX = 0;
@ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the Y direction.")
public static int TrackingInfoY = 0;
@ConfigProp
public static boolean InventoryGuiEnabled = true;
@@ -165,6 +174,11 @@ public class CustomNpcs {
if(PlayerQuestCheck < 1)
PlayerQuestCheck = 1;
if (TrackingInfoAlignment < 0)
TrackingInfoAlignment = 0;
if (TrackingInfoAlignment > 8)
TrackingInfoAlignment = 8;
EnchantInterface.load();
CustomItems.load();
@@ -182,6 +196,10 @@ public class CustomNpcs {
MinecraftForge.EVENT_BUS.register(forgeEventHandler);
FMLCommonHandler.instance().bus().register(forgeEventHandler);
ScriptItemEventHandler scriptItemEventHandler = new ScriptItemEventHandler();
MinecraftForge.EVENT_BUS.register(scriptItemEventHandler);
FMLCommonHandler.instance().bus().register(scriptItemEventHandler);
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
@@ -253,7 +271,7 @@ public class CustomNpcs {
ScriptController.Instance.loadNPCScripts();
ScriptController.Instance.loadPlayerScripts();
ScriptController.HasStart = false;
WrapperNpcAPI.clearCache();
NpcAPI.clearCache();
Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){
+4 -4
View File
@@ -6,10 +6,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.FactionOptions;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.Lines;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.FactionOptions;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobBard;
import noppes.npcs.roles.JobChunkLoader;
+31 -10
View File
@@ -1,19 +1,16 @@
package noppes.npcs;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StringUtils;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataSkinOverlays;
import noppes.npcs.util.ValueUtil;
import com.google.common.collect.Iterables;
@@ -36,8 +33,12 @@ public class DataDisplay {
public GameProfile playerProfile;
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
public String cloakTexture = "";
public DataSkinOverlays skinOverlayData;
public long overlayRenderTicks = 0;
public String glowTexture = "";
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
public int modelSize = 5;
@@ -58,6 +59,7 @@ public class DataDisplay {
public DataDisplay(EntityNPCInterface npc){
this.npc = npc;
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
skinOverlayData = new DataSkinOverlays(npc);
name = getRandomName();
}
@@ -73,10 +75,12 @@ public class DataDisplay {
nbttagcompound.setString("SkinUrl", url);
nbttagcompound.setString("Texture", texture);
nbttagcompound.setString("CloakTexture", cloakTexture);
nbttagcompound.setString("GlowTexture", glowTexture);
nbttagcompound.setByte("UsingSkinUrl", skinType);
nbttagcompound.setString("GlowTexture", glowTexture);
if (this.playerProfile != null)
nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound);
if (this.playerProfile != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
@@ -131,7 +135,24 @@ public class DataDisplay {
texture = nbttagcompound.getString("Texture");
cloakTexture = nbttagcompound.getString("CloakTexture");
glowTexture = nbttagcompound.getString("GlowTexture");
if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", 0); //unique glow texture ID
(new SkinOverlay(glowTexture)).writeToNBT(nbttagcompound);
if (!nbttagcompound.hasKey("SkinOverlayData")) {
NBTTagList tagList = new NBTTagList();
tagList.appendTag(compound);
nbttagcompound.setTag("SkinOverlayData", tagList);
} else if (!glowTexture.isEmpty()) {
nbttagcompound.getTagList("SkinOverlayData", 10).appendTag(compound);
glowTexture = "";
}
}
skinOverlayData.readFromNBT(nbttagcompound);
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit;
+2 -2
View File
@@ -19,8 +19,8 @@ import noppes.npcs.entity.EntityNPCInterface;
public class DataInventory implements IInventory{
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public HashMap<Integer,Double> dropchance = new HashMap<Integer,Double>();
public HashMap<Integer, ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer, ItemStack> armor = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> armor = new HashMap<Integer, ItemStack>();
public int minExp = 0;
public int maxExp = 0;
+9 -8
View File
@@ -14,18 +14,16 @@ import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.ScriptEvent;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.event.ScriptEvent;
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.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.scripted.NpcAPI;
public class DataScript implements IScriptHandler {
public List<ScriptContainer> scripts = new ArrayList();
@@ -49,7 +47,10 @@ public class DataScript implements IScriptHandler {
}
this.npc = npc;
dummyNpc = new ScriptNpc<>(npc);
if (npc.wrappedNPC == null) {
npc.wrappedNPC = new ScriptNpc(this.npc);
}
dummyNpc = npc.wrappedNPC;
if(npc.worldObj instanceof WorldServer)
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
@@ -121,7 +122,7 @@ public class DataScript implements IScriptHandler {
for(int i = 0; i + 1 < obs.length; i += 2){
Object ob = obs[i + 1];
if(ob instanceof Entity)
ob = ScriptController.Instance.getScriptForEntity((Entity)ob);
ob = NpcAPI.Instance().getIEntity((Entity)ob);
script.engine.put(obs[i].toString(), ob);
}
@@ -135,7 +136,7 @@ public class DataScript implements IScriptHandler {
ScriptEvent result = (ScriptEvent) engine.get("event");
if(result == null)
engine.put("event", result = new ScriptEvent());
engine.put("API", new WrapperNpcAPI());
engine.put("API", new NpcAPI());
engine.put("EntityType", entities);
engine.put("RoleType", roles);
engine.put("JobType", jobs);
+173 -108
View File
@@ -20,13 +20,8 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
@@ -36,11 +31,13 @@ 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;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
import noppes.npcs.scripted.interfaces.item.IItemCustom;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.constants.EnumScriptType;
import org.apache.commons.lang3.StringUtils;
@@ -50,6 +47,74 @@ public class EventHooks {
public EventHooks() {
}
public static void onScriptItemInit(IItemCustom handler) {
if (!handler.isClient()) {
ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler);
handler.callScript(EnumScriptType.INIT, event);
NpcAPI.EVENT_BUS.post(event);
}
}
public static void onScriptItemUpdate(IItemCustom handler, EntityLivingBase player) {
if (!handler.isClient()) {
ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, NpcAPI.Instance().getIEntity(player));
handler.callScript(EnumScriptType.TICK, event);
NpcAPI.EVENT_BUS.post(event);
}
}
public static boolean onScriptItemTossed(IItemCustom handler, EntityPlayer player, EntityItem entity) {
ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity));
handler.callScript(EnumScriptType.TOSSED, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemPickedUp(IItemCustom handler, EntityPlayer player) {
ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player));
handler.callScript(EnumScriptType.PICKEDUP, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemSpawn(IItemCustom handler, EntityItem entity) {
ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, NpcAPI.Instance().getIEntity(entity));
handler.callScript(EnumScriptType.SPAWN, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemInteract(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) {
handler.callScript(EnumScriptType.INTERACT, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptItemAttack(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) {
handler.callScript(EnumScriptType.ATTACK, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onFinishUsingCustomItem(IItemCustom handler, IPlayer player, int duration) {
ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCInit(EntityNPCInterface npc) {
if(npc == null || npc.wrappedNPC == null)
return;
@@ -57,7 +122,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCUpdate(EntityNPCInterface npc) {
@@ -67,7 +132,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event);
npc.script.callScript(EnumScriptType.TICK);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
@@ -80,7 +145,7 @@ public class EventHooks {
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
@@ -93,7 +158,7 @@ public class EventHooks {
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
@@ -103,7 +168,7 @@ public class EventHooks {
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -114,7 +179,7 @@ public class EventHooks {
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -125,7 +190,7 @@ public class EventHooks {
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -136,7 +201,7 @@ public class EventHooks {
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, "target", entity);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){
@@ -146,7 +211,7 @@ public class EventHooks {
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -157,7 +222,7 @@ public class EventHooks {
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){
@@ -167,7 +232,7 @@ public class EventHooks {
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event);
boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -178,7 +243,7 @@ public class EventHooks {
NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event);
boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -190,228 +255,228 @@ public class EventHooks {
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerInit(PlayerDataScript handler, IPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
handler.callScript(EnumScriptType.INIT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerTick(PlayerDataScript handler, IPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
handler.callScript(EnumScriptType.TICK, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
handler.callScript(EnumScriptType.INTERACT, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
public static boolean onPlayerDropItems(PlayerDataScript handler, IPlayer player, ArrayList<EntityItem> entityItems) {
IItemStack[] items = new IItemStack[entityItems.size()];
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
DropEvent event = new DropEvent(player, items);
handler.callScript(EnumScriptType.DROP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
public static void onPlayerPickupXP(PlayerDataScript handler, IPlayer player, EntityXPOrb orb) {
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
handler.callScript(EnumScriptType.PICKUP_XP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
public static boolean onPlayerToss(PlayerDataScript handler, IPlayer player, EntityItem entityItem) {
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.TOSS, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
public static boolean onPlayerPickUp(PlayerDataScript handler, IPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.PICKUP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
public static void onPlayerContainerOpen(PlayerDataScript handler, IPlayer player, Container container) {
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
public static void onPlayerUseHoe(PlayerDataScript handler, IPlayer player, ItemStack hoe, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
handler.callScript(EnumScriptType.USE_HOE, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
public static void onPlayerSleep(PlayerDataScript handler, IPlayer player, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
handler.callScript(EnumScriptType.SLEEP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
public static void onPlayerWakeUp(PlayerDataScript handler, IPlayer player, boolean setSpawn) {
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
handler.callScript(EnumScriptType.WAKE_UP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
public static void onPlayerDeath(PlayerDataScript handler, IPlayer player, DamageSource source, Entity entity) {
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
handler.callScript(EnumScriptType.KILLED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
public static void onPlayerKills(PlayerDataScript handler, IPlayer player, EntityLivingBase entityLiving) {
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
handler.callScript(EnumScriptType.KILLS, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
handler.callScript(EnumScriptType.DAMAGED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
public static boolean onPlayerLightning(PlayerDataScript handler, IPlayer player) {
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
handler.callScript(EnumScriptType.LIGHTNING, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
public static boolean onPlayerSound(PlayerDataScript handler, IPlayer player, String name, float pitch, float volume) {
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
handler.callScript(EnumScriptType.PLAYSOUND, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
public static void onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
handler.callScript(EnumScriptType.FALL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerJump(PlayerDataScript handler, IPlayer player) {
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
handler.callScript(EnumScriptType.JUMP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerLogin(PlayerDataScript handler, IPlayer player) {
LoginEvent event = new LoginEvent(player);
handler.callScript(EnumScriptType.LOGIN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
public static void onPlayerAchievement(PlayerDataScript handler, IPlayer player, String description) {
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
public static void onPlayerFillBucket(PlayerDataScript handler, IPlayer player, ItemStack current, ItemStack result) {
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
handler.callScript(EnumScriptType.FILL_BUCKET, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
public static void onPlayerBonemeal(PlayerDataScript handler, IPlayer player, int x, int y, int z, World world) {
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
handler.callScript(EnumScriptType.BONEMEAL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerRespawn(PlayerDataScript handler, IPlayer player) {
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
handler.callScript(EnumScriptType.RESPAWN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
public static void onPlayerLogout(PlayerDataScript handler, IPlayer player) {
LogoutEvent event = new LogoutEvent(player);
handler.callScript(EnumScriptType.LOGOUT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
handler.callScript(EnumScriptType.CHAT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
public static void onPlayerChangeDim(PlayerDataScript handler, IPlayer player, int fromDim, int toDim) {
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
handler.callScript(EnumScriptType.CHANGED_DIM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
KeyPressedEvent event = new KeyPressedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTimer(PlayerData data, int id) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer)NpcAPI.Instance().getIEntity(data.player), id);
handler.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onForgeEntityEvent(EntityEvent event) {
@@ -429,7 +494,7 @@ public class EventHooks {
public static void onForgeInit(ForgeDataScript handler) {
noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent();
handler.callScript("init", event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onForgeEvent(ForgeEvent ev, Event event) {
@@ -443,7 +508,7 @@ public class EventHooks {
}
handler.callScript(eventName, event);
WrapperNpcAPI.EVENT_BUS.post(ev);
NpcAPI.EVENT_BUS.post(ev);
if(event.isCancelable()) {
event.setCanceled(ev.isCanceled());
}
@@ -451,72 +516,72 @@ public class EventHooks {
}
}
public static void onCustomGuiButton(ScriptPlayer player, ICustomGui gui, int buttonId) {
public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) {
CustomGuiEvent.ButtonEvent event = new CustomGuiEvent.ButtonEvent(player, gui, buttonId);
CustomGuiController.onButton(event);
}
public static void onCustomGuiSlot(ScriptPlayer player, ICustomGui gui, int slotId) {
public static void onCustomGuiSlot(IPlayer player, ICustomGui gui, int slotId) {
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId));
CustomGuiController.onSlotChange(event);
}
public static void onCustomGuiUnfocused(ScriptPlayer player, ICustomGui gui, int textfieldId) {
public static void onCustomGuiUnfocused(IPlayer player, ICustomGui gui, int textfieldId) {
CustomGuiEvent.UnfocusedEvent event = new CustomGuiEvent.UnfocusedEvent(player, gui, textfieldId);
CustomGuiController.onCustomGuiUnfocused(event);
}
public static void onCustomGuiScrollClick(ScriptPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
public static void onCustomGuiScrollClick(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
CustomGuiEvent.ScrollEvent event = new CustomGuiEvent.ScrollEvent(player, gui, scrollId, scrollIndex, selection, doubleClick);
CustomGuiController.onScrollClick(event);
}
public static void onCustomGuiClose(ScriptPlayer player, ICustomGui gui) {
public static void onCustomGuiClose(IPlayer player, ICustomGui gui) {
noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui);
CustomGuiController.onClose(event);
}
public static void onQuestFinished(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onQuestStarted(EntityPlayer player, Quest quest){
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_START, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
return NpcAPI.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);
NpcAPI.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);
NpcAPI.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);
NpcAPI.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);
NpcAPI.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);
NpcAPI.EVENT_BUS.post(event);
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.ForgeEventFactory;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.data.SpawnData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -22,19 +22,19 @@ import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*;
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;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.NpcAPI;
public class NoppesUtilPlayer {
@@ -124,6 +124,10 @@ public class NoppesUtilPlayer {
}
player.worldObj.updateEntityWithOptionalForce(player, false);
}
public static void swingPlayerArm(EntityPlayerMP player){
Server.sendData(player, EnumPacketClient.SWING_PLAYER_ARM);
}
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
ItemStack currency = currencyInv.getStackInSlot(0);
@@ -252,16 +256,16 @@ public class NoppesUtilPlayer {
if(dialog == null)
return;
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
return;
}
DialogOption option = dialog.options.get(optionId);
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) {
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
return;
}
if(option.optionType == EnumOptionType.RoleOption){
@@ -299,7 +303,7 @@ public class NoppesUtilPlayer {
if(!data.quest.questInterface.isCompleted(playerData))
return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest);
event.expReward = data.quest.rewardExp;
List<IItemStack> list = new ArrayList();
+31 -25
View File
@@ -14,7 +14,6 @@ import java.util.Map;
import java.util.UUID;
import java.util.zip.GZIPOutputStream;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@@ -41,40 +40,39 @@ import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.Bank;
import noppes.npcs.controllers.data.Bank;
import noppes.npcs.controllers.BankController;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogCategory;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogCategory;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.PlayerBankData;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerBankData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerDialogData;
import noppes.npcs.controllers.PlayerFactionData;
import noppes.npcs.controllers.data.PlayerDialogData;
import noppes.npcs.controllers.data.PlayerFactionData;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.PlayerTransportData;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.PlayerTransportData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestCategory;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.TransportCategory;
import noppes.npcs.controllers.data.TransportCategory;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.controllers.data.TransportLocation;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTransporter;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.DialogEvent;
import noppes.npcs.scripted.event.ScriptEventDialog;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class NoppesUtilServer {
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
@@ -183,7 +181,7 @@ public class NoppesUtilServer {
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
Dialog dialog = dia.copy(player);
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
if(npc instanceof EntityDialogNpc){
dialog.hideNPC = true;
@@ -312,7 +310,9 @@ public class NoppesUtilServer {
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
}
public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge,
public static void spawnScriptedParticle(String directory,
int HEXColor, int HEXColor2, float colorRate, int rateStart,
int amount, int maxAge,
double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
@@ -320,10 +320,14 @@ public class NoppesUtilServer {
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
int entityID
boolean facePlayer, int width, int height, int offsetX, int offsetY,
int animRate, boolean animLoop, int animStart, int animEnd,
int entityID, int dimensionID
){
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
directory, HEXcolor, amount, maxAge,
directory,
HEXColor, HEXColor2, colorRate, rateStart,
amount, maxAge,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
@@ -331,7 +335,9 @@ public class NoppesUtilServer {
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
entityID
facePlayer, width, height, offsetX, offsetY,
animRate, animLoop, animStart, animEnd,
entityID, dimensionID
);
}
@@ -3,8 +3,6 @@ package noppes.npcs;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -21,6 +19,7 @@ import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.constants.*;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleCompanion;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -40,9 +40,7 @@ import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner;
@@ -52,8 +50,9 @@ 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;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.item.ScriptCustomItem;
public class PacketHandlerServer{
@@ -73,27 +72,30 @@ public class PacketHandlerServer{
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(type == EnumPacketServer.IsGuiOpen) {
if (type == EnumPacketServer.IsGuiOpen) {
isGuiOpenPacket(buffer, player);
return;
} else if (type == EnumPacketServer.CustomGuiButton && 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());
} else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiUnfocused((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
} else if (type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
return;
} else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) {
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
EventHooks.onCustomGuiScrollClick((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
EventHooks.onCustomGuiScrollClick((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
return;
} else if (type == EnumPacketServer.CustomGuiClose) {
EventHooks.onCustomGuiClose((ScriptPlayer)NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
return;
} else if (type == EnumPacketServer.UpdateTrackedQuest) {
updateTrackedQuest(buffer, player);
return;
}
@@ -123,6 +125,12 @@ public class PacketHandlerServer{
npcScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
forgeScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
itemScriptPackets(type, buffer, player);
else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave)
getScriptsEnabled(type, buffer, player);
else if (type == EnumPacketServer.ServerUpdateSkinOverlays)
updateSkinOverlays(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))
@@ -134,10 +142,59 @@ public class PacketHandlerServer{
}
}
private void updateTrackedQuest(ByteBuf buffer, EntityPlayerMP player) {
String trackedQuestString = Server.readString(buffer);
if (trackedQuestString != null && trackedQuestString.contains(":")) {
String[] splitString = trackedQuestString.split(":");
String categoryName = splitString[0];
String questName = splitString[1];
for (QuestCategory category : QuestController.instance.categories.values()) {
if (category.title.equals(categoryName)) {
for (Quest quest : category.quests.values()) {
if (quest.title.equals(questName)) {
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = quest;
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Quest",quest.writeToNBT(new NBTTagCompound()));
compound.setString("CategoryName", quest.getCategory().getName());
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
return;
}
}
}
}
}
PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null;
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
}
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
NoppesUtilServer.isGUIOpen(buffer, player);
}
public void updateSkinOverlays(EntityPlayerMP player) {
PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient();
}
private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if (type == EnumPacketServer.ScriptGlobalGuiDataGet) {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("ScriptsEnabled", CustomNpcs.GlobalPlayerScripts);
compound.setBoolean("PlayerScriptsEnabled", CustomNpcs.GlobalPlayerScripts);
compound.setBoolean("GlobalNPCScriptsEnabled", CustomNpcs.GlobalNPCScripts);
compound.setBoolean("ForgeScriptsEnabled", CustomNpcs.GlobalForgeScripts);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) {
NBTTagCompound compound = Server.readNBT(buffer);
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("ScriptsEnabled");
CustomNpcs.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled");
CustomNpcs.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled");
CustomNpcs.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled");
}
}
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
if(type == EnumPacketServer.ScriptDataSave){
npc.script.readFromNBT(Server.readNBT(buffer));
@@ -156,6 +213,7 @@ public class PacketHandlerServer{
if(type == EnumPacketServer.ScriptPlayerGet) {
PlayerDataScript data = ScriptController.Instance.playerScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setBoolean("ScriptEnabled", ScriptController.Instance.playerScripts.getEnabled());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptPlayerSave) {
@@ -168,6 +226,7 @@ public class PacketHandlerServer{
if (type == EnumPacketServer.ScriptForgeGet) {
ForgeDataScript data = ScriptController.Instance.forgeScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setBoolean("ScriptEnabled", ScriptController.Instance.forgeScripts.getEnabled());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
} else if (type == EnumPacketServer.ScriptForgeSave) {
@@ -180,6 +239,7 @@ public class PacketHandlerServer{
if(type == EnumPacketServer.ScriptNPCGet) {
NPCDataScript data = ScriptController.Instance.npcScripts;
compound = data.writeToNBT(new NBTTagCompound());
compound.setBoolean("ScriptEnabled", ScriptController.Instance.npcScripts.getEnabled());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
} else if(type == EnumPacketServer.ScriptNPCSave) {
@@ -187,6 +247,26 @@ public class PacketHandlerServer{
}
}
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
if (type == EnumPacketServer.ScriptItemDataGet) {
ScriptCustomItem iw = new ScriptCustomItem(player.getHeldItem());
NBTTagCompound compound = iw.getMCNbt();
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
} else if (type == EnumPacketServer.ScriptItemDataSave) {
if (!player.capabilities.isCreativeMode) {
return;
}
NBTTagCompound compound = Server.readNBT(buffer);
ScriptCustomItem wrapper = new ScriptCustomItem(player.getHeldItem());
wrapper.setMCNbt(compound);
wrapper.lastInited = -1L;
wrapper.saveScriptData();
player.sendContainerToPlayer(player.inventoryContainer);
}
}
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
if(type == EnumPacketServer.DimensionsGet){
HashMap<String,Integer> map = new HashMap<String,Integer>();
+13 -4
View File
@@ -6,12 +6,13 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
public class QuestLogData {
public String trackedQuestKey = "";
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
public String selectedQuest = "";
public String selectedCategory = "";
@@ -25,6 +26,7 @@ public class QuestLogData {
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey);
return compound;
}
@@ -33,11 +35,12 @@ public class QuestLogData {
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID");
}
public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(Quest quest : PlayerQuestController.getActiveQuests(player))
for(Quest quest : PlayerQuestController.getActiveQuests(player))
{
String category = quest.category.title;
if(!categories.containsKey(category))
@@ -50,6 +53,12 @@ public class QuestLogData {
questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player));
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(category + ":" + quest.title, quest.completerNpc);
if (playerData.questData.trackedQuest != null) {
if (quest.id == playerData.questData.trackedQuest.getId()) {
trackedQuestKey = category + ":" + quest.title;
}
}
}
}
@@ -0,0 +1,157 @@
package noppes.npcs;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.event.ItemEvent;
import noppes.npcs.scripted.interfaces.item.IItemCustom;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.NpcAPI;
import java.util.HashMap;
public class ScriptItemEventHandler {
public ScriptItemEventHandler() {}
@SubscribeEvent
public void invoke(LivingEvent.LivingUpdateEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer)
return;
if (event.entityLiving instanceof EntityCustomNpc) {
HashMap<Integer, ItemStack> armor = ((EntityCustomNpc) event.entityLiving).inventory.armor;
HashMap<Integer, ItemStack> items = ((EntityCustomNpc) event.entityLiving).inventory.items;
HashMap<Integer, ItemStack> weapons = ((EntityCustomNpc) event.entityLiving).inventory.weapons;
HashMap<Integer, ItemStack>[] inventories = new HashMap[]{armor, items, weapons};
for (HashMap<Integer, ItemStack> inventory : inventories) {
for (ItemStack stack : inventory.values()) {
if (stack != null && stack.getItem() == CustomItems.scripted_item) {
IItemStack istack = NpcAPI.Instance().getIItemStack(stack);
EventHooks.onScriptItemUpdate((IItemCustom) istack, event.entityLiving);
}
}
}
} else if(event.entityLiving.getHeldItem() != null && event.entityLiving.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem());
EventHooks.onScriptItemUpdate((IItemCustom) itemStack, event.entityLiving);
}
}
@SubscribeEvent
public void invoke(ItemTossEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
try {
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem);
}
} catch (Exception e) {}
}
}
@SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
try {
if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.player.getHeldItem());
EventHooks.onScriptItemPickedUp(isw, event.player);
}
} catch(Exception e) {}
}
}
@SubscribeEvent
public void invoke(EntityJoinWorldEvent event) {
if (!event.world.isRemote && event.entity instanceof EntityItem) {
EntityItem entity = (EntityItem)event.entity;
ItemStack stack = entity.getEntityItem();
try {
if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item && EventHooks.onScriptItemSpawn(ItemScripted.GetWrapper(stack), entity)) {
event.setCanceled(true);
}
} catch(Exception e) {}
}
}
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
try {
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ)));
event.setCanceled(EventHooks.onScriptItemInteract(isw, eve));
}
} catch(Exception e) {}
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingCustomItem(handler, IPlayer, event.duration));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
IItemCustom handler = ItemScripted.GetWrapper(event.item);
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingCustomItem(handler, IPlayer, event.duration);
}
}
}
@@ -5,37 +5,20 @@
package noppes.npcs;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Vector;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
@@ -45,15 +28,16 @@ import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ForgeEvent;
import org.lwjgl.input.Mouse;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() {
@@ -68,7 +52,7 @@ public class ScriptPlayerEventHandler {
if(player.ticksExisted%10 == 0) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
}
@@ -93,7 +77,7 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
}
@@ -106,7 +90,7 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
EventHooks.onPlayerBowCharge(handler, ev);
}
@@ -119,7 +103,7 @@ public class ScriptPlayerEventHandler {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
EventHooks.onPlayerRanged(handler, ev);
}
@@ -132,7 +116,7 @@ public class ScriptPlayerEventHandler {
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
event.setExpToDrop(ev.exp);
@@ -146,7 +130,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -157,7 +141,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -168,7 +152,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@@ -179,7 +163,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
}
}
@@ -191,7 +175,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
}
}
@@ -203,7 +187,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
}
}
@@ -215,7 +199,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
}
}
@@ -227,7 +211,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
}
}
@@ -239,7 +223,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
}
}
@@ -251,7 +235,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
}
}
@@ -263,7 +247,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
}
}
@@ -275,7 +259,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
}
}
@@ -287,7 +271,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
}
}
@@ -299,7 +283,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
}
}
@@ -311,7 +295,7 @@ public class ScriptPlayerEventHandler {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
}
}
@@ -323,7 +307,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
}
}
@@ -336,7 +320,7 @@ public class ScriptPlayerEventHandler {
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
}
}
@@ -350,7 +334,7 @@ public class ScriptPlayerEventHandler {
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerJump(handler, scriptPlayer);
}
}
@@ -364,7 +348,7 @@ public class ScriptPlayerEventHandler {
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
EventHooks.onPlayerLightning(handler, scriptPlayer);
}
}
@@ -378,7 +362,7 @@ public class ScriptPlayerEventHandler {
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
}
}
@@ -393,12 +377,12 @@ public class ScriptPlayerEventHandler {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
}
if(source instanceof EntityPlayer) {
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity());
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
}
@@ -414,17 +398,16 @@ public class ScriptPlayerEventHandler {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
event.ammount = pevent.damage;
}
if(source instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
event.ammount = pevent1.damage;
}
}
}
@@ -435,7 +418,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);
}
}
@@ -447,8 +430,16 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.trackedQuest;
if (quest != null) {
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Quest",quest.writeToNBT(new NBTTagCompound()));
compound.setString("CategoryName", quest.getCategory().getName());
Server.sendData((EntityPlayerMP) event.player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
}
}
}
@@ -459,7 +450,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogout(handler, scriptPlayer);
}
}
@@ -473,7 +464,7 @@ public class ScriptPlayerEventHandler {
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
String message = event.message;
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
EventHooks.onPlayerChat(handler, ev);
@@ -34,8 +34,8 @@ import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur;
import noppes.npcs.items.ItemShield;
@@ -7,8 +7,8 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.Lines;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityNPCInterface;
public class VersionCompatibility {
@@ -29,8 +29,16 @@ public class EntityAIReturn extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute(){
if(npc.hasOwner() || !npc.ai.returnToStart || npc.isKilled() || !npc.getNavigator().noPath() || npc.isInteracting()){
public boolean shouldExecute() {
if (!npc.ai.returnToStart){
return false;
}
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)){
return true;
}
if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){
return false;
}
@@ -52,9 +60,6 @@ public class EntityAIReturn extends EntityAIBase
}
return false;
}
if(!npc.isAttacking() && wasAttacked){
return true;
}
if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < CustomNpcs.NpcNavRange * CustomNpcs.NpcNavRange)
return false;
@@ -10,7 +10,7 @@ import net.minecraft.util.Vec3;
import noppes.npcs.CustomNpcs;
import noppes.npcs.ai.selector.NPCInteractSelector;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIWander extends EntityAIBase
@@ -76,10 +76,6 @@ public class FlyPathFinder extends PathFinder
flag = this.isPathingInWater;
this.isPathingInWater = false;
}
else
{
i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
}
FlyPathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(p_75857_1_.boundingBox.minX), i, MathHelper.floor_double(p_75857_1_.boundingBox.minZ));
FlyPathPoint pathpoint = this.openPoint(MathHelper.floor_double(p_75857_2_ - (double)(p_75857_1_.width / 2.0F)), MathHelper.floor_double(p_75857_4_), MathHelper.floor_double(p_75857_6_ - (double)(p_75857_1_.width / 2.0F)));
@@ -167,10 +163,17 @@ public class FlyPathFinder extends PathFinder
}
for(int y = -1; y <= 1; y ++) {
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0);
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0);
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //A
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); //D
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); //B
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //C
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //2
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //4
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //3
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //1
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint3;
@@ -187,6 +190,34 @@ public class FlyPathFinder extends PathFinder
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint6;
}
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint7;
}
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint8;
}
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint9;
}
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint10;
}
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_ &&
pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_) {
this.pathOptions[i++] = pathpoint11;
}
}
return i;
@@ -262,7 +293,7 @@ public class FlyPathFinder extends PathFinder
/**
* Returns a mapped point or creates and adds one
*/
private final FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_)
private FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_)
{
int l = FlyPathPoint.makeHash(p_75854_1_, p_75854_2_, p_75854_3_);
FlyPathPoint pathpoint = (FlyPathPoint)this.pointMap.lookup(l);
@@ -300,7 +331,17 @@ public class FlyPathFinder extends PathFinder
if(block == Blocks.air)
{
return 2;
boolean heightClear = true;
for (int currentY = blockY; currentY <= Math.ceil(blockY + entity.height); ++currentY) {
Block b = entity.worldObj.getBlock(l, currentY, j1);
if (b != Blocks.air) {
heightClear = false;
break;
}
}
if (heightClear) {
return 2;
}
}
if (block == Blocks.trapdoor)
@@ -29,10 +29,11 @@ public class FlyingMoveHelper extends EntityMoveHelper{
if (this.update) {
this.update = false;
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
double verticalSpeed = this.speed * this.entity.ai.flySpeed/8.0D;
double d0 = this.posX - this.entity.posX;
double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D);
double d1 = this.posY - this.entity.posY;
double d2 = this.posZ - this.entity.posZ;
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
double d5 = MathHelper.sqrt_double(d4);
@@ -48,17 +49,20 @@ public class FlyingMoveHelper extends EntityMoveHelper{
}
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed;
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed;
this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed;
this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed;
if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) {
this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed;
this.entity.motionY = verticalSpeed * (d1 / d5);
if (this.entity.motionY > 0) {
this.entity.motionY += 0.1D;
}
}
this.entity.velocityChanged = true;
}
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F);
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),20.0F);
}
}
@@ -1,10 +1,13 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate;
@@ -196,6 +199,16 @@ public class PathNavigateFlying extends PathNavigate {
return this.currentPath;
}
private boolean isInLiquid()
{
return this.theEntity.isInWater() || this.theEntity.handleLavaMovement();
}
private boolean canNavigate()
{
return !this.isInLiquid() || (this.canSwim && this.isInLiquid());
}
public void onUpdateNavigation()
{
++this.totalTicks;
@@ -224,15 +237,6 @@ public class PathNavigateFlying extends PathNavigate {
Vec3 vec3 = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
{
i = j;
break;
}
}
float f = this.theEntity.width * this.theEntity.width;
int k;
@@ -257,7 +261,7 @@ public class PathNavigateFlying extends PathNavigate {
}
}
if (this.totalTicks - this.ticksAtLastPos > 100)
if (this.totalTicks - this.ticksAtLastPos > 10)
{
if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
@@ -300,23 +304,6 @@ public class PathNavigateFlying extends PathNavigate {
return this.theEntity.boundingBox.minY + 0.05D;
}
/**
* If on ground or swimming and can swim
*/
private boolean canNavigate()
{
return true;
}
/**
* Returns true when an entity could stand at a position, including solid blocks under the entire entity. Args:
* xOffset, yOffset, zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_)
{
return true;
}
/**
* Trims path data from the end to the first sun covered block
*/
@@ -341,7 +328,7 @@ public class PathNavigateFlying extends PathNavigate {
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_)
private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int entityXSize, int entityYSize, int entityZSize)
{
int l = MathHelper.floor_double(p_75493_1_.xCoord);
int i1 = MathHelper.floor_double(p_75493_1_.zCoord);
@@ -358,17 +345,17 @@ public class PathNavigateFlying extends PathNavigate {
double d3 = 1.0D / Math.sqrt(d2);
d0 *= d3;
d1 *= d3;
p_75493_3_ += 2;
p_75493_5_ += 2;
entityXSize += 2;
entityZSize += 2;
if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1))
if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, entityXSize, entityYSize, entityZSize, p_75493_1_, d0, d1))
{
return false;
}
else
{
p_75493_3_ -= 2;
p_75493_5_ -= 2;
entityXSize -= 2;
entityZSize -= 2;
double d4 = 1.0D / Math.abs(d0);
double d5 = 1.0D / Math.abs(d1);
double d6 = (double)(l * 1) - p_75493_1_.xCoord;
@@ -413,17 +400,53 @@ public class PathNavigateFlying extends PathNavigate {
k2 = i2 - i1;
}
}
while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1));
while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, entityXSize, entityYSize, entityZSize, p_75493_1_, d0, d1));
return false;
}
}
}
/**
* Returns true if an entity does not collide with any solid blocks at the position. Args: xOffset, yOffset,
* zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_)
{
int k1 = p_75483_1_ - p_75483_4_ / 2;
int l1 = p_75483_3_ - p_75483_6_ / 2;
if (!this.isPositionClear(k1, p_75483_2_, l1, p_75483_4_, p_75483_5_, p_75483_6_, p_75483_7_, p_75483_8_, p_75483_10_))
{
return false;
}
else
{
for (int i2 = k1; i2 < k1 + p_75483_4_; ++i2)
{
for (int j2 = l1; j2 < l1 + p_75483_6_; ++j2)
{
double d2 = (double)i2 + 0.5D - p_75483_7_.xCoord;
double d3 = (double)j2 + 0.5D - p_75483_7_.zCoord;
if (d2 * p_75483_8_ + d3 * p_75483_10_ >= 0.0D)
{
Block block = this.worldObj.getBlock(i2, p_75483_2_ - 1, j2);
Material material = block.getMaterial();
if (material == Material.water && !this.theEntity.isInWater())
{
return false;
}
if (material == Material.lava)
{
return false;
}
}
}
}
return true;
}
}
private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_)
{
for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1)
@@ -14,7 +14,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.data.Availability;
public class TileBorder extends TileEntity implements IEntitySelector{
public Availability availability = new Availability();
@@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import noppes.npcs.CustomNpcs;
import noppes.npcs.blocks.BlockNpcRedstone;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.data.Availability;
public class TileRedstoneBlock extends TileEntity {
public int onRange = 6;
@@ -10,10 +10,10 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.data.PlayerQuestData;
import noppes.npcs.controllers.data.QuestData;
import noppes.npcs.quests.QuestLocation;
public class TileWaypoint extends TileEntity {
@@ -5,16 +5,24 @@ import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.HashMap;
import java.util.UUID;
import net.minecraft.client.Minecraft;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.constants.EnumPacketServer;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import noppes.npcs.controllers.data.SkinOverlay;
public class Client {
public static OverlayQuestTracking questTrackingOverlay = null;
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, Long> entitySkinOverlayTicks = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer();
try {
@@ -1,18 +1,65 @@
package noppes.npcs.client;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.renderer.OpenGlHelper;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.RenderCNPCPlayer;
import org.lwjgl.opengl.GL11;
public class ClientEventHandler {
RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event){
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
for (OverlayCustom overlayCustom : Client.customOverlays.values()) {
overlayCustom.renderGameOverlay(event.partialTicks);
}
if (Client.questTrackingOverlay != null) {
Client.questTrackingOverlay.renderGameOverlay(event.partialTicks);
}
}
}
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Post event) {
if (!(event.renderer instanceof RenderCNPCPlayer)) {
renderCNPCPlayer.tempRenderPartialTicks = event.partialRenderTick;
renderCNPCPlayer.doRender(event.entityPlayer, 0, 0, 0, 0.0F, event.partialRenderTick);
}
}
@SubscribeEvent
public void cancelSpecials(RenderPlayerEvent.Specials.Pre event) {
if (event.renderer instanceof RenderCNPCPlayer)
event.setCanceled(true);
}
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && event.phase == TickEvent.Phase.END) {
renderCNPCPlayer.itemRenderer.updateEquippedItem();
renderCNPCPlayer.updateFovModifierHand();
}
}
@SubscribeEvent
public void onRenderHand(RenderHandEvent event) {
if (Client.skinOverlays.containsKey(Minecraft.getMinecraft().thePlayer.getUniqueID()) && Client.skinOverlays.get(Minecraft.getMinecraft().thePlayer.getUniqueID()).values().size() > 0) {
GL11.glPushMatrix();
event.setCanceled(true);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
renderCNPCPlayer.renderHand(event.partialTicks, event.renderPass);
GL11.glPopMatrix();
} else {
event.setCanceled(false);
}
}
}
@@ -100,6 +100,7 @@ import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.script.GuiScriptGlobal;
import noppes.npcs.client.gui.script.GuiScriptItem;
import noppes.npcs.client.model.*;
import noppes.npcs.client.renderer.*;
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
@@ -130,9 +131,10 @@ import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.*;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.interfaces.IWorld;
import org.lwjgl.input.Keyboard;
@@ -165,7 +167,6 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc());
RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale(
new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F)));
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
@@ -358,6 +359,9 @@ public class ClientProxy extends CommonProxy {
else if(gui == EnumGuiType.Script && CustomNpcs.ScriptingEnabled)
return new GuiScript(npc);
else if (gui == EnumGuiType.ScriptItem)
return new GuiScriptItem(Minecraft.getMinecraft().thePlayer);
else if(gui == EnumGuiType.PlayerAnvil)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
@@ -536,7 +540,11 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerItem(Item item) {
MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer());
if (item instanceof ItemScripted) {
MinecraftForgeClient.registerItemRenderer(item, new CustomItemRenderer());
} else {
MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer());
}
}
public static void bindTexture(ResourceLocation location) {
@@ -63,16 +63,8 @@ public class ClientTickHandler{
mc.setIngameFocus();
}
int key = Keyboard.getEventKey();
long time = Keyboard.getEventNanoseconds();
if(Keyboard.getEventKeyState()) {
if(!this.isIgnoredKey(key)) {
this.buttonTime = time;
}
}
if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) {
if(!Keyboard.isRepeatEvent()) {
int key = Keyboard.getEventKey();
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
@@ -80,13 +72,13 @@ public class ClientTickHandler{
boolean keyDown = Keyboard.isKeyDown(key);
StringBuilder keysDownString = new StringBuilder();
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
if(Keyboard.isKeyDown(i)){
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
if (Keyboard.isKeyDown(i)) {
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
if(keysDownString.length() > 0){//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length()-1);
if (keysDownString.length() > 0) {//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length() - 1);
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
@@ -76,6 +76,10 @@ public class ImageDownloadAlt extends SimpleTexture
}
}
public BufferedImage getBufferedImage(){
return this.bufferedImage;
}
public void loadTexture(IResourceManager resourceManager) throws IOException
{
if (this.bufferedImage == null && this.textureLocation != null)
@@ -6,7 +6,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.Vector;
@@ -16,14 +15,16 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.Server;
import noppes.npcs.client.fx.EntityCustomFX;
import noppes.npcs.client.fx.CustomFX;
import noppes.npcs.client.gui.player.GuiDialogInteract;
import noppes.npcs.client.gui.player.GuiQuestCompletion;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
@@ -32,9 +33,10 @@ import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.Sys;
@@ -70,12 +72,27 @@ public class NoppesUtil {
}
}
public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) {
HashMap<Integer, SkinOverlay> skinOverlays = new HashMap<>();
NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10);
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
skinOverlays.put(tagID, (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)));
}
Client.skinOverlays.put(player.getUniqueID(), skinOverlays);
}
public static void spawnScriptedParticle(ByteBuf buffer){
Minecraft minecraft = Minecraft.getMinecraft();
String directory = Server.readString(buffer);
int HEXcolor = buffer.readInt();
int HEXColor = buffer.readInt();
int HEXColor2 = buffer.readInt();
float colorRate = buffer.readFloat();
int colorRateStart = buffer.readInt();
int amount = buffer.readInt();
int maxAge = buffer.readInt();
@@ -113,17 +130,31 @@ public class NoppesUtil {
float rotationZRate = buffer.readFloat();
int rotationZRateStart = buffer.readInt();
boolean facePlayer = buffer.readBoolean();
int width = buffer.readInt();
int height = buffer.readInt();
int offsetX = buffer.readInt();
int offsetY = buffer.readInt();
int animRate = buffer.readInt();
boolean animLoop = buffer.readBoolean();
int animStart = buffer.readInt();
int animEnd = buffer.readInt();
int entityID = buffer.readInt();
int dimensionID = buffer.readInt();
World worldObj = DimensionManager.getWorld(dimensionID);
World worldObj = Minecraft.getMinecraft().theWorld;
Entity entity = worldObj.getEntityByID(entityID);
if(entity != null)
worldObj = entity.worldObj;
if(entity == null)
return;
EntityCustomFX fx = new EntityCustomFX(
entity,
directory, HEXcolor,
CustomFX fx = new CustomFX(
worldObj, entity,
directory,
HEXColor,HEXColor2,colorRate,colorRateStart,
x, y, z,
motionX, motionY, motionZ, gravity,
scale1, scale2, scaleRate, scaleRateStart,
@@ -131,7 +162,9 @@ public class NoppesUtil {
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
maxAge
maxAge, facePlayer,
width, height, offsetX, offsetY,
animRate, animLoop, animStart, animEnd
);
for(int i = 0; i < amount; i++){
@@ -26,6 +26,7 @@ import noppes.npcs.ServerEventsHandler;
import noppes.npcs.client.ClientProxy.FontContainer;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
@@ -36,7 +37,7 @@ import noppes.npcs.client.gui.util.IGuiError;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.entity.EntityDialogNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -260,15 +261,32 @@ public class PacketHandlerClient extends PacketHandlerServer{
NoppesUtil.isGUIOpen(isGUIOpen);
}
else if(type == EnumPacketClient.OVERLAY_DATA){
else if(type == EnumPacketClient.SCRIPT_OVERLAY_DATA){
OverlayCustom overlayCustom = new OverlayCustom(Minecraft.getMinecraft());
overlayCustom.setOverlayData(Server.readNBT(buffer));
Client.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom);
}
else if(type == EnumPacketClient.OVERLAY_CLOSE){
else if(type == EnumPacketClient.SCRIPT_OVERLAY_CLOSE){
int id = buffer.readInt();
Client.customOverlays.remove(id);
}
else if(type == EnumPacketClient.OVERLAY_QUEST_TRACKING){
try {
NBTTagCompound compound = Server.readNBT(buffer);
Client.questTrackingOverlay = new OverlayQuestTracking(Minecraft.getMinecraft());
Client.questTrackingOverlay.setOverlayData(compound);
} catch (IOException e) {
Client.questTrackingOverlay = null;
}
}
else if(type == EnumPacketClient.SWING_PLAYER_ARM){
Minecraft.getMinecraft().thePlayer.swingItem();
}
else if(type == EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS) {
EntityPlayer sendingPlayer = (EntityPlayer) Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
NBTTagCompound compound = Server.readNBT(buffer);
NoppesUtil.updateSkinOverlayData(sendingPlayer, compound);
}
}
}
@@ -0,0 +1,366 @@
package noppes.npcs.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.resources.data.TextureMetadataSection;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import noppes.npcs.client.ClientProxy;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomFX extends EntityFX {
private final Entity entity;
private final ResourceLocation location;
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
private float startX = 0, startY = 0, startZ = 0;
public float scale1 = 1.0F;
public float scale2 = 1.0F;
public float scaleRate = 1.0F;
public int scaleRateStart = 0;
public float alpha1 = 1.0F;
public float alpha2 = 0;
public float alphaRate = 0.0F;
public int alphaRateStart = 0;
public float rotationX = 0;
public float rotationX1 = 0;
public float rotationX2 = 0;
public float rotationXRate = 0.0F;
public int rotationXRateStart = 0;
public float rotationY = 0;
public float rotationY1 = 0;
public float rotationY2 = 0;
public float rotationYRate = 0.0F;
public int rotationYRateStart = 0;
public float rotationZ = 0;
public float rotationZ1 = 0;
public float rotationZ2 = 0;
public float rotationZRate = 0.0F;
public int rotationZRateStart = 0;
public boolean facePlayer = true;
private int totalWidth, totalHeight;
public int width, height;
public int offsetX, offsetY;
private int timeSinceStart;
public int animRate;
public boolean animLoop;
public int animStart,animEnd;
private int animPosX;
private int animPosY;
public int HEXColor = 0xFFFFFF;
public int HEXColor2 = 0xFFFFFF;
public float HEXColorRate = 0.0F;
public int HEXColorStart = 0;
private ImageDownloadAlt imageDownloadAlt = null;
private boolean isUrl = false;
private boolean gotWidthHeight = false;
public CustomFX(World worldObj, Entity entity, String directory,
int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart,
double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
int age, boolean facePlayer, int width, int height, int offsetX, int offsetY,
int animRate, boolean animLoop, int animStart, int animEnd
) {
super(worldObj, x, y, z, motionX, motionY, motionZ);
this.HEXColor = HEXColor;
this.HEXColor2 = HEXColor2;
this.HEXColorRate = HEXColorRate;
this.HEXColorStart = HEXColorStart;
particleRed = (HEXColor >> 16 & 255) / 255f;
particleGreen = (HEXColor >> 8 & 255) / 255f;
particleBlue = (HEXColor & 255) / 255f;
this.scale1 = scale1;
this.scale2 = scale2;
this.scaleRate = Math.abs(scaleRate);
this.scaleRateStart = scaleRateStart;
particleScale = scale1;
if(scale1 > scale2)
this.scaleRate *= -1;
this.alpha1 = alpha1;
this.alpha2 = alpha2;
this.alphaRate = Math.abs(alphaRate);
this.alphaRateStart = alphaRateStart;
particleAlpha = alpha1;
if(alpha1 > alpha2)
this.alphaRate *= -1;
this.rotationX1 = rotationX1;
this.rotationX2 = rotationX2;
this.rotationXRate = Math.abs(rotationXRate);
this.rotationXRateStart = rotationXRateStart;
rotationX = rotationX1;
if(rotationX1 > rotationX2)
this.rotationXRate *= -1;
this.rotationY1 = rotationY1;
this.rotationY2 = rotationY2;
this.rotationYRate = Math.abs(rotationYRate);
this.rotationYRateStart = rotationYRateStart;
rotationY = rotationY1;
if(rotationY1 > rotationY2)
this.rotationYRate *= -1;
this.rotationZ1 = rotationZ1;
this.rotationZ2 = rotationZ2;
this.rotationZRate = Math.abs(rotationZRate);
this.rotationZRateStart = rotationZRateStart;
rotationZ = rotationZ1;
if(rotationZ1 > rotationZ2)
this.rotationZRate *= -1;
particleGravity = gravity/0.04F;
particleMaxAge = age;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.entity = entity;
noClip = true;
location = new ResourceLocation(directory);
this.width = width;
this.height = height;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.animRate = animRate;
this.animLoop = animLoop;
this.animStart = animStart;
this.animEnd = animEnd;
if(this.animEnd < this.animStart)
this.animEnd = this.animStart + this.particleMaxAge;
if(directory.startsWith("https://")){
isUrl = true;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.location, imageDownloadAlt);
} else {
try {
getWidthHeight();
} catch (IOException e) {
e.printStackTrace();
}
}
this.facePlayer = facePlayer;
}
@Override
public void onUpdate() {
++this.timeSinceStart;
if (this.timeSinceStart == this.particleMaxAge)
{
this.setDead();
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.04D * (double)this.particleGravity;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if(animRate > 0 && timeSinceStart%animRate == 0 && timeSinceStart > 0 && gotWidthHeight && timeSinceStart >= animStart && timeSinceStart <= animEnd && (animLoop || animPosY <= totalHeight)){
animPosX += width;
if (animPosX + width > totalWidth) {
animPosX = offsetX;
animPosY += height;
if (animPosY > totalHeight && animLoop) {
animPosY = offsetY;
}
}
}
particleRed = (HEXColor >> 16 & 255) / 255f;
particleGreen = (HEXColor >> 8 & 255) / 255f;
particleBlue = (HEXColor & 255) / 255f;
if(timeSinceStart >= HEXColorStart)
HEXColor = lerpColor(HEXColor, HEXColor2, HEXColorRate);
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
{
tessellator.draw();
ClientProxy.bindTexture(location);
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
getURLWidthHeight();
}
if(entity != null){
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
}
float scaleChange = this.scaleRate / (float)particleMaxAge;
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
particleScale = this.scale2;
else if(timeSinceStart >= this.scaleRateStart)
particleScale += scaleChange;
float alphaChange = this.alphaRate / (float)particleMaxAge;
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
particleAlpha = this.alpha2;
else if(timeSinceStart >= this.alphaRateStart)
particleAlpha += alphaChange;
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
rotationX = this.rotationX2;
else if(timeSinceStart >= this.rotationXRateStart)
rotationX += rotationXChange;
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
rotationY = this.rotationY2;
else if(timeSinceStart >= this.rotationYRateStart)
rotationY += rotationYChange;
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
rotationZ = this.rotationZ2;
else if(timeSinceStart >= this.rotationZRateStart)
rotationZ += rotationZChange;
renderParticleSide(true, tessellator, partialTick);
renderParticleSide(false, tessellator, partialTick);
GL11.glColor4f(1, 1, 1, 1.0F);
ClientProxy.bindTexture(resource);
tessellator.startDrawingQuads();
}
public void renderParticleSide(boolean front, Tessellator tessellator, float partialTick){
float u1 = (float)offsetX/(float)totalWidth + (float)animPosX/(float)totalWidth;
float u2 = u1 + (float)width/(float)totalWidth;
float v1 = (float)offsetY/(float)totalHeight + (float)animPosY/(float)totalHeight;
float v2 = v1 + (float)height/(float)totalHeight;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
float renderScale = 0.1F * particleScale;
float posX = (float)((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX;
float posY = (float)((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY;
float posZ = (float)((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ;
GL11.glPushMatrix();
GL11.glTranslated(posX,posY,posZ);
GL11.glScalef(renderScale, renderScale, renderScale);
if(facePlayer) {
GL11.glRotated(180 - player.rotationYaw, 0.0, 1.0, 0.0);
GL11.glRotated(-player.rotationPitch + 90, 1.0, 0.0, 0.0);
GL11.glRotated(rotationX, 1.0, 0.0, 0.0);
GL11.glRotated(rotationZ, 0.0, 1.0, 0.0);
GL11.glRotated(rotationY + (!front ? 180 : 0), 0.0, 0.0, 1.0);
} else {
GL11.glRotated(rotationX, 1.0, 0.0, 0.0);
GL11.glRotated(rotationY, 0.0, 1.0, 0.0);
GL11.glRotated(rotationZ + (!front ? 180 : 0), 0.0, 0.0, 1.0);
}
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
tessellator.addVertexWithUV( (u2-u1)/2, 0, (v2-v1)/2, u2, v2);
tessellator.addVertexWithUV( (u2-u1)/2, 0, -(v2-v1)/2, u2, v1);
tessellator.addVertexWithUV( -(u2-u1)/2, 0, -(v2-v1)/2, u1, v1);
tessellator.addVertexWithUV( -(u2-u1)/2, 0, (v2-v1)/2, u1, v2);
tessellator.draw();
GL11.glPopMatrix();
}
public void getWidthHeight() throws IOException {
InputStream inputstream = null;
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
gotWidthHeight = true;
this.totalWidth = bufferedimage.getWidth();
this.totalHeight = bufferedimage.getHeight();
correctWidthHeight();
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
public void getURLWidthHeight(){
if(imageDownloadAlt.getBufferedImage() != null) {
gotWidthHeight = true;
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
correctWidthHeight();
}
}
public void correctWidthHeight(){
totalWidth = Math.max(totalWidth, 1);
totalHeight = Math.max(totalHeight, 1);
this.width = width < 0 ? totalWidth : width;
this.height = height < 0 ? totalHeight : height;
}
public int lerpColor(int from, int to, float ratio) {
float ar = (from & 0xFF0000) >> 16;
float ag = (from & 0x00FF00) >> 8;
float ab = (from & 0x0000FF);
float br = (to & 0xFF0000) >> 16;
float bg = (to & 0x00FF00) >> 8;
float bb = (to & 0x0000FF);
float rr = ar + ratio * (br - ar);
float rg = ag + ratio * (bg - ag);
float rb = ab + ratio * (bb - ab);
return (int)(((int)rr << 16) + ((int)rg << 8) + (rb));
}
public int getFXLayer(){
return 0;
}
}
@@ -1,212 +0,0 @@
package noppes.npcs.client.fx;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientProxy;
import org.lwjgl.opengl.GL11;
public class EntityCustomFX extends EntityFX {
private Entity entity;
private final ResourceLocation location;
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
private boolean move = true;
private float startX = 0, startY = 0, startZ = 0;
public float scale1 = 1.0F;
public float scale2 = 1.0F;
public float scaleRate = 1.0F;
public int scaleRateStart = 0;
public float alpha1 = 1.0F;
public float alpha2 = 0;
public float alphaRate = 0.0F;
public int alphaRateStart = 0;
public float rotationX = 0;
public float rotationX1 = 0;
public float rotationX2 = 0;
public float rotationXRate = 0.0F;
public int rotationXRateStart = 0;
public float rotationY = 0;
public float rotationY1 = 0;
public float rotationY2 = 0;
public float rotationYRate = 0.0F;
public int rotationYRateStart = 0;
public float rotationZ = 0;
public float rotationZ1 = 0;
public float rotationZ2 = 0;
public float rotationZRate = 0.0F;
public int rotationZRateStart = 0;
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
double motionX, double motionY, double motionZ, float gravity,
float scale1, float scale2, float scaleRate, int scaleRateStart,
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
int age) {
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
this.scale1 = scale1;
this.scale2 = scale2;
this.scaleRate = Math.abs(scaleRate);
this.scaleRateStart = scaleRateStart;
particleScale = scale1;
if(scale1 > scale2)
this.scaleRate *= -1;
this.alpha1 = alpha1;
this.alpha2 = alpha2;
this.alphaRate = Math.abs(alphaRate);
this.alphaRateStart = alphaRateStart;
particleAlpha = alpha1;
if(alpha1 > alpha2)
this.alphaRate *= -1;
this.rotationX1 = rotationX1;
this.rotationX2 = rotationX2;
this.rotationXRate = Math.abs(rotationXRate);
this.rotationXRateStart = rotationXRateStart;
rotationX = rotationX1;
if(rotationX1 > rotationX2)
this.rotationXRate *= -1;
this.rotationY1 = rotationY1;
this.rotationY2 = rotationY2;
this.rotationYRate = Math.abs(rotationYRate);
this.rotationYRateStart = rotationYRateStart;
rotationY = rotationY1;
if(rotationY1 > rotationY2)
this.rotationYRate *= -1;
this.rotationZ1 = rotationZ1;
this.rotationZ2 = rotationZ2;
this.rotationZRate = Math.abs(rotationZRate);
this.rotationZRateStart = rotationZRateStart;
rotationZ = rotationZ1;
if(rotationZ1 > rotationZ2)
this.rotationZRate *= -1;
particleGravity = gravity/0.04F;
particleMaxAge = age;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.entity = entity;
noClip = true;
particleRed = (HEXColor >> 16 & 255) / 255f;
particleGreen = (HEXColor >> 8 & 255) / 255f;
particleBlue = (HEXColor & 255) / 255f;
if(Math.floor(Math.random()*3) == 1){
move = false;
this.startX = (float) entity.posX;
this.startY = (float) entity.posY;
this.startZ = (float) entity.posZ;
}
location = new ResourceLocation(directory);
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
{
tessellator.draw();
GL11.glPushMatrix();
ClientProxy.bindTexture(location);
if(move){
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
}
float scaleChange = this.scaleRate / (float)particleMaxAge;
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
particleScale = this.scale2;
else if(particleAge >= this.scaleRateStart)
particleScale += scaleChange;
float alphaChange = this.alphaRate / (float)particleMaxAge;
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
particleAlpha = this.alpha2;
else if(particleAge >= this.alphaRateStart)
particleAlpha += alphaChange;
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
rotationX = this.rotationX2;
else if(particleAge >= this.rotationXRateStart)
rotationX += rotationXChange;
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
rotationY = this.rotationY2;
else if(particleAge >= this.rotationYRateStart)
rotationY += rotationYChange;
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
rotationZ = this.rotationZ2;
else if(particleAge >= this.rotationZRateStart)
rotationZ += rotationZChange;
float u1 = 0.0f;
float u2 = 1.0f;
float v1 = 0.0f;
float v2 = 1.0f;
float renderScale = 0.1F * particleScale;
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
GL11.glTranslated((double)posX, (double)posY, (double)posZ);
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
double yaw = (player.rotationYaw/180)*Math.PI;
double pitch = (player.rotationPitch/180)*Math.PI;
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
rotationX += 180*Math.signum(rotationX);
}
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
rotationY += 180*Math.signum(rotationY);
}
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2);
tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1);
tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1);
tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2);
tessellator.draw();
GL11.glPopMatrix();
GL11.glColor4f(1, 1, 1, 1.0F);
ClientProxy.bindTexture(resource);
tessellator.startDrawingQuads();
}
public int getFXLayer(){
return 0;
}
}
@@ -11,8 +11,8 @@ import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.Lines;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
@@ -4,23 +4,26 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){
super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture);
title = "Select Overlay";
//super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture);
super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "");
title = "Select Overlay";
this.parent = parent;
}
public void initGui(){
super.initGui();
int index = npc.display.glowTexture.lastIndexOf("/");
String str = npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "";
int index = str.lastIndexOf("/");
if(index > 0){
String asset = npc.display.glowTexture.substring(index + 1);
if(npc.display.glowTexture.equals(assets.getAsset(asset)))
String asset = str.substring(index + 1);
if(str.equals(assets.getAsset(asset)))
slot.selected = asset;
}
}
@@ -73,8 +76,13 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{
@Override
public void elementClicked(){
if(dataTextures.contains(slot.selected) && slot.selected != null){
npc.display.glowTexture = assets.getAsset(slot.selected);
//npc.display.glowTexture = assets.getAsset(slot.selected);
npc.textureGlowLocation = null;
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(
assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
}
}
@@ -0,0 +1,590 @@
package noppes.npcs.client.gui;
import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.controllers.data.Quest;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class OverlayQuestTracking extends Gui {
public Minecraft mc;
private ScaledResolution res = null;
public static int scaledWidth = 0;
public static int scaledHeight = 0;
int color = 0xFFFFFF;
float alpha = 1.0F;
private boolean randomStyle = false;
private boolean boldStyle = false;
private boolean italicStyle = false;
private boolean underlineStyle = false;
private boolean strikethroughStyle = false;
private boolean bidiFlag = false;
private boolean unicodeFlag = false;
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
private final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
protected final ResourceLocation locationFontTexture = new ResourceLocation("textures/font/ascii.png");;
protected int[] charWidth = new int[256];
protected byte[] glyphWidth = new byte[65536];
private final int[] colorCode = new int[32];
private float red;
private float green;
private float blue;
private float posX;
private float posY;
private float renderOffsetY;
public static Quest trackedQuest = new Quest();
public static String categoryName = "";
public OverlayQuestTracking(Minecraft mc) {
this.mc = mc;
readFontTexture();
readGlyphSizes();
for (int i = 0; i < 32; ++i)
{
int j = (i >> 3 & 1) * 85;
int k = (i >> 2 & 1) * 170 + j;
int l = (i >> 1 & 1) * 170 + j;
int i1 = (i >> 0 & 1) * 170 + j;
if (i == 6)
{
k += 85;
}
if (Minecraft.getMinecraft().gameSettings.anaglyph)
{
int j1 = (k * 30 + l * 59 + i1 * 11) / 100;
int k1 = (k * 30 + l * 70) / 100;
int l1 = (k * 30 + i1 * 70) / 100;
k = j1;
l = k1;
i1 = l1;
}
if (i >= 16)
{
k /= 4;
l /= 4;
i1 /= 4;
}
this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255;
}
}
public void initOverlay() {
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
}
public void setOverlayData(NBTTagCompound compound) {
trackedQuest.readNBT(compound.getCompoundTag("Quest"));
categoryName = compound.getString("CategoryName");
this.initOverlay();
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(CustomNpcs.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(CustomNpcs.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F);
GL11.glTranslatef(CustomNpcs.TrackingInfoX - 10, CustomNpcs.TrackingInfoY, 0.0F);
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
float centerX = -60;
float questTitleTop;
this.renderOffsetY = -40;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(trackedQuest.getName(),1.2F, false, true);
GL11.glPopMatrix();
questTitleTop = this.renderOffsetY;
this.renderOffsetY -= 5;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(categoryName,0.85F, false, false);
GL11.glPopMatrix();
//TODO: Add objectives list, with green strikethrough text for completed objectives. Then, add who the player should turn the quest in to.
this.renderOffsetY = -25;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+2), 0xFF777777);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
GL11.glPopMatrix();
this.renderOffsetY = questTitleTop + 5;
GL11.glPushMatrix();
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-1), 0xFFA8A8A8);
this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-2), 0xFF777777);
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
public void renderStringLines(String string, float scale, boolean upwards, boolean bold) {
String[] split = string.split(" ");
ArrayList<String> lines = new ArrayList<>();
lines.add(split[0]);
for (int i = 1; i < split.length; i++) {
String s = split[i];
if (this.fontRenderer.getStringWidth(lines.get(lines.size() - 1) + " " + s) > 100) {
lines.add(s);
} else {
lines.set(lines.size() - 1, lines.get(lines.size() - 1) + " " + s);
}
}
for (int i = 0; i < lines.size(); i++) {
String s = lines.get(i);
if (!upwards) {
s = lines.get(lines.size()-1 - i);
}
GL11.glPushMatrix();
GL11.glTranslatef(scale*(-this.fontRenderer.getStringWidth(s)/2.0F), this.renderOffsetY, 0.0F);
GL11.glScalef(scale, scale, scale);
this.drawString(s, 0, 0, this.color, true);
if (bold) {
GL11.glTranslatef(0.2F, 0.2F, 0.0F);
this.drawString(s, 0, 0, this.color, false);
}
this.renderOffsetY += upwards ? 10 : -10;
GL11.glPopMatrix();
}
}
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
{
this.resetStyles();
int l;
if (p_85187_5_)
{
l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true);
l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false));
}
else
{
l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false);
}
return l;
}
private void resetStyles()
{
this.randomStyle = false;
this.boldStyle = false;
this.italicStyle = false;
this.underlineStyle = false;
this.strikethroughStyle = false;
}
private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_)
{
if (p_78258_1_ == null)
{
return 0;
}
else
{
if (this.bidiFlag)
{
p_78258_1_ = this.bidiReorder(p_78258_1_);
}
setColor(this.red, this.green, this.blue, this.alpha);
if (p_78258_5_) {
setColor(0,0,0,1.0F);
}
this.posX = (float)p_78258_2_;
this.posY = (float)p_78258_3_;
this.renderStringAtPos(p_78258_1_, p_78258_5_);
return (int)this.posX;
}
}
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{
for (int i = 0; i < p_78255_1_.length(); ++i)
{
char c0 = p_78255_1_.charAt(i);
int j;
int k;
if (c0 == 38 && i + 1 < p_78255_1_.length())
{
j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1));
if(j < 16){
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
if (j < 0 || j > 15)
{
j = 15;
}
if (p_78255_2_)
{
j += 16;
}
k = this.colorCode[j];
setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha);
}
else if (j == 16)
{
this.randomStyle = true;
}
else if (j == 17)
{
this.boldStyle = true;
}
else if (j == 18)
{
this.strikethroughStyle = true;
}
else if (j == 19)
{
this.underlineStyle = true;
}
else if (j == 20)
{
this.italicStyle = true;
}
else if (j == 21)
{
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
}
++i;
}
else
{
j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0);
if (this.randomStyle && j != -1)
{
do
{
k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length);
}
while (this.charWidth[j] != this.charWidth[k]);
j = k;
}
float f1 = this.unicodeFlag ? 0.5F : 1.0F;
boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
float f = this.renderCharAtPos(j, c0, this.italicStyle);
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
if (this.boldStyle)
{
this.posX += f1;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
this.renderCharAtPos(j, c0, this.italicStyle);
this.posX -= f1;
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
++f;
}
doDraw(f);
}
}
}
protected void doDraw(float f)
{
{
{
Tessellator tessellator;
if (this.strikethroughStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
if (this.underlineStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int l = this.underlineStyle ? -1 : 0;
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.posX += (float)((int)f);
}
}
}
private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_)
{
return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_));
}
protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
{
float f = (float)(p_78266_1_ % 16 * 8);
float f1 = (float)(p_78266_1_ / 16 * 8);
float f2 = p_78266_2_ ? 1.0F : 0.0F;
bindTexture(this.locationFontTexture);
float f3 = (float)this.charWidth[p_78266_1_] - 0.01F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f2, this.posY, 0.0F);
GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (float)this.charWidth[p_78266_1_];
}
private ResourceLocation getUnicodePageLocation(int p_111271_1_)
{
if (unicodePageLocations[p_111271_1_] == null)
{
unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)}));
}
return unicodePageLocations[p_111271_1_];
}
private void loadGlyphTexture(int p_78257_1_)
{
bindTexture(this.getUnicodePageLocation(p_78257_1_));
}
/**
* Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
*/
protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_)
{
if (this.glyphWidth[p_78277_1_] == 0)
{
return 0.0F;
}
else
{
int i = p_78277_1_ / 256;
this.loadGlyphTexture(i);
int j = this.glyphWidth[p_78277_1_] >>> 4;
int k = this.glyphWidth[p_78277_1_] & 15;
float f = (float)j;
float f1 = (float)(k + 1);
float f2 = (float)(p_78277_1_ % 16 * 16) + f;
float f3 = (float)((p_78277_1_ & 255) / 16 * 16);
float f4 = f1 - f - 0.02F;
float f5 = p_78277_2_ ? 1.0F : 0.0F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f5, this.posY, 0.0F);
GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (f1 - f) / 2.0F + 1.0F;
}
}
protected void setColor(float r, float g, float b, float a)
{
GL11.glColor4f(r, g, b, a);
}
protected void bindTexture(ResourceLocation location)
{
Minecraft.getMinecraft().renderEngine.bindTexture(location);
}
private void readFontTexture()
{
BufferedImage bufferedimage;
try
{
bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture));
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
int i = bufferedimage.getWidth();
int j = bufferedimage.getHeight();
int[] aint = new int[i * j];
bufferedimage.getRGB(0, 0, i, j, aint, 0, i);
int k = j / 16;
int l = i / 16;
byte b0 = 1;
float f = 8.0F / (float)l;
int i1 = 0;
while (i1 < 256)
{
int j1 = i1 % 16;
int k1 = i1 / 16;
if (i1 == 32)
{
this.charWidth[i1] = 3 + b0;
}
int l1 = l - 1;
while (true)
{
if (l1 >= 0)
{
int i2 = j1 * l + l1;
boolean flag = true;
for (int j2 = 0; j2 < k && flag; ++j2)
{
int k2 = (k1 * l + j2) * i;
if ((aint[i2 + k2] >> 24 & 255) != 0)
{
flag = false;
}
}
if (flag)
{
--l1;
continue;
}
}
++l1;
this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0;
++i1;
break;
}
}
}
private void readGlyphSizes()
{
try
{
InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin"));
inputstream.read(this.glyphWidth);
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
}
protected InputStream getResourceInputStream(ResourceLocation location) throws IOException
{
return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream();
}
private String bidiReorder(String p_147647_1_)
{
try
{
Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127);
bidi.setReorderingMode(0);
return bidi.writeReordered(2);
}
catch (ArabicShapingException arabicshapingexception)
{
return p_147647_1_;
}
}
}
@@ -15,7 +15,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.data.PlayerMail;
public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener{
@@ -14,8 +14,8 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityFactionType;
import noppes.npcs.constants.EnumDayTime;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Faction;
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
{
@@ -1,7 +1,6 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
@@ -12,8 +11,8 @@ import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityDialog;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Dialog;
public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData{
private Availability availabitily;
@@ -1,7 +1,6 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
@@ -13,8 +12,8 @@ import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityQuest;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Quest;
public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSelectionListener, IGuiData {
private Availability availabitily;
@@ -5,19 +5,11 @@ import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenMutated;
import net.minecraftforge.common.BiomeManager;
import noppes.npcs.DataAI;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.constants.EnumStandingType;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.data.SpawnData;
public class SubGuiNpcBiomes extends SubGuiInterface
{
@@ -2,21 +2,14 @@ package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityDialog;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.PlayerMail;
public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiListener
{
@@ -14,8 +14,8 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption;
public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener{
private DialogOption option;
@@ -5,8 +5,8 @@ import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption;
public class SubGuiNpcDialogOptions extends SubGuiInterface
{
@@ -14,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.FactionOptions;
import noppes.npcs.controllers.data.FactionOptions;
public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollData,ICustomScrollListener
{
@@ -7,7 +7,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.data.Faction;
public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfieldListener
{
@@ -5,32 +5,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.apache.logging.log4j.status.StatusConsoleListener;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.SubGuiMailmanSendSetup;
import noppes.npcs.client.gui.SubGuiNpcCommand;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
import noppes.npcs.client.gui.SubGuiNpcTextArea;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener{
@@ -14,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.entity.EntityNPCInterface;
@@ -8,12 +8,12 @@ import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.TransformData;
import noppes.npcs.controllers.data.DataTransform;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData
{
private TransformData data;
private DataTransform data;
public GuiNPCNightSetup(EntityNPCInterface npc)
{
@@ -5,7 +5,6 @@ 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;
@@ -31,7 +30,7 @@ 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 noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -10,14 +10,13 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiButton;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiButton extends GuiButton implements IClickListener {
@@ -53,7 +52,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -9,23 +9,19 @@ import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.renderer.OpenGlHelper;
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.ScriptGuiLabel;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class CustomGuiLabel extends Gui implements IGuiComponent {
int x, y, width, height;
@@ -135,14 +131,14 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
}
public static CustomGuiLabel fromComponent(ScriptGuiLabel component) {
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow());
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.getShadow());
lbl.scale = 1.0F;
lbl.color = component.getColor();
lbl.setScale(component.getScale());
if (component.hasHoverText()) {
lbl.hoverText = component.getHoverText();
}
lbl.labelShadowEnabled = component.hasShadow();
lbl.labelShadowEnabled = component.getShadow();
lbl.color = component.getColor();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
@@ -155,7 +151,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
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);
component.enableShadow(this.labelShadowEnabled);
component.setShadow(this.labelShadowEnabled);
component.setColor(this.color);
component.setAlpha(this.alpha);
component.setRotation(this.rotation);
@@ -6,12 +6,9 @@ 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.ScriptGuiLine;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomGuiLine extends Gui implements IGuiComponent {
int id;
GuiCustom parent;
@@ -17,7 +17,7 @@ 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 noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener {
@@ -8,14 +8,12 @@ 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.Client;
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.constants.EnumPacketServer;
import noppes.npcs.scripted.gui.ScriptGuiTextField;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
@@ -10,19 +10,15 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent;
ResourceLocation texture;
@@ -57,7 +53,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -6,7 +6,7 @@
package noppes.npcs.client.gui.custom.interfaces;
import net.minecraft.client.Minecraft;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
public interface IGuiComponent {
int getID();
@@ -5,12 +5,11 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLabel;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLine;
import noppes.npcs.client.gui.customoverlay.components.CustomOverlayTexturedRect;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.*;
import org.lwjgl.opengl.GL11;
@@ -9,7 +9,7 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayLabel;
import org.lwjgl.opengl.GL11;
@@ -2,18 +2,14 @@ package noppes.npcs.client.gui.customoverlay.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayLine;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
public class CustomOverlayLine extends Gui implements IOverlayComponent {
OverlayCustom parent;
int alignment;
@@ -2,23 +2,18 @@ package noppes.npcs.client.gui.customoverlay.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent;
import noppes.npcs.scripted.overlay.ScriptOverlayTexturedRect;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL14.glBlendFuncSeparate;
public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent {
OverlayCustom parent;
int alignment;
@@ -55,7 +50,7 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
texturemanager.loadTexture(this.texture, object);
}
}
@@ -17,7 +17,7 @@ import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.controllers.Bank;
import noppes.npcs.controllers.data.Bank;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData
@@ -8,11 +8,8 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNpcSoundSelection;
import noppes.npcs.client.gui.SubGuiMailmanSendSetup;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.SubGuiNpcCommand;
import noppes.npcs.client.gui.SubGuiNpcDialogExtra;
import noppes.npcs.client.gui.SubGuiNpcDialogOption;
import noppes.npcs.client.gui.SubGuiNpcDialogOptions;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
import noppes.npcs.client.gui.SubGuiNpcTextArea;
@@ -29,9 +26,8 @@ import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogCategory;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogCategory;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, GuiSelectionListener,ICustomScrollListener,ITextfieldListener, IGuiData
@@ -22,7 +22,7 @@ import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener
@@ -5,32 +5,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.apache.logging.log4j.status.StatusConsoleListener;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.SubGuiMailmanSendSetup;
import noppes.npcs.client.gui.SubGuiNpcCommand;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
import noppes.npcs.client.gui.SubGuiNpcTextArea;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollData, ISubGuiListener{
@@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiMailmanSendSetup;
import noppes.npcs.client.gui.SubGuiNpcCommand;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
@@ -32,9 +31,8 @@ import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestCategory;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestCategory;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, GuiSelectionListener,ICustomScrollListener,ITextfieldListener, IGuiData
@@ -21,7 +21,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
@@ -22,7 +22,7 @@ import noppes.npcs.client.gui.util.ISliderListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.SpawnData;
import noppes.npcs.controllers.data.SpawnData;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, IScrollData, ITextfieldListener, ICustomScrollListener, ISliderListener{
@@ -9,7 +9,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.containers.ContainerNpcQuestReward;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
@@ -10,11 +10,8 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.constants.EnumStandingType;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.PlayerMail;
import noppes.npcs.controllers.data.Quest;
public class SubGuiNpcQuestAdvanced extends SubGuiInterface implements ITextfieldListener
{
@@ -15,6 +15,7 @@ import noppes.npcs.client.gui.SubGuiNpcName;
import noppes.npcs.client.gui.model.GuiCreationScreen;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -76,7 +77,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
y+=23;
addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, display.glowTexture));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : ""));
this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture"));
y+=23;
@@ -128,7 +130,11 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
}
else if(textfield.id == 9){
npc.textureGlowLocation = null;
display.glowTexture = textfield.getText();
//display.glowTexture = textfield.getText();
npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay(
textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F,
1.0F, 1.0F, 0.0F, 0.0F, 0.0F
));
}
else if(textfield.id == 11){
display.title = textfield.getText();
@@ -33,7 +33,6 @@ import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityFakeLiving;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.Sys;
public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener{
@@ -229,7 +228,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
npc.display.texture = NPCRendererHelper.getTexture(render,entity);
}
}
npc.display.glowTexture = "";
//npc.display.glowTexture = "";
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -336,7 +336,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol
else{
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
}
npc.display.glowTexture = "";
//npc.display.glowTexture = "";
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -3,7 +3,6 @@ package noppes.npcs.client.gui.model;
import java.util.Collections;
import java.util.Vector;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
@@ -127,7 +126,8 @@ public class GuiEntitySelection extends GuiNPCInterface
else{
npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png";
}
npc.display.glowTexture = "";
//npc.display.glowTexture = "";
npc.display.skinOverlayData.overlayList.remove(0);
npc.textureLocation = null;
npc.textureGlowLocation = null;
npc.updateHitbox();
@@ -21,8 +21,8 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.IGuiClose;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Keyboard;
@@ -13,8 +13,8 @@ import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.PlayerFactionData;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.PlayerFactionData;
import org.lwjgl.opengl.GL11;
@@ -19,8 +19,8 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.PlayerMailData;
import noppes.npcs.controllers.data.PlayerMail;
import noppes.npcs.controllers.data.PlayerMailData;
public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScrollListener, GuiYesNoCallback{
@@ -26,7 +26,7 @@ import noppes.npcs.client.gui.util.IGuiError;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.PlayerMail;
import noppes.npcs.controllers.data.PlayerMail;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -3,7 +3,6 @@ package noppes.npcs.client.gui.player;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.TextBlockClient;
@@ -12,7 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.ITopButtonListener;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import org.lwjgl.opengl.GL11;
@@ -13,16 +13,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.QuestLogData;
import noppes.npcs.client.Client;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.TextBlockClient;
import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiMenuSideButton;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.ITopButtonListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumPlayerPacket;
import org.lwjgl.opengl.GL11;
@@ -33,16 +29,16 @@ import tconstruct.client.tabs.TabRegistry;
public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
private EntityPlayer player;
private GuiCustomScroll scroll;
private HashMap<Integer,GuiMenuSideButton> sideButtons = new HashMap<Integer,GuiMenuSideButton>();
private QuestLogData data = new QuestLogData();
private boolean noQuests = false;
private boolean questDetails = true;
private Minecraft mc = Minecraft.getMinecraft();
public GuiQuestLog(EntityPlayer player) {
super();
this.player = player;
@@ -58,7 +54,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
TabRegistry.addTabsToList(buttonList);
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabQuests.class);
noQuests = false;
if(data.categories.isEmpty()){
@@ -76,10 +72,10 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
i++;
}
sideButtons.get(categories.indexOf(data.selectedCategory)).active = true;
if(scroll == null)
scroll = new GuiCustomScroll(this,0);
scroll.setList(data.categories.get(data.selectedCategory));
scroll.setSize(134, 174);
scroll.guiLeft = guiLeft + 5;
@@ -89,21 +85,32 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
addButton(new GuiButtonNextPage(1, guiLeft + 286, guiTop + 176, true));
addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false));
GuiNpcButton trackingButton = new GuiNpcButton(3, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"Track", "Tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0);
if (trackingButton.displayString.equals("Tracking")) {
trackingButton.packedFGColour = 0x32CD32;
}
addButton(trackingButton);
getButton(1).visible = questDetails && data.hasSelectedQuest();
getButton(2).visible = !questDetails && data.hasSelectedQuest();
getButton(3).visible = !data.selectedQuest.isEmpty() && getButton(1).visible;
}
@Override
protected void actionPerformed(GuiButton guibutton){
if(!(guibutton instanceof GuiButtonNextPage))
return;
if(guibutton.id == 1){
questDetails = false;
initGui();
}
if(guibutton.id == 2){
questDetails = true;
initGui();
}
if(guibutton.id == 3){
if (!data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest)) {
data.trackedQuestKey = data.selectedCategory + ":" + data.selectedQuest;
} else {
data.trackedQuestKey = "";
}
}
initGui();
}
@Override
public void drawScreen(int i, int j, float f){
@@ -115,7 +122,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195);
drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195);
super.drawScreen(i, j, f);
if(noQuests){
mc.fontRenderer.drawString(StatCollector.translateToLocal("quest.noquests"),guiLeft + 84,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
return;
@@ -127,18 +134,17 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
if(!data.hasSelectedQuest())
return;
if(questDetails){
if (questDetails) {
drawProgress();
String title = StatCollector.translateToLocal("gui.text");
mc.fontRenderer.drawString(title, guiLeft + 284 - mc.fontRenderer.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
}
else{
} else {
drawQuestText();
String title = StatCollector.translateToLocal("quest.objectives");
mc.fontRenderer.drawString(title, guiLeft + 168, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
}
GL11.glPushMatrix();
GL11.glTranslatef(guiLeft + 148, guiTop, 0);
GL11.glScalef(1.24f, 1.24f, 1.24f);
@@ -146,21 +152,21 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
GL11.glPopMatrix();
drawHorizontalLine(guiLeft + 142, guiLeft + 312, guiTop + 17, + 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
}
private void drawQuestText(){
TextBlockClient block = new TextBlockClient(data.getQuestText(), 174, true, player);
int yoffset = guiTop + 5;
int yoffset = guiTop + 5;
for(int i = 0; i < block.lines.size(); i++){
String text = block.lines.get(i).getFormattedText();
fontRendererObj.drawString(text, guiLeft + 142, guiTop + 20 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor);
}
}
private void drawProgress() {
String complete = data.getComplete();
if(complete != null && !complete.isEmpty())
mc.fontRenderer.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor);
int yoffset = guiTop + 22;
for(String process : data.getQuestStatus()){
int index = process.lastIndexOf(":");
@@ -179,7 +185,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
yoffset += 10;
}
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
}
@@ -235,10 +241,16 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
this.data = data;
initGui();
}
@Override
@Override
public void onGuiClosed() {
super.onGuiClosed();
this.save();
}
@Override
public void save() {
// TODO Auto-generated method stub
Client.sendData(EnumPacketServer.UpdateTrackedQuest, this.data.trackedQuestKey);
}
}
@@ -1,7 +1,6 @@
package noppes.npcs.client.gui.player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.lwjgl.opengl.GL11;
@@ -18,7 +17,7 @@ import noppes.npcs.client.gui.util.GuiButtonNextPage;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.controllers.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.RecipeController;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -8,13 +8,12 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNPCDialogSelection;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.quests.QuestDialog;
@@ -11,7 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.quests.QuestItem;
@@ -17,7 +17,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.quests.QuestKill;
@@ -2,13 +2,12 @@ package noppes.npcs.client.gui.questtypes;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.quests.QuestLocation;
@@ -11,7 +11,7 @@ import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Bank;
import noppes.npcs.controllers.data.Bank;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleBank;
@@ -6,19 +6,15 @@ import java.util.Vector;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.mainmenu.GuiNpcAdvanced;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNPCStringSlot;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.controllers.data.TransportLocation;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, IGuiData{
@@ -6,13 +6,16 @@
package noppes.npcs.client.gui.script;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomNpcs;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer;
import org.lwjgl.opengl.GL11;
public class GuiScriptGlobal extends GuiNPCInterface {
public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData {
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png");
public GuiScriptGlobal() {
@@ -24,16 +27,20 @@ public class GuiScriptGlobal extends GuiNPCInterface {
public void initGui() {
super.initGui();
Client.sendData(EnumPacketServer.ScriptGlobalGuiDataGet, new Object[0]);
}
public void setGuiData(NBTTagCompound compound) {
GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players");
playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled);
playerButton.setEnabled(compound.getBoolean("PlayerScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
this.addButton(playerButton);
GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge");
forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled);
forgeButton.setEnabled(compound.getBoolean("ForgeScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
this.addButton(forgeButton);
GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs");
npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled);
npcButton.setEnabled(compound.getBoolean("GlobalNPCScriptsEnabled") && compound.getBoolean("ScriptsEnabled"));
this.addButton(npcButton);
}
@@ -20,7 +20,6 @@ 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;
@@ -37,6 +36,7 @@ import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.NPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.apache.commons.lang3.StringUtils;
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener {
@@ -165,6 +165,21 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
hookList.add("dialogClose");
hookList.add("timer");
}
else if(handler instanceof ScriptCustomItem) {
hookList.add("init");
hookList.add("tick");
hookList.add("tossed");
hookList.add("pickedUp");
hookList.add("spawn");
hookList.add("interact");
hookList.add("attack");
hookList.add("startItem");
hookList.add("usingItem");
hookList.add("stopItem");
hookList.add("finishItem");
//hookList.add("");
//hookList.add("");
}
else if(handler instanceof ForgeDataScript) {
hooks.setSize(238, 198);
hooks.guiLeft = guiLeft - 240;
@@ -0,0 +1,28 @@
package noppes.npcs.client.gui.script;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomItems;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.scripted.item.ScriptCustomItem;
public class GuiScriptItem extends GuiScriptInterface {
private ScriptCustomItem item;
public GuiScriptItem(EntityPlayer player) {
this.handler = this.item = new ScriptCustomItem(new ItemStack(CustomItems.scripted_item));
Client.sendData(EnumPacketServer.ScriptItemDataGet, new Object[0]);
}
public void setGuiData(NBTTagCompound compound) {
this.item.setMCNbt(compound);
super.setGuiData(compound);
}
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptItemDataSave, new Object[]{this.item.getMCNbt()});
}
}
@@ -125,6 +125,7 @@ public abstract class GuiContainerNPCInterface extends GuiContainer
public void buttonEvent(GuiButton guibutton){};
public void close(){
Keyboard.enableRepeatEvents(false);
GuiNpcTextField.unfocus();
save();
player.closeScreen();
@@ -155,6 +155,7 @@ public abstract class GuiNPCInterface extends GuiScreen
GuiNpcTextField.unfocus();
}
public void close(){
Keyboard.enableRepeatEvents(false);
displayGuiScreen(null);
mc.setIngameFocus();
save();
@@ -99,6 +99,8 @@ public class GuiNpcMenu implements GuiYesNoCallback{
}
private void close() {
Keyboard.enableRepeatEvents(false);
if(parent instanceof GuiContainerNPCInterface2)
((GuiContainerNPCInterface2)parent).close();
@@ -0,0 +1,521 @@
package noppes.npcs.client.renderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import noppes.npcs.CustomItems;
import noppes.npcs.items.ItemRenderInterface;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import static net.minecraft.client.renderer.entity.RenderItem.renderInFrame;
public class CustomItemRenderer implements IItemRenderer {
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
private static final ResourceLocation enchant = new ResourceLocation("textures/misc/enchanted_item_glint.png");
private final Random random = new Random();
private int entityRenderTicks = 1;
private int item3dRenderTicks = 1;
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
InputStream inputstream = null;
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
if(scriptCustomItem.width == -1 || scriptCustomItem.height == -1) {
try {
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(scriptCustomItem.texture));
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = ImageIO.read(inputstream);
scriptCustomItem.width = bufferedimage.getWidth();
scriptCustomItem.height = bufferedimage.getHeight();
scriptCustomItem.saveItemData();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (inputstream != null) {
inputstream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
if(scriptCustomItem.width == -1 || scriptCustomItem.height == -1)
return;
if (type == ItemRenderType.INVENTORY) {
renderInventoryCustomItem(scriptCustomItem);
return;
}
if (type == ItemRenderType.ENTITY) {
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
GL11.glRotatef(scriptCustomItem.rotationXRate * entityRenderTicks%360, 1, 0, 0);
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
int color = scriptCustomItem.getColor();
float itemRed = (color >> 16 & 255) / 255f;
float itemGreen = (color >> 8 & 255) / 255f;
float itemBlue = (color & 255) / 255f;
GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F);
EntityItem entityItem = (EntityItem) data[1];
renderEntityCustomItem(scriptCustomItem, itemStack, entityItem);
return;
}
GL11.glTranslatef(0.9375F, 0.0625F, 0.0F);
GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F);
((ItemScripted) itemStack.getItem()).renderOffset(scriptCustomItem);
GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ);
GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0);
GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1);
GL11.glRotatef(scriptCustomItem.rotationXRate * item3dRenderTicks %360, 1, 0, 0);
GL11.glRotatef(scriptCustomItem.rotationYRate * item3dRenderTicks %360, 0, 1, 0);
GL11.glRotatef(scriptCustomItem.rotationZRate * item3dRenderTicks %360, 0, 0, 1);
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
int color = scriptCustomItem.getColor();
float itemRed = (color >> 16 & 255) / 255f;
float itemGreen = (color >> 8 & 255) / 255f;
float itemBlue = (color & 255) / 255f;
GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F);
GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.09375F, 0.0625F, 0.0F);
EntityLivingBase entityLivingBase = (EntityLivingBase) data[1];
renderItem3d(scriptCustomItem, entityLivingBase, itemStack);
}
public void renderEntityCustomItem(ScriptCustomItem scriptCustomItem, ItemStack itemStack, EntityItem entityItem) {
this.entityRenderTicks++;
int pass = 0;
float bobbingY = (float)(Math.sin((float)this.entityRenderTicks /40.0F) + 1) * scriptCustomItem.scaleY/6.0F;
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up.
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
ResourceLocation location = new ResourceLocation(scriptCustomItem.texture);
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
Tessellator tessellator = Tessellator.instance;
float f14 = 0.0F;
float f15 = 1.0F;
float f4 = 0.0F;
float f5 = 1.0F;
float f6 = 1.0F;
float f7 = 0.5F;
float f8 = 0.25F;
float f10;
if (RenderManager.instance.options.fancyGraphics)
{
GL11.glPushMatrix();
if (renderInFrame)
{
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
}
else
{
GL11.glRotatef((((float)entityItem.age) / 20.0F + entityItem.hoverStart) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
}
float f9 = 0.0625F;
f10 = 0.021875F;
int j = itemStack.stackSize;
byte b0;
if (j < 2)
{
b0 = 1;
}
else if (j < 16)
{
b0 = 2;
}
else if (j < 32)
{
b0 = 3;
}
else
{
b0 = 4;
}
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
for (int k = 0; k < b0; ++k)
{
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
GL11.glTranslatef(0f, 0f, f9 + f10);
ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, scriptCustomItem.width, scriptCustomItem.height, f9);
if (itemStack.hasEffect(pass))
{
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
float f11 = 0.76F;
GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
float f12 = 0.125F;
GL11.glScalef(f12, f12, f12);
float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
GL11.glTranslatef(f13, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(f12, f12, f12);
f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
GL11.glTranslatef(-f13, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
}
GL11.glPopMatrix();
}
else
{
int j = itemStack.stackSize;
int b0;
if (j < 2)
{
b0 = 1;
}
else if (j < 16)
{
b0 = 2;
}
else if (j < 32)
{
b0 = 3;
}
else
{
b0 = 4;
}
for (int l = 0; l < b0; ++l)
{
GL11.glPushMatrix();
if (l > 0)
{
f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
GL11.glTranslatef(f10, f16, f17);
}
if (!renderInFrame)
{
GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
}
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5);
tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5);
tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4);
tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4);
tessellator.draw();
GL11.glPopMatrix();
}
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
public void renderInventoryCustomItem(ScriptCustomItem scriptCustomItem) {
GL11.glPushMatrix();
int color = scriptCustomItem.getColor();
float itemRed = (color >> 16 & 255) / 255f;
float itemGreen = (color >> 8 & 255) / 255f;
float itemBlue = (color & 255) / 255f;
GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up.
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
ResourceLocation location = new ResourceLocation(scriptCustomItem.texture);
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
renderCustomItemSlot(0,0,16,16, scriptCustomItem.item);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
if (scriptCustomItem.item.hasEffect(0))
{
renderEffect(Minecraft.getMinecraft().getTextureManager(), 0, 0);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
public void renderEffect(TextureManager manager, int x, int y)
{
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
manager.bindTexture(RES_ITEM_GLINT);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
this.renderGlint(x - 2, y - 2, 20, 20);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_)
{
for (int j1 = 0; j1 < 2; ++j1)
{
OpenGlHelper.glBlendFunc(772, 1, 0, 0);
float f = 0.00390625F;
float f1 = 0.00390625F;
float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F;
float f3 = 0.0F;
Tessellator tessellator = Tessellator.instance;
float f4 = 4.0F;
if (j1 == 1)
{
f4 = -1.0F;
}
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1));
tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_4_ + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1));
tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + 0), 0, (double)((f2 + (float)p_77018_4_) * f), (double)((f3 + 0.0F) * f1));
tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + 0), 0, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1));
tessellator.draw();
}
}
public void renderCustomItemSlot(int posX, int posY, int imageWidth, int imageHeight, ItemStack itemStack) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double)(posX), (double)(posY + imageHeight), 0, 0, 1);
tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY + imageHeight), 0, 1, 1);
tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY), 0, 1, 0);
tessellator.addVertexWithUV((double)(posX), (double)(posY), 0, 0, 0);
tessellator.draw();
}
public void renderItem3d(ScriptCustomItem scriptCustomItem, EntityLivingBase entityLivingBase, ItemStack itemStack) {
item3dRenderTicks++;
Minecraft mc = Minecraft.getMinecraft();
TextureManager texturemanager = mc.getTextureManager();
int par3 = 0;
ResourceLocation location = new ResourceLocation(scriptCustomItem.texture);
texturemanager.bindTexture(location);
Tessellator tessellator = Tessellator.instance;
IIcon icon = entityLivingBase.getItemIcon(itemStack, par3);
if (icon == null) {
return;
}
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float f4 = 0.0F;
float f5 = 0.3F;
GL11.glTranslatef(-f4, -f5, 0.0F);
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
renderCustomItemIn2D(itemStack, tessellator, 1.0F, 0.0F, 0.0F, 1.0F, 0.0625F);
if (itemStack.hasEffect(par3)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
texturemanager.bindTexture(enchant);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
float f7 = 0.76F;
GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
float f8 = 0.125F;
GL11.glScalef(f8, f8, f8);
float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
GL11.glTranslatef(f9, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(f8, f8, f8);
f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
GL11.glTranslatef(-f9, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
public static void renderCustomItemIn2D(ItemStack itemStack, Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_)
{
GL11.glEnable(GL11.GL_BLEND);
int width = ItemScripted.GetWrapper(itemStack).width;
int height = ItemScripted.GetWrapper(itemStack).height;
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 0.0F, 1.0F);
p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_);
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 0.0F, -1.0F);
p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_);
p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_);
p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_);
p_78439_0_.draw();
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width;
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height;
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F);
int k;
float f7;
float f8;
for (k = 0; k < width; ++k)
{
f7 = (float)k / (float)width;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(1.0F, 0.0F, 0.0F);
float f9;
for (k = 0; k < width; ++k)
{
f7 = (float)k / (float)width;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
f9 = f7 + 1.0F / (float)width;
p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_);
p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_);
p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, 1.0F, 0.0F);
for (k = 0; k < height; ++k)
{
f7 = (float)k / (float)height;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
f9 = f7 + 1.0F / (float)height;
p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8);
}
p_78439_0_.draw();
p_78439_0_.startDrawingQuads();
p_78439_0_.setNormal(0.0F, -1.0F, 0.0F);
for (k = 0; k < height; ++k)
{
f7 = (float)k / (float)height;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8);
p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8);
}
p_78439_0_.draw();
}
}
Loaded 100 of 300 files, more files were not shown because too many files have changed in this diff. Show more