This commit is contained in:
KAMKEEL committed 2022-02-02 16:20:17 -05:00
commit 0c4ead5752
77 files changed
+3115 -305

No files matched your search

+12
View File
@@ -72,9 +72,15 @@ public class CustomNpcs {
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
public static int NpcNavRange = 32;
@ConfigProp(info = "Size limit for NPCs. Default 100, larger sizes may cause lag on clients and servers that can't take it!")
public static int NpcSizeLimit = 100;
@ConfigProp(info = "Set to true if you want the dialog command option to be able to use op commands like tp etc")
public static boolean NpcUseOpCommands = false;
@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
public static boolean InventoryGuiEnabled = true;
@@ -171,6 +177,12 @@ public class CustomNpcs {
NpcNavRange = 96;
}
if(NpcSizeLimit < 1)
NpcSizeLimit = 1;
if(PlayerQuestCheck < 1)
PlayerQuestCheck = 1;
EnchantInterface.load();
CustomItems.load();
@@ -133,6 +133,9 @@ public class DataDisplay {
glowTexture = nbttagcompound.getString("GlowTexture");
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit;
modelType = nbttagcompound.getInteger("modelType");
showName = nbttagcompound.getInteger("ShowName");
+15 -5
View File
@@ -18,7 +18,7 @@ import noppes.npcs.entity.EntityNPCInterface;
public class DataInventory implements IInventory{
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public HashMap<Integer,Integer> dropchance = new HashMap<Integer,Integer>();
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>();
@@ -38,7 +38,7 @@ public class DataInventory implements IInventory{
nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items));
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
nbttagcompound.setTag("DropChance", NBTTags.nbtIntegerIntegerMap(dropchance));
nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
nbttagcompound.setInteger("LootMode", lootMode);
return nbttagcompound;
@@ -49,7 +49,17 @@ public class DataInventory implements IInventory{
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10)));
dropchance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
if(!nbttagcompound.hasKey("DoubleDropChance")) {
dropchance.clear();
HashMap<Integer, Integer> oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
for(int i = 0; i < oldDropChance.entrySet().size(); i++){
dropchance.put(i, Double.valueOf(oldDropChance.get(i)));
}
} else {
dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10));
}
lootMode = nbttagcompound.getInteger("LootMode");
}
public HashMap<Integer, ItemStack> getWeapons() {
@@ -89,10 +99,10 @@ public class DataInventory implements IInventory{
ItemStack item = items.get(i);
if(item == null)
continue;
int dchance = 100;
double dchance = 100;
if(dropchance.containsKey(i))
dchance = dropchance.get(i);
int chance = npc.worldObj.rand.nextInt(100) + dchance;
double chance = Math.random()*100 + dchance;
if(chance >= 100){
EntityItem e = getEntityItem(item.copy());
if(e != null)
+2 -2
View File
@@ -262,9 +262,9 @@ public class EventHooks {
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown) {
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);
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
+24
View File
@@ -69,6 +69,17 @@ public class NBTTags {
}
return list;
}
public static HashMap<Integer, Double> getIntegerDoubleMap(
NBTTagList tagList) {
HashMap<Integer, Double> list = new HashMap<Integer, Double>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double"));
}
return list;
}
public static HashMap<Integer, Long> getIntegerLongMap(
NBTTagList tagList) {
@@ -239,6 +250,19 @@ public class NBTTags {
return nbttaglist;
}
public static NBTTagList nbtIntegerDoubleMap(HashMap<Integer, Double> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setDouble("Double", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerLongMap(HashMap<Integer, Long> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
@@ -26,21 +26,7 @@ import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.controllers.Bank;
import noppes.npcs.controllers.BankController;
import noppes.npcs.controllers.BankData;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.DialogOption;
import noppes.npcs.controllers.Line;
import noppes.npcs.controllers.PlayerBankData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.PlayerTransportData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.controllers.TransportLocation;
import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
@@ -303,13 +289,14 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
}
public static void questCompletion(EntityPlayerMP player, int questId) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
QuestData data = playerdata.activeQuests.get(questId);
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
QuestData data = questData.activeQuests.get(questId);
if(data == null)
return;
if(!data.quest.questInterface.isCompleted(player))
if(!data.quest.questInterface.isCompleted(playerData))
return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
@@ -3,6 +3,8 @@ 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;
@@ -16,11 +18,7 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.constants.EnumCompanionTalent;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.constants.*;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityNPCInterface;
@@ -66,7 +64,31 @@ public class PacketHandlerPlayer{
return;
}
EventHooks.onPlayerKeyPressed(player, buffer.readInt(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean());
int button = buffer.readInt();
boolean isCtrlPressed = buffer.readBoolean();
boolean isShiftPressed = buffer.readBoolean();
boolean isAltPressed = buffer.readBoolean();
boolean isMetaPressed = buffer.readBoolean();
boolean buttonDown = buffer.readBoolean();
String ints = Server.readString(buffer);
String[] split = ints.split(",");
int[] keysDown;
if(ints.length() > 0) {
keysDown = new int[split.length];
try {
for (int i = 0; i < split.length; i++) {
keysDown[i] = Integer.parseInt(split[i]);
}
}
catch (NumberFormatException ignored){
}
} else {
keysDown = new int[0];
}
EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
}
else if(type == EnumPlayerPacket.MouseClicked) {
if(ScriptController.Instance.languages.isEmpty()) {
@@ -135,8 +157,9 @@ public class PacketHandlerPlayer{
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
}
else if(type == EnumPlayerPacket.CheckQuestCompletion){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
playerdata.checkQuestCompletion(player, null);
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
questData.checkQuestCompletion(playerData, null);
}
else if(type == EnumPlayerPacket.QuestLog){
NoppesUtilPlayer.sendQuestLogData(player);
+4 -2
View File
@@ -6,6 +6,8 @@ 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.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.Quest;
@@ -34,7 +36,7 @@ public class QuestLogData {
}
public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(Quest quest : PlayerQuestController.getActiveQuests(player))
{
String category = quest.category.title;
@@ -46,7 +48,7 @@ public class QuestLogData {
questText.put(category + ":" + quest.title, quest.logText);
questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player));
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(player))
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(category + ":" + quest.title, quest.completerNpc);
}
}
@@ -46,15 +46,13 @@ 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.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ForgeEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import org.lwjgl.input.Mouse;
public class ScriptPlayerEventHandler {
@@ -74,9 +72,16 @@ public class ScriptPlayerEventHandler {
EventHooks.onPlayerTick(handler, scriptPlayer);
}
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
if(PlayerDataController.instance != null) {
if(PlayerDataController.instance.getPlayerData(player).timers.size() > 0)
PlayerDataController.instance.getPlayerData(player).timers.update();
if(playerData.timers.size() > 0)
playerData.timers.update();
}
if(player.ticksExisted%(20*CustomNpcs.PlayerQuestCheck) == 0){
PlayerQuestData questData = playerData.questData;
for(EnumQuestType e : EnumQuestType.values())
questData.checkQuestCompletion(playerData, e);
}
}
}
@@ -21,7 +21,6 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -43,7 +42,6 @@ import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.quests.QuestKill;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.scripted.event.ForgeEvent;
public class ServerEventsHandler {
@@ -293,11 +291,12 @@ public class ServerEventsHandler {
}
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
boolean change = false;
String entityName = EntityList.getEntityString(entity);
for(QuestData data : playerdata.activeQuests.values()){
for(QuestData data : questData.activeQuests.values()){
if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue;
if(data.quest.type == EnumQuestType.AreaKill && all){
@@ -309,6 +308,8 @@ public class ServerEventsHandler {
}
String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface;
if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface))
continue;
if(quest.targets.containsKey(entity.getCommandSenderName()))
name = entity.getCommandSenderName();
else if(!quest.targets.containsKey(name))
@@ -326,15 +327,16 @@ public class ServerEventsHandler {
if(!change)
return;
playerdata.checkQuestCompletion(player,EnumQuestType.Kill);
questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
}
@SubscribeEvent
public void pickUp(EntityItemPickupEvent event){
if(event.entityPlayer.worldObj.isRemote)
return;
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(event.entityPlayer).questData;
playerdata.checkQuestCompletion(event.entityPlayer, EnumQuestType.Item);
PlayerData playerData = PlayerDataController.instance.getPlayerData(event.entityPlayer);
PlayerQuestData questData = playerData.questData;
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
}
@SubscribeEvent
@@ -10,6 +10,7 @@ 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.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
@@ -43,15 +44,16 @@ public class TileWaypoint extends TileEntity {
if(toCheck.isEmpty())
return;
for(EntityPlayer player : toCheck){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
for(QuestData data : playerdata.activeQuests.values()){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
for(QuestData data : questData.activeQuests.values()){
if(data.quest.type != EnumQuestType.Location)
continue;
QuestLocation quest = (QuestLocation) data.quest.questInterface;
if(quest.setFound(data, name)){
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
playerdata.checkQuestCompletion(player, EnumQuestType.Location);
questData.checkQuestCompletion(playerData, EnumQuestType.Location);
}
}
}
@@ -4,13 +4,16 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.HashMap;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.constants.EnumPacketServer;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
public class Client {
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer();
@@ -1,5 +1,18 @@
package noppes.npcs.client;
public class ClientEventHandler {
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import org.lwjgl.opengl.GL11;
public class ClientEventHandler {
@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Post event){
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
for (OverlayCustom overlayCustom : Client.customOverlays.values()) {
overlayCustom.renderGameOverlay(event.partialTicks);
}
}
}
}
@@ -78,7 +78,18 @@ public class ClientTickHandler{
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
boolean keyDown = Keyboard.isKeyDown(key);
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown)});
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)){
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
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()});
}
}
@@ -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.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.player.GuiBook;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCInterface;
@@ -259,5 +260,15 @@ public class PacketHandlerClient extends PacketHandlerServer{
NoppesUtil.isGUIOpen(isGUIOpen);
}
else if(type == EnumPacketClient.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){
int id = buffer.readInt();
Client.customOverlays.remove(id);
}
}
}
@@ -74,6 +74,15 @@ public class EntityCustomFX extends EntityFX {
location = new ResourceLocation(directory);
}
/*
par2 = partial tick time
par3 = ActiveRenderInfo.rotationX;
par4 = ActiveRenderInfo.rotationZ;
par5 = ActiveRenderInfo.rotationYZ;
par6 = ActiveRenderInfo.rotationXY;
par7 = ActiveRenderInfo.rotationXZ;
*/
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
@@ -121,12 +130,16 @@ public class EntityCustomFX extends EntityFX {
Minecraft minecraft = Minecraft.getMinecraft();
EntityPlayer player = minecraft.thePlayer;
double yaw = (player.rotationYaw/180)*Math.PI;
double pitch = (player.rotationPitch/180)*Math.PI;
double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
double angleRad = (angle/180)*Math.PI;
double diffX = player.posX - this.startX;
double diffY = player.posY - player.getYOffset() - this.startY;
double diffZ = player.posZ - this.startZ;
double yaw = (player.rotationYaw/180)*Math.PI;
double pitch = (player.rotationPitch/180)*Math.PI;
double angleX = Math.sin(yaw)*Math.cos(pitch);
if(Math.abs(angleX) < 0.0001){
angleX = 0.0D;
@@ -140,13 +153,62 @@ public class EntityCustomFX extends EntityFX {
angleZ = 0.0D;
}
double translateX = 0;
double angleXtranslateX = 0.0D;
double angleXtranslateY = 0.0D;//(-diffY + Math.cos(angleRad)*diffY) + (-Math.sin(angleRad)*diffZ);
double angleXtranslateZ = 0.0D;//(Math.sin(angleRad)*diffY) + (-diffZ + Math.cos(angleRad)*diffZ);
double angleYtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (Math.sin(angleRad)*diffZ);
double angleYtranslateY = 0.0D;
double angleYtranslateZ = 0.0D;//(-Math.sin(angleRad)*diffX) + (-diffZ + Math.cos(angleRad)*diffZ);
double angleZtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (-Math.sin(angleRad)*diffY);
double angleZtranslateY = 0.0D;//(Math.sin(angleRad)*diffX) + (-diffY + Math.cos(angleRad)*diffY);
double angleZtranslateZ = 0.0D;
double translateX = angleXtranslateX + angleYtranslateX + angleZtranslateX;
double translateY = angleXtranslateY + angleYtranslateY + angleZtranslateY;
double translateZ = angleXtranslateZ + angleYtranslateZ + angleZtranslateZ;
//distance in the X & Z plane
double distXZ = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffZ,2));
//distance in the X & Y plane
double distXY = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffY,2));
//distance in the Y & Z plane
double distYZ = Math.sqrt(Math.pow(diffY,2) + Math.pow(diffZ,2));
double signDiffX = Math.signum(diffX);
double signDiffY = Math.signum(diffY);
double signDiffZ = Math.signum(diffZ);
double angleXtoNorm = Math.sin(Math.acos(diffX/distXZ));
double angleZtoNorm = Math.sin(Math.acos(diffZ/distXZ));
double angleDiffX = (Math.abs(Math.cos(yaw))-angleXtoNorm);
double angleDiffZ = (Math.abs(Math.cos(yaw))-angleZtoNorm);
double translateX = -Math.abs(angleDiffX*angleZ*distXZ)*signDiffX;
double translateY = 0;
double translateZ = 0;
double translateZ = -Math.abs(angleDiffX*angleX*distXZ)*signDiffZ + Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ;
if(minecraft.currentScreen == null) {
System.out.println();
//System.out.printf("diffX: %f, diffY: %f, diffZ: %f\n", diffX, diffY, diffZ);
//System.out.printf("angleX: %f, angleY: %f, angleZ: %f\n", angleX, angleY, angleZ);
//System.out.printf("angleXtoNorm: %f, angleZtoNorm: %f\n", angleXtoNorm, angleZtoNorm);
System.out.printf("Math.sin(yaw): %f\n", Math.sin(yaw));
System.out.printf("Math.cos(yaw): %f\n", Math.cos(yaw));
//System.out.printf("Math.sin(pitch): %f\n", Math.sin(pitch));
//System.out.printf("Math.cos(pitch): %f\n", Math.cos(pitch));
System.out.printf("angleDiffX: %f\n", angleDiffX);
System.out.printf("angleDiffZ: %f\n", angleDiffZ);
System.out.printf("translateX: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleZ*distXZ)*signDiffX);
System.out.printf("translateZ: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ);
}
*/
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1.0F);
//GL11.glTranslated(translateX,translateY,translateZ);
//GL11.glRotated(angle, angleX, angleY, angleZ);
@@ -130,8 +130,16 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) {
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);
IGuiComponent component = (IGuiComponent)var4.next();
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
if (this.hoverText != null) {
@@ -429,6 +437,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
this.components.put(scroll.getID(), scroll);
this.addDataHolder(scroll);
this.addClickListener(scroll);
break;
case 6:
CustomGuiLine line = CustomGuiLine.fromComponent((ScriptGuiLine) component);
this.components.put(line.getID(),line);
break;
}
}
@@ -6,12 +6,16 @@
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.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 org.lwjgl.opengl.GL11;
@@ -23,17 +27,17 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public int textureY;
boolean field_146123_n;
String label;
int colour;
String[] hoverText;
int color;
float alpha;
public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText);
this.colour = 16777215;
}
public CustomGuiButton(int id, String buttonText, int x, int y, int width, int height) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height, buttonText);
this.colour = 16777215;
}
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture) {
@@ -46,6 +50,12 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
this.textureY = textureY;
this.label = buttonText;
this.texture = new ResourceLocation(texture);
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(GuiCustom parent) {
@@ -66,6 +76,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY());
}
btn.color = component.getColor();
btn.alpha = component.getAlpha();
if (component.hasHoverText()) {
btn.hoverText = component.getHoverText();
}
@@ -81,59 +94,59 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
//GL11.func_179094_E();
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
FontRenderer fontRenderer = mc.fontRenderer;
int i;
if (this.texture == null) {
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (this.packedFGColour != 0) {
j = this.packedFGColour;
} else if (!this.enabled) {
j = 10526880;
} else if (this.field_146123_n) {
j = 16777120;
}
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j);
} else {
mc.getTextureManager().bindTexture(this.texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.hoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.colour);
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
FontRenderer fontRenderer = mc.fontRenderer;
int i;
if (this.texture == null) {
mc.getTextureManager().bindTexture(buttonTextures);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (this.packedFGColour != 0) {
j = this.packedFGColour;
} else if (!this.enabled) {
j = 10526880;
} else if (this.field_146123_n) {
j = 16777120;
}
GL11.glTranslated(0.0D, 0.0D, 0.1D);
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j);
} else {
mc.getTextureManager().bindTexture(this.texture);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.hoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.color);
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
}
GL11.glPopMatrix();
}
public ICustomGuiComponent toComponent() {
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture.toString(), this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setColor(this.color);
component.setAlpha(this.alpha);
return component;
}
public void setColour(int colour) {
this.colour = colour;
}
protected int hoverState(boolean mouseOver) {
int i = 0;
if (mouseOver) {
@@ -5,53 +5,113 @@
package noppes.npcs.client.gui.custom.components;
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 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;
GuiCustom parent;
String fullLabel;
int color;
String[] hoverText;
float scale;
int id;
int border = 2;
boolean labelBgEnabled = true;
boolean labelShadowEnabled = false;
int color;
float alpha;
float rotation;
protected int field_146167_a;
protected int field_146161_f;
public int field_146162_g;
public int field_146174_h;
private ArrayList field_146173_k;
private boolean field_146170_l;
public boolean field_146172_j;
private boolean field_146171_m;
private int field_146168_n;
private int field_146169_o;
private int field_146166_p;
private int field_146165_q;
private FontRenderer field_146164_r;
private int field_146163_s;
private static final String __OBFID = "CL_00000671";
public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height){
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];
protected final ResourceLocation locationFontTexture;
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;
public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){
this.id = id;
this.fullLabel = fullLabel;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.labelShadowEnabled = shadow;
locationFontTexture = new ResourceLocation("textures/font/ascii.png");
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 setParent(GuiCustom parent) {
@@ -75,14 +135,17 @@ 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());
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow());
lbl.scale = 1.0F;
lbl.color = component.getColor();
lbl.field_146172_j = true;
lbl.setScale(component.getScale());
if (component.hasHoverText()) {
lbl.hoverText = component.getHoverText();
}
lbl.labelShadowEnabled = component.hasShadow();
lbl.color = component.getColor();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
return lbl;
}
@@ -90,34 +153,416 @@ 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.setColor(this.color);
component.setAlpha(this.alpha);
component.setRotation(this.rotation);
return component;
}
public void drawLabel()
{
if (this.field_146172_j)
GL11.glPushMatrix();
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
GL11.glTranslatef(this.x,this.y,0.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
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_)
{
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawLabelBackground();
this.drawString(Minecraft.getMinecraft().fontRenderer, fullLabel, this.x, this.y, this.color);
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);
this.posX = (float)p_78258_2_;
this.posY = (float)p_78258_3_;
this.renderStringAtPos(p_78258_1_, p_78258_5_);
return (int)this.posX;
}
}
protected void drawLabelBackground()
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{
if (this.labelBgEnabled)
for (int i = 0; i < p_78255_1_.length(); ++i)
{
int k = this.width + this.border * 2;
int l = this.height + this.border * 2;
int i1 = this.x - this.border;
int j1 = this.y - this.border;
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor
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_;
}
}
}
@@ -0,0 +1,79 @@
package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
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 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;
int x1;
int y1;
int x2;
int y2;
int color;
float alpha;
float rotation;
int thickness;
public CustomGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.id = id;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
public void setParent(GuiCustom parent) {
this.parent = parent;
}
@Override
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
double distance = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png"));
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,0.0F);
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScaled(thickness, distance,0.0D);
this.drawTexturedModalRect(0,0,0,0, 1, 1);
GL11.glPopMatrix();
}
public ICustomGuiComponent toComponent() {
ScriptGuiLine line = new ScriptGuiLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness);
line.setColor(this.color);
line.setAlpha(this.alpha);
line.setRotation(this.rotation);
return line;
}
public static CustomGuiLine fromComponent(ScriptGuiLine component) {
CustomGuiLine line = new CustomGuiLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness());
line.color = component.getColor();
line.alpha = component.getAlpha();
line.rotation = component.getRotation();
return line;
}
}
@@ -25,6 +25,9 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo
String[] hoverText;
public boolean multiSelect = false;
int color;
float alpha;
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
super(parent, id);
this.mc = mc;
@@ -48,13 +51,17 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize;
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize;
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
GL11.glPopMatrix();
}
@@ -79,11 +86,15 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo
this.hoverText = component.getHoverText();
}
this.color = component.getColor();
this.alpha = component.getAlpha();
}
public ICustomGuiComponent toComponent() {
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0]));
component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component;
}
@@ -16,12 +16,16 @@ 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 org.lwjgl.opengl.GL11;
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
GuiCustom parent;
String[] hoverText;
int id;
int color;
float alpha;
public CustomGuiTextField(int id, int x, int y, int width, int height) {
super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
this.id = id;
@@ -34,7 +38,12 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
this.drawTextBox();
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
}
@@ -59,6 +68,8 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID
ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height);
component.setText(this.getText());
component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component;
}
@@ -72,6 +83,9 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID
txt.setText(component.getText());
}
txt.color = component.getColor();
txt.alpha = component.getAlpha();
return txt;
}
@@ -8,13 +8,21 @@ package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.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 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;
@@ -28,6 +36,10 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float scale;
String[] hoverText;
int color;
float alpha;
float rotation;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
@@ -36,12 +48,18 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
this.scale = 1.0F;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = GuiCustom.guiLeft + x;
this.y = GuiCustom.guiTop + y;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(GuiCustom parent) {
@@ -56,7 +74,36 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(this.texture);
this.drawTexturedModalRect(this.x + this.textureX, this.y + this.textureY, 0, 0, (int)(this.width*this.scale), (int)(this.height*this.scale));
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glColor4f(red,green,blue,this.alpha);
GL11.glScalef(this.scale, this.scale, this.scale);
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
int p_73729_1_ = (int) (this.x/this.scale);
int p_73729_2_ = (int) (this.y/this.scale);
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText;
@@ -67,6 +114,9 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setHoverText(this.hoverText);
component.setScale(this.scale);
component.setColor(color);
component.setAlpha(alpha);
component.setRotation(rotation);
return component;
}
@@ -83,6 +133,10 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
rect.hoverText = component.getHoverText();
}
rect.color = component.getColor();
rect.alpha = component.getAlpha();
rect.rotation = component.getRotation();
return rect;
}
}
@@ -0,0 +1,97 @@
package noppes.npcs.client.gui.customoverlay;
import net.minecraft.client.Minecraft;
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.overlay.*;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class OverlayCustom extends Gui {
protected final Minecraft mc;
private ScaledResolution res = null;
public static int scaledWidth = 0;
public static int scaledHeight = 0;
public ScriptOverlay overlay;
Map<Integer, IOverlayComponent> components = new HashMap();
public OverlayCustom(Minecraft mc) {
this.mc = mc;
}
public void initOverlay(){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
if(this.overlay != null){
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
this.components.clear();
Iterator var1 = this.overlay.getComponents().iterator();
while(var1.hasNext()) {
ICustomOverlayComponent c = (ICustomOverlayComponent)var1.next();
this.addComponent(c);
}
}
}
private void addComponent(ICustomOverlayComponent component) {
ScriptOverlayComponent c = (ScriptOverlayComponent)component;
switch(c.getType()) {
case 0:
CustomOverlayTexturedRect rect = CustomOverlayTexturedRect.fromComponent((ScriptOverlayTexturedRect) component);
rect.setParent(this);
this.components.put(rect.getID(), rect);
break;
case 1:
CustomOverlayLabel lbl = CustomOverlayLabel.fromComponent((ScriptOverlayLabel)component);
lbl.setParent(this);
this.components.put(lbl.getID(), lbl);
break;
case 2:
CustomOverlayLine line = CustomOverlayLine.fromComponent((ScriptOverlayLine) component);
line.setParent(this);
this.components.put(line.getID(), line);
break;
}
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) {
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);
IOverlayComponent component = (IOverlayComponent)var4.next();
component.onRender(this.mc, partialTicks);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
}
public void setOverlayData(NBTTagCompound compound) {
this.overlay = (ScriptOverlay)(new ScriptOverlay()).fromNBT(compound);
this.initOverlay();
}
}
@@ -0,0 +1,553 @@
package noppes.npcs.client.gui.customoverlay.components;
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.Gui;
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.overlay.ScriptOverlayLabel;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
public class CustomOverlayLabel extends Gui implements IOverlayComponent {
OverlayCustom parent;
int id;
String fullLabel;
int x, y, width, height, alignment;
float scale, rotation;
int color;
float alpha;
int border = 2;
boolean labelBgEnabled = true;
boolean labelShadowEnabled = false;
protected int field_146167_a;
protected int field_146161_f;
public int field_146162_g;
public int field_146174_h;
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];
protected final ResourceLocation locationFontTexture;
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;
public CustomOverlayLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){
this.id = id;
this.fullLabel = fullLabel;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.labelShadowEnabled = shadow;
locationFontTexture = new ResourceLocation("textures/font/ascii.png");
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 setParent(OverlayCustom parent) {
this.parent = parent;
}
public void onRender(Minecraft mc, float partialTicks) {
this.drawLabel();
}
public int getID() {
return this.id;
}
public void setScale(float scale) {
this.scale = scale;
}
public static CustomOverlayLabel fromComponent(ScriptOverlayLabel component) {
CustomOverlayLabel lbl = new CustomOverlayLabel(component.getID(), component.getText(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getShadow());
lbl.scale = 1.0F;
lbl.color = component.getColor();
lbl.labelShadowEnabled = component.getShadow();
lbl.alignment = component.getAlignment();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
lbl.setScale(component.getScale());
return lbl;
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayLabel component = new ScriptOverlayLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color);
component.setShadow(this.labelShadowEnabled);
component.setAlignment(alignment);
component.setAlpha(alpha);
component.setColor(color);
component.setRotation(rotation);
return component;
}
public void drawLabel()
{
GL11.glPushMatrix();
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
GL11.glTranslatef(this.x,this.y,0.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScalef(this.scale, this.scale, this.scale);
this.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled);
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);
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_;
}
}
}
@@ -0,0 +1,104 @@
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.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;
int id;
int x1;
int y1;
int x2;
int y2;
int color;
int thickness;
float alpha;
float rotation;
public CustomOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.id = id;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
public void setParent(OverlayCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, float partialTicks) {
double distance = Math.hypot(x1-x2, y1-y2);
mc.getTextureManager().bindTexture(new ResourceLocation("customnpcs:textures/gui/misc.png"));
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
GL11.glTranslatef(this.x1,this.y1,0.0F);
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
GL11.glScaled(thickness, distance,0.0D);
int p_73729_1_ = 0;
int p_73729_2_ = 0;
int p_73729_3_ = 0;
int p_73729_4_ = 0;
int p_73729_5_ = 1;
int p_73729_6_ = 1;
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayLine line = new ScriptOverlayLine(this.id, this.x1,this.y1,this.x2,this.y2,this.color,this.thickness);
line.setAlignment(alignment);
line.setAlpha(alpha);
line.setColor(color);
line.setRotation(rotation);
return line;
}
public static CustomOverlayLine fromComponent(ScriptOverlayLine component) {
CustomOverlayLine line = new CustomOverlayLine(component.getID(), component.getX1(), component.getY1(), component.getX2(), component.getY2(), component.getColor(), component.getThickness());
line.alignment = component.getAlignment();
line.alpha = component.getAlpha();
line.color = component.getColor();
line.rotation = component.getRotation();
return line;
}
}
@@ -0,0 +1,132 @@
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.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;
int id;
ResourceLocation texture;
int x;
int y;
int width;
int height;
int textureX;
int textureY;
float scale;
int color;
float alpha;
float rotation;
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0);
}
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this.scale = 1.0F;
this.alignment = 0;
this.id = id;
this.texture = new ResourceLocation(texture);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.textureX = textureX;
this.textureY = textureY;
if(texture.startsWith("https://")){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false));
texturemanager.loadTexture(this.texture, object);
}
}
public void setParent(OverlayCustom parent) {
this.parent = parent;
}
public int getID() {
return this.id;
}
public void onRender(Minecraft mc, float partialTicks) {
mc.getTextureManager().bindTexture(this.texture);
GL11.glPushMatrix();
float red = (color >> 16 & 255) / 255f;
float green = (color >> 8 & 255) / 255f;
float blue = (color & 255) / 255f;
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);//alignment%3 * width/2 Math.floor(alignment/3) * height/2
GL11.glScalef(this.scale, this.scale, this.scale);
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
int p_73729_1_ = (int) (this.x/this.scale);
int p_73729_2_ = (int) (this.y/this.scale);
int p_73729_3_ = this.textureX;
int p_73729_4_ = this.textureY;
int p_73729_5_ = (int)(this.width);
int p_73729_6_ = (int)(this.height);
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.setColorRGBA_F(red, green, blue, alpha);
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
tessellator.draw();
GL11.glPopMatrix();
}
public ICustomOverlayComponent toComponent() {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
component.setScale(scale);
component.setAlignment(alignment);
component.setAlpha(alpha);
component.setColor(color);
component.setRotation(rotation);
return component;
}
public static CustomOverlayTexturedRect fromComponent(ScriptOverlayTexturedRect component) {
CustomOverlayTexturedRect rect;
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
rect = new CustomOverlayTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTextureX(), component.getTextureY());
} else {
rect = new CustomOverlayTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
}
rect.scale = component.getScale();
rect.alignment = component.getAlignment();
rect.alpha = component.getAlpha();
rect.color = component.getColor();
rect.rotation = component.getRotation();
return rect;
}
}
@@ -0,0 +1,7 @@
package noppes.npcs.client.gui.customoverlay.interfaces;
import net.minecraft.client.Minecraft;
public interface IOverlayComponent {
void onRender(Minecraft mc, float partialTicks);
}
@@ -6,29 +6,30 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcSlider;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.ISliderListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListener, IGuiData
public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, ITextfieldListener
{
private HashMap<Integer,Integer> chances = new HashMap<Integer, Integer>();
private HashMap<Integer,Double> chances = new HashMap<Integer, Double>();
private ContainerNPCInv container;
private ResourceLocation slot;
private int inventoryTab = 0;
public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container)
{
super(npc,container,3);
@@ -56,25 +57,58 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5));
addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101));
for(int i = 0; i < 9; i++){
int chance = 100;
if(npc.inventory.dropchance.containsKey(i)){
chance = npc.inventory.dropchance.get(i);
}
if(chance <= 0 || chance > 100)
chance = 100;
chances.put(i, chance);
GuiNpcSlider slider = new GuiNpcSlider(this, i, guiLeft + 211, guiTop + 14 + i * 21, ((float)chance)/100);
addSlider(slider);
addLabel(new GuiNpcLabel(4,"Tab", guiLeft + 381, guiTop + 5));
addButton(new GuiNpcButton(11, guiLeft + 375, guiTop + 13, 30, 20, "1"));
addButton(new GuiNpcButton(12, guiLeft + 375, guiTop + 34, 30, 20, "2"));
for(int c = 0; c < 4; c++) {
for (int r = 0; r < 9; r++) {
double chance = 100;
if (npc.inventory.dropchance.containsKey(r + c*9)) {
chance = npc.inventory.dropchance.get(r + c*9);
}
if (chance <= 0 || chance > 100)
chance = 100;
chances.put(r + c*9, chance);
if(Math.floor((float)c/2) != this.inventoryTab) {
container.getSlot(r + c*9 + 7).xDisplayPosition = 10000;
container.getSlot(r + c*9 + 7).yDisplayPosition = 10000;
continue;
} else {
container.getSlot(r + c*9 + 7).xDisplayPosition = 191 + (c-this.inventoryTab*2) * 90;
container.getSlot(r + c*9 + 7).yDisplayPosition = 16 + r * 21;
}
GuiNpcTextField textField = new GuiNpcTextField(2 + r + c*9, this, fontRendererObj, guiLeft + 210 + (c-this.inventoryTab*2)*90, guiTop + 14 + r * 21, 60, 18, chance + "");
addLabel(new GuiNpcLabel(c*9 + r + 5,"%", guiLeft + 272 + (c-this.inventoryTab*2)*90, guiTop + 16 + r * 21));
textField.doublesOnly = true;
textField.setMinMaxDefaultDouble(0, 100, 100);
addTextField(textField);
}
}
}
private void drawSlot(int x, int y)
{
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
this.mc.getTextureManager().bindTexture(slot);
this.drawTexturedModalRect(x, y, 0,0,18, 18);
GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up
GL11.glEnable(GL11.GL_LIGHTING);
}
@Override
protected void actionPerformed(GuiButton guibutton) {
if(guibutton.id == 10){
npc.inventory.lootMode = ((GuiNpcButton)guibutton).getValue();
}
if(guibutton.id == 11 || guibutton.id == 12){
this.inventoryTab = Integer.parseInt(guibutton.displayString)-1;
initGui();
}
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
@@ -82,12 +116,18 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
super.drawGuiContainerBackgroundLayer(f, i, j);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(slot);
for(int id = 4; id <= 6;id++){
Slot slot = container.getSlot(id);
if(slot.getHasStack())
drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition -1, 0, 0, 18, 18);
}
for(int c = 0; c < 2; c++) {
for (int r = 0; r < 9; r++) {
this.drawSlot(guiLeft + 190 + c*90, guiTop + 15 + r * 21);
}
}
}
public void drawScreen(int i, int j, float f)
{
@@ -149,18 +189,12 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
npc.inventory.readEntityFromNBT(compound);
initGui();
}
@Override
public void mouseDragged(GuiNpcSlider guiNpcSlider) {
guiNpcSlider.displayString = StatCollector.translateToLocal("inv.dropChance") + ": " + (int) (guiNpcSlider.sliderValue * 100) + "%";
}
@Override
public void mousePressed(GuiNpcSlider guiNpcSlider) {
}
@Override
public void mouseReleased(GuiNpcSlider guiNpcSlider) {
chances.put(guiNpcSlider.id, (int) (guiNpcSlider.sliderValue * 100));
}
@Override
public void unFocused(GuiNpcTextField textfield) {
if(textfield.id >= 2){
chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
this.save();
}
}
}
@@ -141,7 +141,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
}
else if (button.id == 17) {
ai.tacticalVariant = EnumNavType.values()[button.getValue()];
ai.directLOS = EnumNavType.values()[button.getValue()] == EnumNavType.Stalk ? false : this.ai.directLOS;
ai.directLOS = EnumNavType.values()[button.getValue()] != EnumNavType.Stalk && this.ai.directLOS;
initGui();
}
else if (button.id == 22) {
@@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
@@ -56,7 +57,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
getTextField(2).setMinMaxDefault(1, CustomNpcs.NpcSizeLimit, 5);
//addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
y+=23;
@@ -37,29 +37,35 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
quest = (QuestKill) q.questInterface;
setBackground("menubg.png");
xSize = 356;
ySize = 216;
setBackground("largebg.png");
bgScale = 1.7F;
bgScaleX = 1.1F;
xSize = 300;
ySize = 300;
closeOnEsc = true;
}
public void initGui() {
super.initGui();
guiTop -= 20;
int i = 0;
addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 50));
addLabel(new GuiNpcLabel(0, "You can fill in npc or player names too", guiLeft + 4, guiTop + 20));
for (String name : quest.targets.keySet()) {
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + ""));
this.getTextField(i+3).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, name));
this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + ""));
this.getTextField(i+12).integersOnly = true;
this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
i++;
}
for(;i < 3; i++){
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, ""));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1"));
this.getTextField(i+3).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
for(;i < 12; i++){
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, ""));
this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1"));
this.getTextField(i+12).integersOnly = true;
this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
}
Map<?,?> data = EntityList.stringToClassMapping;
ArrayList<String> list = new ArrayList<String>();
@@ -78,9 +84,13 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
scroll.setList(list);
scroll.setSize(130, 198);
scroll.guiLeft = guiLeft + 220;
scroll.guiTop = guiTop + 14;
scroll.guiTop = guiTop + 40;
addScroll(scroll);
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back"));
guiTop += 50;
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 300, 98, 20, "gui.back"));
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs"}, quest.targetType));
guiTop -= 50;
scroll.visible = GuiNpcTextField.isFieldActive();
}
@@ -90,6 +100,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
if (guibutton.id == 0) {
close();
}
if (guibutton.id == 1) {
quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0;
}
}
public void mouseClicked(int i, int j, int k)
{
@@ -101,18 +114,18 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
@Override
public void unFocused(GuiNpcTextField guiNpcTextField) {
if(guiNpcTextField.id < 3)
if(guiNpcTextField.id < 12)
lastSelected = guiNpcTextField;
saveTargets();
}
private void saveTargets(){
HashMap<String,Integer> map = new HashMap<String,Integer>();
for(int i = 0; i< 3; i++){
for(int i = 0; i< 12; i++){
String name = getTextField(i).getText();
if(name.isEmpty())
continue;
map.put(name, getTextField(i+3).getInteger());
map.put(name, getTextField(i+12).getInteger());
}
quest.targets = map;
}
@@ -45,7 +45,10 @@ public abstract class GuiNPCInterface extends GuiScreen
public int mouseX, mouseY;
public float bgScale = 1;
public float bgScaleX = 1;
public float bgScaleY = 1;
public float bgScaleZ = 1;
public GuiNPCInterface(EntityNPCInterface npc)
{
this.player = Minecraft.getMinecraft().thePlayer;
@@ -102,7 +105,7 @@ public abstract class GuiNPCInterface extends GuiScreen
gui.setWorldAndResolution(mc, 350, 250);
extra.put(gui.id, gui);
}
public void mouseClicked(int i, int j, int k)
{
if(AWTWindow != null)
@@ -202,11 +205,11 @@ public abstract class GuiNPCInterface extends GuiScreen
scrolls.put(scroll.id, scroll);
}
public GuiCustomScroll getScroll(int id){
return scrolls.get(id);
return scrolls.get(id);
}
public abstract void save();
@Override
public void drawScreen(int i, int j, float f){
if(AWTWindow != null){
@@ -223,12 +226,12 @@ public abstract class GuiNPCInterface extends GuiScreen
mouseY = j;
if(drawDefaultBackground && subgui == null)
drawDefaultBackground();
if(background != null && mc.renderEngine != null){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glTranslatef(guiLeft, guiTop, 0);
GL11.glScalef(bgScale, bgScale, bgScale);
GL11.glScalef(bgScale*bgScaleX, bgScale*bgScaleY, bgScale*bgScaleZ);
mc.renderEngine.bindTexture(background);
if(xSize > 256){
drawTexturedModalRect(0, 0, 0, 0, 250, ySize);
@@ -112,8 +112,6 @@ public class RenderCustomNpc extends RenderNPCHumanMale{
@Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
super.doRender(entityliving, d, d1, d2, f, f1);
}
@@ -1,6 +1,6 @@
package noppes.npcs.constants;
public enum EnumPacketClient {
CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN
CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN, OVERLAY_DATA, OVERLAY_CLOSE
}
@@ -16,15 +16,16 @@ public class ContainerNPCInv extends Container{
addSlotToContainer(new Slot(npc.inventory, 5, 81, 40));
addSlotToContainer(new Slot(npc.inventory, 6, 81, 58));
for(int l = 0; l < 9; l++){
addSlotToContainer(new Slot(npc.inventory, l + 7 , 191 , 16 + l * 21));
for(int c = 0; c < 4; c++) {
for (int r = 0; r < 9; r++) {
addSlotToContainer(new Slot(npc.inventory, c*9 + r + 7, 191 + (c%2)*90, 16 + r * 21));
}
}
for(int i1 = 0; i1 < 3; i1++){
for(int l1 = 0; l1 < 9; l1++){
addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, l1 * 18 + 8, 113 + i1 * 18));
}
}
for(int j1 = 0; j1 < 9; j1++){
@@ -3,10 +3,7 @@ package noppes.npcs.controllers;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumGuiType;
@@ -18,6 +15,7 @@ import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.CustomGuiEvent;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import java.io.IOException;
@@ -42,6 +40,15 @@ public class CustomGuiController {
}
}
public static void openOverlay(ScriptPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()});
}
public static boolean updateOverlay(ScriptPlayer player, ScriptOverlay gui) {
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()});
return true;
}
static boolean checkGui(CustomGuiEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (!(player.openContainer instanceof ContainerCustomGui)) {
@@ -239,4 +239,39 @@ public class Dialog implements ICompatibilty, IDialog {
public void setCommand(String command) {
this.command = command;
}
public void setDarkenScreen(boolean darkenScreen) {
this.darkenScreen = darkenScreen;
}
public boolean getDarkenScreen() {
return this.darkenScreen;
}
public void setDisableEsc(boolean disableEsc) {
this.disableEsc = disableEsc;
}
public boolean getDisableEsc() {
return this.disableEsc;
}
public void setShowWheel(boolean showWheel) {
this.showWheel = showWheel;
}
public boolean getShowWheel() {
return this.showWheel;
}
public void setHideNPC(boolean hideNPC) {
this.hideNPC = hideNPC;
}
public boolean getHideNPC() {
return this.hideNPC;
}
public void setSound(String sound) {
this.sound = sound;
}
public String getSound() {
return this.sound;
}
}
@@ -79,24 +79,26 @@ public class PlayerQuestData {
}
public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(QuestData data : activeQuests.values()){
Quest quest = data.quest;
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(player)){
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)){
return data;
}
}
return null;
}
public boolean checkQuestCompletion(EntityPlayer player,EnumQuestType type) {
public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) {
boolean bo = false;
EntityPlayer player = playerData.player;
for(QuestData data : this.activeQuests.values()){
if(data.quest.type != type && type != null)
continue;
QuestInterface inter = data.quest.questInterface;
if(inter.isCompleted(player)){
if(inter.isCompleted(playerData)){
if(!data.isCompleted){
if(!data.quest.complete(player,data)){
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.completed", data.quest.title);
@@ -20,6 +20,7 @@ import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory;
import noppes.npcs.scripted.handler.data.IQuestInterface;
import noppes.npcs.scripted.handler.data.IQuestObjective;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.IPlayer;
@@ -242,4 +243,8 @@ public class Quest implements ICompatibilty, IQuest {
public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems);
}
public IQuestInterface getQuestInterface(){
return this.questInterface;
}
}
@@ -434,7 +434,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
protected void updateAITasks()
{
super.updateAITasks();
try {
super.updateAITasks();
} catch (ConcurrentModificationException ignored){
}
this.getNavigator().onUpdateNavigation();
this.getMoveHelper().onUpdateMoveHelper();
}
@@ -472,10 +476,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
@Override
public boolean attackEntityFrom(DamageSource damagesource, float i) {
if (this.worldObj.isRemote || CustomNpcs.FreezeNPCs || damagesource.damageType.equals("inWall")){
if (this.worldObj.isRemote || CustomNpcs.FreezeNPCs || (damagesource.damageType != null && damagesource.damageType.equals("inWall"))){
return false;
}
if(damagesource.damageType.equals("outOfWorld") && isKilled()){
if(damagesource.damageType != null && damagesource.damageType.equals("outOfWorld") && isKilled()){
reset();
}
i = stats.resistances.applyResistance(damagesource, i);
@@ -14,9 +14,10 @@ import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestDialog;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestDialog extends QuestInterface{
public class QuestDialog extends QuestInterface implements IQuestDialog {
public HashMap<Integer,Integer> dialogs = new HashMap<Integer,Integer>();
@@ -31,9 +32,9 @@ public class QuestDialog extends QuestInterface{
}
@Override
public boolean isCompleted(EntityPlayer player) {
public boolean isCompleted(PlayerData playerData) {
for(int dialogId : dialogs.values())
if(!PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId))
if(!playerData.dialogData.dialogsRead.contains(dialogId))
return false;
return true;
}
@@ -93,17 +94,17 @@ public class QuestDialog extends QuestInterface{
public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
if (progress == 0 && completed) {
data.dialogData.dialogsRead.remove(this.dialog.id);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.saveNBTData(data.getNBT());
}
if (progress == 1 && !completed) {
data.dialogData.dialogsRead.add(this.dialog.id);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
data.saveNBTData(data.getNBT());
}
@@ -117,7 +118,7 @@ public class QuestDialog extends QuestInterface{
}
public boolean isCompleted() {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
return data.dialogData.dialogsRead.contains(this.dialog.id);
}
@@ -4,13 +4,15 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.handler.data.IQuestInterface;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public abstract class QuestInterface {
public abstract class QuestInterface implements IQuestInterface {
public int questId;
public abstract void writeEntityToNBT(NBTTagCompound compound);
public abstract void readEntityFromNBT(NBTTagCompound compound);
public abstract boolean isCompleted(EntityPlayer player);
public abstract boolean isCompleted(PlayerData player);
public abstract void handleComplete(EntityPlayer player);
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
@@ -8,11 +8,13 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.NpcMiscInventory;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestItem;
import noppes.npcs.scripted.handler.data.IQuestObjective;
import noppes.npcs.util.ValueUtil;
public class QuestItem extends QuestInterface{
public class QuestItem extends QuestInterface implements IQuestItem {
public NpcMiscInventory items = new NpcMiscInventory(3);
public boolean leaveItems = false;
public boolean ignoreDamage = false;
@@ -35,8 +37,8 @@ public class QuestItem extends QuestInterface{
}
@Override
public boolean isCompleted(EntityPlayer player) {
HashMap<Integer,ItemStack> map = getProcessSet(player);
public boolean isCompleted(PlayerData playerData) {
HashMap<Integer,ItemStack> map = getProcessSet(playerData.player);
for(ItemStack reqItem : items.items.values()){
boolean done = false;
for(ItemStack item : map.values()){
@@ -137,6 +139,27 @@ public class QuestItem extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
public void setLeaveItems(boolean leaveItems){
this.leaveItems = leaveItems;
}
public boolean getLeaveItems(){
return this.leaveItems;
}
public void setIgnoreDamage(boolean ignoreDamage){
this.ignoreDamage = ignoreDamage;
}
public boolean getIgnoreDamage(){
return this.ignoreDamage;
}
public void setIgnoreNbt(boolean ignoreNbt){
this.ignoreNBT = ignoreNbt;
}
public boolean getIgnoreNbt(){
return this.ignoreNBT;
}
class QuestItemObjective implements IQuestObjective {
private final QuestItem parent;
private final EntityPlayer player;
+38 -13
View File
@@ -14,24 +14,37 @@ import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestKill;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestKill extends QuestInterface{
public class QuestKill extends QuestInterface implements IQuestKill {
public HashMap<String,Integer> targets = new HashMap<String,Integer>();
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
}
public int targetType = 0;
@Override
public void writeEntityToNBT(NBTTagCompound compound) {
compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets));
compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets));
//compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets));
compound.setInteger("TargetType",targetType);
}
@Override
public boolean isCompleted(EntityPlayer player) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
public void readEntityFromNBT(NBTTagCompound compound) {
if(!compound.hasKey("QuestKills")) {
targets.clear();
HashMap<String,Integer> oldTargets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
targets.putAll(oldTargets);
} else {
targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestKills", 10));
}
//targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
targetType = compound.getInteger("TargetType");
}
@Override
public boolean isCompleted(PlayerData playerData) {
PlayerQuestData playerdata = playerData.questData;
QuestData data = playerdata.activeQuests.get(questId);
if(data == null)
return false;
@@ -90,6 +103,18 @@ public class QuestKill extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
public void setTargetType(int type) {
if(type < 0)
type = 0;
if(type > 1)
type = 1;
this.targetType = type;
}
public int getTargetType() {
return this.targetType;
}
class QuestKillObjective implements IQuestObjective {
private final QuestKill parent;
private final EntityPlayer player;
@@ -104,7 +129,7 @@ public class QuestKill extends QuestInterface{
}
public int getProgress() {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
@@ -113,15 +138,15 @@ public class QuestKill extends QuestInterface{
public void setProgress(int progress) {
if (progress >= 0 && progress <= this.amount) {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
killed.put(this.entity, progress);
this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[4]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
data.saveNBTData(data.getNBT());
}
} else {
@@ -13,9 +13,10 @@ import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestLocation;
import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestLocation extends QuestInterface{
public class QuestLocation extends QuestInterface implements IQuestLocation {
public String location = "";
public String location2 = "";
public String location3 = "";
@@ -36,8 +37,8 @@ public class QuestLocation extends QuestInterface{
}
@Override
public boolean isCompleted(EntityPlayer player) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
public boolean isCompleted(PlayerData playerData) {
PlayerQuestData playerdata = playerData.questData;
QuestData data = playerdata.activeQuests.get(questId);
if(data == null)
return false;
@@ -118,6 +119,27 @@ public class QuestLocation extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
}
public void setLocation1(String loc1){
this.location = loc1;
}
public String getLocation1(){
return location;
}
public void setLocation2(String loc2){
this.location2 = loc2;
}
public String getLocation2(){
return location2;
}
public void setLocation3(String loc3){
this.location3 = loc3;
}
public String getLocation3(){
return location3;
}
class QuestLocationObjective implements IQuestObjective {
private final QuestLocation parent;
private final EntityPlayer player;
@@ -137,12 +159,12 @@ public class QuestLocation extends QuestInterface{
public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
boolean completed = questData.extraData.getBoolean (this.nbtName);
if ((!completed || progress != 1) && (completed || progress != 0)) {
questData.extraData.setBoolean(this.nbtName, progress == 1);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[3]);
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
data.saveNBTData(data.getNBT());
}
} else {
@@ -155,7 +177,7 @@ public class QuestLocation extends QuestInterface{
}
public boolean isCompleted() {
PlayerData data = PlayerData.get(this.player);
PlayerData data = PlayerDataController.instance.getPlayerData(player);
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
return questData.extraData.getBoolean(this.nbtName);
}
@@ -179,6 +179,16 @@ public class ScriptEntity<T extends Entity> implements IEntity {
entity.velocityChanged = true;
}
public void setMotion(double x, double y, double z){
this.setMotionX(x);
this.setMotionY(y);
this.setMotionZ(z);
}
public boolean isAirborne(){
return entity.isAirBorne;
}
/**
* @return The block x position
*/
@@ -499,12 +509,16 @@ public class ScriptEntity<T extends Entity> implements IEntity {
}
/**
* @return Current rotation of the npc
* @return Current rotation of the entity
*/
public float getRotation(){
return entity.rotationYaw;
}
public void setPitch(float pitch){entity.rotationPitch = pitch;}
public float getPitch(){return entity.rotationPitch;}
/**
* @param power How strong the knockback is
* @param direction The direction in which he flies back (0-360). Usually based on getRotation()
@@ -41,7 +41,10 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
}
public void hurt(float damage, ScriptEntity source) {
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage);
if(source.getType() == 1)//if player
entity.attackEntityFrom(new EntityDamageSource("player",source.getMCEntity()),damage);
else
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage);
}
public void hurt(float damage, ScriptDamageSource damageSource) {
@@ -1,6 +1,7 @@
package noppes.npcs.scripted.entity;
import net.minecraft.item.ItemStack;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.*;
import noppes.npcs.controllers.Line;
@@ -53,6 +54,9 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setSize(int size){
if(size < 1)
size = 1;
if(size > CustomNpcs.NpcSizeLimit)
size = CustomNpcs.NpcSizeLimit;
npc.display.modelSize = size;
npc.script.clientNeedsUpdate = true;
}
@@ -528,7 +532,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param slot The slot from the NPC's drop list to return (0-8)
* @return The chance of dropping the item in this slot. Returns 100 if the slot is not found.
*/
public int getLootChance(int slot) {
public double getLootChance(int slot) {
if(!npc.inventory.dropchance.containsKey(slot))
return 100;
@@ -540,8 +544,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
* @param slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot
*/
public void setLootChance(int slot, int chance) {
if(slot < 0 || slot > 8)
public void setLootChance(int slot, double chance) {
if(!npc.inventory.dropchance.containsKey(slot))
return;
if(chance < 0)
@@ -609,10 +613,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
}
public void setTacticalVariant(int variant){
if(variant > EnumNavType.values().length-1)
if(variant > EnumNavType.values().length-1 || variant < 0)
return;
npc.ai.tacticalVariant = EnumNavType.values()[variant];
npc.ai.directLOS = EnumNavType.values()[variant] != EnumNavType.Stalk && npc.ai.directLOS;
}
public int getTacticalVariant(){
@@ -25,10 +25,8 @@ import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.event.FactionEvent;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
@@ -71,6 +69,22 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
NoppesUtilPlayer.teleportPlayer(player, x, y, z, dimensionId);
}
public int getHunger(){
return player.getFoodStats().getFoodLevel();
}
public void setHunger(int hunger){
player.getFoodStats().setFoodLevel(hunger);
}
public float getSaturation(){
return player.getFoodStats().getSaturationLevel();
}
public void setSaturation(float saturation){
player.getFoodStats().setFoodSaturationLevel(saturation);
}
public int getDimension(){
return player.dimension;
}
@@ -331,6 +345,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
}
}
public void setRotation(float rotationYaw){
NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, player.rotationPitch, player.dimension);
}
public void setRotation(float rotationYaw, float rotationPitch){
NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension);
}
@@ -388,8 +406,9 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
public void updatePlayerInventory() {
((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges();
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
playerdata.checkQuestCompletion((EntityPlayer)this.entity, EnumQuestType.Item);
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData questData = playerData.questData;
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
}
public boolean checkGUIOpen() {
@@ -398,12 +417,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
return data.getGUIOpen();
}
public void checkQuestCompleted() {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
for(EnumQuestType e : EnumQuestType.values())
playerdata.checkQuestCompletion((EntityPlayer)this.entity, e);
}
public ScriptDBCPlayer<T> getDBCPlayer() {
Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c();
Iterator iterator = keySet.iterator();
@@ -459,7 +472,15 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
public void closeGui() {
((EntityPlayerMP)this.entity).closeContainer();
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, new Object[]{-1, new NBTTagCompound()});
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, -1, new NBTTagCompound());
}
public void showCustomOverlay(ICustomOverlay overlay) {
CustomGuiController.openOverlay(this, (ScriptOverlay) overlay);
}
public void closeOverlay(int id) {
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound());
}
public IQuest[] getFinishedQuests() {
@@ -42,8 +42,9 @@ public class PlayerEvent extends CustomNPCsEvent {
public final boolean isShiftPressed;
public final boolean isMetaPressed;
public final boolean keyDown;
public final int[] keysDown;
public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean keyDown) {
public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean keyDown, int[] heldKeys) {
super(player);
this.key = key;
this.isCtrlPressed = isCtrlPressed;
@@ -51,6 +52,11 @@ public class PlayerEvent extends CustomNPCsEvent {
this.isShiftPressed = isShiftPressed;
this.isMetaPressed = isMetaPressed;
this.keyDown = keyDown;
this.keysDown = heldKeys;
for(int i : keysDown){
System.out.println(i);
}
}
}
@@ -13,17 +13,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.IButton;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.IItemSlot;
import noppes.npcs.scripted.interfaces.ILabel;
import noppes.npcs.scripted.interfaces.IScroll;
import noppes.npcs.scripted.interfaces.ITextField;
import noppes.npcs.scripted.interfaces.ITexturedRect;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer;
@@ -170,6 +161,18 @@ public class ScriptGui implements ICustomGui {
return (IScroll)this.components.get(this.components.size() - 1);
}
public ILine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
ScriptGuiLine line = new ScriptGuiLine(id, x1, y1, x2, y2, color, thickness);
this.components.add(line);
return (ILine) this.components.get(this.components.size() - 1);
}
public ILine addLine(int id, int x1, int y1, int x2, int y2) {
ScriptGuiLine line = new ScriptGuiLine(id, x1, y1, x2, y2);
this.components.add(line);
return (ILine) this.components.get(this.components.size() - 1);
}
public void showPlayerInventory(int x, int y) {
this.showPlayerInv = true;
this.playerInvX = x;
@@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
public abstract class ScriptGuiComponent implements ICustomGuiComponent {
int id;
@@ -11,6 +12,10 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
int posY;
String[] hoverText;
int color = 0xFFFFFF;
float alpha = 1.0F;
float rotation = 0;
public ScriptGuiComponent() {
}
@@ -55,11 +60,39 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
return this;
}
public int getColor() {
return this.color;
}
public ICustomGuiComponent setColor(int color) {
this.color = color;
return this;
}
public float getAlpha() {
return this.alpha;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
public float getRotation() {
return rotation;
}
public void setRotation(float rotation) {
this.rotation = rotation;
}
public abstract int getType();
public NBTTagCompound toNBT(NBTTagCompound nbt) {
nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
nbt.setInteger("color", this.color);
nbt.setFloat("alpha",this.alpha);
nbt.setFloat("rotation",this.rotation);
if (this.hoverText != null) {
NBTTagList list = new NBTTagList();
String[] var3 = this.hoverText;
@@ -84,6 +117,9 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
this.setID(nbt.getInteger("id"));
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]);
this.setColor(nbt.getInteger("color"));
this.setAlpha(nbt.getFloat("alpha"));
this.setRotation(nbt.getFloat("rotation"));
if (nbt.hasKey("hover")) {
NBTTagList list = nbt.getTagList("hover", 8);
String[] hoverText = new String[list.tagCount()];
@@ -112,6 +148,8 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
return (new ScriptGuiScroll()).fromNBT(nbt);
case 5:
return (new ScriptGuiItemSlot()).fromNBT(nbt);
case 6:
return (new ScriptGuiLine()).fromNBT(nbt);
default:
return null;
}
@@ -7,21 +7,20 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
String label;
int width;
int height;
int color;
float scale;
boolean shadow;
public ScriptGuiLabel() {
this.color = 16777215;
this.scale = 1.0F;
}
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) {
this.color = 16777215;
this.scale = 1.0F;
this.setID(id);
this.setText(label);
this.setPos(x, y);
this.setSize(width, height);
this.enableShadow(false);
}
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) {
@@ -52,15 +51,6 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
return this;
}
public int getColor() {
return this.color;
}
public ILabel setColor(int color) {
this.color = color;
return this;
}
public float getScale() {
return this.scale;
}
@@ -70,6 +60,14 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
return this;
}
public boolean hasShadow(){
return this.shadow;
}
public void enableShadow(boolean shadow){
this.shadow = shadow;
}
public int getType() {
return 1;
}
@@ -78,8 +76,8 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
super.toNBT(nbt);
nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setInteger("color", this.color);
nbt.setFloat("scale", this.scale);
nbt.setBoolean("shadow",this.shadow);
return nbt;
}
@@ -87,8 +85,8 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
super.fromNBT(nbt);
this.setText(nbt.getString("label"));
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setColor(nbt.getInteger("color"));
this.setScale(nbt.getFloat("scale"));
this.enableShadow(nbt.getBoolean("shadow"));
return this;
}
}
@@ -0,0 +1,98 @@
package noppes.npcs.scripted.gui;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.interfaces.ILine;
public class ScriptGuiLine extends ScriptGuiComponent implements ILine {
int x1;
int y1;
int x2;
int y2;
int thickness = 2;
public ScriptGuiLine(){
}
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2){
this.setPos(x1, y1);
this.setID(id);
this.hoverText = new String[]{""};
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.setPos(x1, y1);
this.setID(id);
this.hoverText = new String[]{""};
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
@Override
public int getType() {
return 6;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setInteger("X1",x1);
nbt.setInteger("Y1",y1);
nbt.setInteger("X2",x2);
nbt.setInteger("Y2",y2);
nbt.setInteger("Thickness",thickness);
return nbt;
}
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
x1 = nbt.getInteger("X1");
y1 = nbt.getInteger("Y1");
x2 = nbt.getInteger("X2");
y2 = nbt.getInteger("Y2");
thickness = nbt.getInteger("Thickness");
return this;
}
public int getX1(){
return this.x1;
}
public int getY1(){
return this.y1;
}
public int getX2(){
return this.x2;
}
public int getY2(){
return this.y2;
}
public int getThickness(){
return this.thickness;
}
public void setX1(int x1){
this.x1 = x1;
}
public void setY1(int y1){
this.y1 = y1;
}
public void setX2(int x2){
this.x2 = x2;
}
public void setY2(int y2){
this.y2 = y2;
}
public void setThickness(int thickness){
this.thickness = thickness;
}
}
@@ -34,5 +34,20 @@ public interface IDialog {
IDialogCategory getCategory();
void setDarkenScreen(boolean darkenScreen);
boolean getDarkenScreen();
void setDisableEsc(boolean disableEsc);
boolean getDisableEsc();
void setShowWheel(boolean showWheel);
boolean getShowWheel();
void setHideNPC(boolean hideNPC);
boolean getHideNPC();
void setSound(String sound);
String getSound();
void save();
}
@@ -44,4 +44,6 @@ public interface IQuest {
void save();
boolean getIsRepeatable();
IQuestInterface getQuestInterface();
}
@@ -0,0 +1,4 @@
package noppes.npcs.scripted.handler.data;
public interface IQuestDialog extends IQuestInterface {
}
@@ -0,0 +1,4 @@
package noppes.npcs.scripted.handler.data;
public interface IQuestInterface {
}
@@ -0,0 +1,12 @@
package noppes.npcs.scripted.handler.data;
public interface IQuestItem extends IQuestInterface {
void setLeaveItems(boolean leaveItems);
boolean getLeaveItems();
void setIgnoreDamage(boolean ignoreDamage);
boolean getIgnoreDamage();
void setIgnoreNbt(boolean ignoreNbt);
boolean getIgnoreNbt();
}
@@ -0,0 +1,6 @@
package noppes.npcs.scripted.handler.data;
public interface IQuestKill extends IQuestInterface {
void setTargetType(int type);
int getTargetType();
}
@@ -0,0 +1,12 @@
package noppes.npcs.scripted.handler.data;
public interface IQuestLocation extends IQuestInterface {
void setLocation1(String loc1);
String getLocation1();
void setLocation2(String loc2);
String getLocation2();
void setLocation3(String loc3);
String getLocation3();
}
@@ -44,6 +44,10 @@ public interface ICustomGui {
IScroll addScroll(int var1, int var2, int var3, int var4, int var5, String[] var6);
ILine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness);
ILine addLine(int id, int x1, int y1, int x2, int y2);
IItemSlot addItemSlot(int var1, int var2);
IItemSlot addItemSlot(int var1, int var2, IItemStack var3);
@@ -299,14 +299,14 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param slot The slot from the NPC's drop list to return (0-8)
* @return The chance of dropping the item in this slot. Returns 100 if the slot is not found.
*/
public int getLootChance(int slot);
public double getLootChance(int slot);
/**
*
* @param slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot
*/
public void setLootChance(int slot, int chance);
public void setLootChance(int slot, double chance);
/**
*
@@ -0,0 +1,4 @@
package noppes.npcs.scripted.interfaces;
public interface ICustomOverlay {
}
@@ -0,0 +1,29 @@
package noppes.npcs.scripted.interfaces;
public interface ICustomOverlayComponent {
int getID();
ICustomOverlayComponent setID(int id);
int getPosX();
int getPosY();
ICustomOverlayComponent setPos(int x, int y);
int getAlignment();
void setAlignment(int alignment);
int getColor();
ICustomOverlayComponent setColor(int color);
float getAlpha();
void setAlpha(float alpha);
float getRotation();
void setRotation(float rotation);
}
@@ -16,10 +16,6 @@ public interface ILabel extends ICustomGuiComponent {
ILabel setSize(int var1, int var2);
int getColor();
ILabel setColor(int var1);
float getScale();
ILabel setScale(float var1);
@@ -0,0 +1,15 @@
package noppes.npcs.scripted.interfaces;
public interface ILine extends ICustomGuiComponent {
int getX1();
int getY1();
int getX2();
int getY2();
int getThickness();
void setX1(int x1);
void setY1(int y1);
void setX2(int x2);
void setY2(int y2);
void setThickness(int thickness);
}
@@ -0,0 +1,17 @@
package noppes.npcs.scripted.interfaces;
public interface IOverlayLabel extends ICustomOverlayComponent {
String getText();
IOverlayLabel setText(String var1);
int getWidth();
int getHeight();
IOverlayLabel setSize(int var1, int var2);
float getScale();
IOverlayLabel setScale(float var1);
}
@@ -0,0 +1,17 @@
package noppes.npcs.scripted.interfaces;
import noppes.npcs.scripted.overlay.ScriptOverlayLine;
public interface IOverlayLine extends ICustomOverlayComponent {
int getX1();
int getY1();
int getX2();
int getY2();
int getThickness();
void setX1(int x1);
void setY1(int y1);
void setX2(int x2);
void setY2(int y2);
void setThickness(int thickness);
}
@@ -0,0 +1,23 @@
package noppes.npcs.scripted.interfaces;
public interface IOverlayTexturedRect extends ICustomOverlayComponent {
String getTexture();
IOverlayTexturedRect setTexture(String var1);
int getWidth();
int getHeight();
IOverlayTexturedRect setSize(int var1, int var2);
float getScale();
IOverlayTexturedRect setScale(float var1);
int getTextureX();
int getTextureY();
IOverlayTexturedRect setTextureOffset(int var1, int var2);
}
@@ -0,0 +1,161 @@
package noppes.npcs.scripted.overlay;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.gui.ScriptGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiItemSlot;
import noppes.npcs.scripted.gui.ScriptGuiLabel;
import noppes.npcs.scripted.gui.ScriptGuiLine;
import noppes.npcs.scripted.interfaces.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ScriptOverlay implements ICustomOverlay {
int id;
int defaultAlignment = 0;
List<ICustomOverlayComponent> components = new ArrayList();
public ScriptOverlay(){
}
public ScriptOverlay(int id){
this.id = id;
}
public int getID() {
return this.id;
}
public List<ICustomOverlayComponent> getComponents() {
return this.components;
}
public PlayerDataScript getScriptHandler() {
return ScriptController.Instance.playerScripts;//this.scriptHandler;
}
public int getDefaultAlignment(){
return this.defaultAlignment;
}
public void setDefaultAlignment(int defaultAlignment) {
this.defaultAlignment = defaultAlignment;
}
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height);
this.components.add(component);
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
}
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height, textureX, textureY);
this.components.add(component);
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
}
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height) {
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height);
this.components.add(component);
return (IOverlayLabel)this.components.get(this.components.size() - 1);
}
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height, int color) {
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height, color);
this.components.add(component);
return (IOverlayLabel)this.components.get(this.components.size() - 1);
}
public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
ScriptOverlayLine line = new ScriptOverlayLine(id, x1, y1, x2, y2, color, thickness);
this.components.add(line);
return (IOverlayLine) this.components.get(this.components.size() - 1);
}
public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2) {
ScriptOverlayLine line = new ScriptOverlayLine(id, x1, y1, x2, y2);
this.components.add(line);
return (IOverlayLine) this.components.get(this.components.size() - 1);
}
public ICustomOverlayComponent getComponent(int componentID) {
Iterator var2 = this.components.iterator();
ICustomOverlayComponent component;
do {
if (!var2.hasNext()) {
return null;
}
component = (ICustomOverlayComponent)var2.next();
} while(component.getID() != componentID);
return component;
}
public void removeComponent(int componentID) {
for(int i = 0; i < this.components.size(); ++i) {
if (((ICustomOverlayComponent)this.components.get(i)).getID() == componentID) {
this.components.remove(i);
return;
}
}
}
public void updateComponent(ICustomOverlayComponent component) {
for(int i = 0; i < this.components.size(); ++i) {
ICustomOverlayComponent c = (ICustomOverlayComponent)this.components.get(i);
if (c.getID() == component.getID()) {
this.components.set(i, component);
return;
}
}
}
public void update(IPlayer player) {
CustomGuiController.updateOverlay((ScriptPlayer)player, this);
}
public ICustomOverlay fromNBT(NBTTagCompound tag) {
this.id = tag.getInteger("id");
List<ICustomOverlayComponent> components = new ArrayList();
NBTTagList list = tag.getTagList("components", 10);
for(int i = 0; i < list.tagCount(); i++){
NBTBase b = list.getCompoundTagAt(i);
ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound)b);
components.add(component);
}
this.components = components;
return this;
}
public NBTTagCompound toNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("id", this.id);
NBTTagList list = new NBTTagList();
Iterator var3 = this.components.iterator();
ICustomOverlayComponent c;
while(var3.hasNext()) {
c = (ICustomOverlayComponent)var3.next();
list.appendTag(((ScriptOverlayComponent)c).toNBT(new NBTTagCompound()));
}
tag.setTag("components", list);
return tag;
}
}
@@ -0,0 +1,123 @@
package noppes.npcs.scripted.overlay;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.scripted.gui.*;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
import noppes.npcs.scripted.interfaces.IOverlayTexturedRect;
public abstract class ScriptOverlayComponent implements ICustomOverlayComponent {
int id;
int posX;
int posY;
int alignment = 0;
int color = 0xFFFFFF;
float alpha = 1.0F;
float rotation = 0;
/* ========ALIGNMENTS========
0 1 2
3 4 5
6 7 8
*/
public ScriptOverlayComponent(){
}
public int getID() {
return this.id;
}
public ICustomOverlayComponent setID(int id) {
this.id = id;
return this;
}
public int getPosX() {
return this.posX;
}
public int getPosY() {
return this.posY;
}
public ICustomOverlayComponent setPos(int x, int y) {
this.posX = x;
this.posY = y;
return this;
}
public int getAlignment() {
return this.alignment;
}
public void setAlignment(int alignment) {
this.alignment = alignment;
}
public int getColor() {
return this.color;
}
public ICustomOverlayComponent setColor(int color) {
this.color = color;
return this;
}
public float getAlpha() {
return this.alpha;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
public float getRotation() {
return rotation;
}
public void setRotation(float rotation) {
this.rotation = rotation;
}
public abstract int getType();
public NBTTagCompound toNBT(NBTTagCompound nbt) {
nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
nbt.setInteger("alignment",this.alignment);
nbt.setInteger("color", this.color);
nbt.setFloat("alpha",this.alpha);
nbt.setFloat("rotation",this.rotation);
nbt.setInteger("type", this.getType());
return nbt;
}
public ScriptOverlayComponent fromNBT(NBTTagCompound nbt) {
this.setID(nbt.getInteger("id"));
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]);
this.setAlignment(nbt.getInteger("alignment"));
this.setColor(nbt.getInteger("color"));
this.setAlpha(nbt.getFloat("alpha"));
this.setRotation(nbt.getInteger("rotation"));
return this;
}
public static ScriptOverlayComponent createFromNBT(NBTTagCompound nbt) {
switch(nbt.getInteger("type")) {
case 0:
return (new ScriptOverlayTexturedRect()).fromNBT(nbt);
case 1:
return (new ScriptOverlayLabel()).fromNBT(nbt);
case 2:
return (new ScriptOverlayLine()).fromNBT(nbt);
default:
return null;
}
}
}
@@ -0,0 +1,97 @@
package noppes.npcs.scripted.overlay;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.gui.ScriptGuiComponent;
import noppes.npcs.scripted.interfaces.ILabel;
import noppes.npcs.scripted.interfaces.IOverlayLabel;
public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverlayLabel {
String label;
int width;
int height;
float scale;
boolean shadow;
public ScriptOverlayLabel() {
this.color = 16777215;
this.scale = 1.0F;
}
public ScriptOverlayLabel(int id, String label, int x, int y, int width, int height) {
this.color = 16777215;
this.scale = 1.0F;
this.setID(id);
this.setText(label);
this.setPos(x, y);
this.setSize(width, height);
this.setShadow(false);
}
public ScriptOverlayLabel(int id, String label, int x, int y, int width, int height, int color) {
this(id, label, x, y, width, height);
this.setColor(color);
}
public String getText() {
return this.label;
}
public IOverlayLabel setText(String label) {
this.label = label;
return this;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public IOverlayLabel setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public float getScale() {
return this.scale;
}
public IOverlayLabel setScale(float scale) {
this.scale = scale;
return this;
}
public boolean getShadow(){
return this.shadow;
}
public void setShadow(boolean shadow){
this.shadow = shadow;
}
@Override
public int getType() {
return 1;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setFloat("scale", this.scale);
nbt.setBoolean("shadow",this.shadow);
return nbt;
}
public ScriptOverlayLabel fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setText(nbt.getString("label"));
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setScale(nbt.getFloat("scale"));
this.setShadow(nbt.getBoolean("shadow"));
return this;
}
}
@@ -0,0 +1,97 @@
package noppes.npcs.scripted.overlay;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.gui.ScriptGuiComponent;
import noppes.npcs.scripted.interfaces.IOverlayLine;
public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverlayLine {
int x1;
int y1;
int x2;
int y2;
int thickness = 2;
public ScriptOverlayLine(){
}
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2){
this.setPos(x1, y1);
this.setID(id);
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
this.setPos(x1, y1);
this.setID(id);
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.thickness = thickness;
}
@Override
public int getType() {
return 2;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setInteger("X1",x1);
nbt.setInteger("Y1",y1);
nbt.setInteger("X2",x2);
nbt.setInteger("Y2",y2);
nbt.setInteger("Thickness",thickness);
return nbt;
}
public ScriptOverlayLine fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
x1 = nbt.getInteger("X1");
y1 = nbt.getInteger("Y1");
x2 = nbt.getInteger("X2");
y2 = nbt.getInteger("Y2");
thickness = nbt.getInteger("Thickness");
return this;
}
public int getX1(){
return this.x1;
}
public int getY1(){
return this.y1;
}
public int getX2(){
return this.x2;
}
public int getY2(){
return this.y2;
}
public int getThickness(){
return this.thickness;
}
public void setX1(int x1){
this.x1 = x1;
}
public void setY1(int y1){
this.y1 = y1;
}
public void setX2(int x2){
this.x2 = x2;
}
public void setY2(int y2){
this.y2 = y2;
}
public void setThickness(int thickness){
this.thickness = thickness;
}
}
@@ -0,0 +1,110 @@
package noppes.npcs.scripted.overlay;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.gui.ScriptGuiComponent;
import noppes.npcs.scripted.interfaces.IOverlayLabel;
import noppes.npcs.scripted.interfaces.IOverlayTexturedRect;
import noppes.npcs.scripted.interfaces.ITexturedRect;
public class ScriptOverlayTexturedRect extends ScriptOverlayComponent implements IOverlayTexturedRect {
int width;
int height;
int textureX;
int textureY;
float scale;
String texture;
public ScriptOverlayTexturedRect() {
this.textureY = -1;
this.scale = 1.0F;
}
public ScriptOverlayTexturedRect(int id, String texture, int x, int y, int width, int height) {
this.textureY = -1;
this.scale = 1.0F;
this.setID(id);
this.setTexture(texture);
this.setPos(x, y);
this.setSize(width, height);
}
public ScriptOverlayTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
this(id, texture, x, y, width, height);
this.setTextureOffset(textureX, textureY);
}
public String getTexture() {
return this.texture;
}
public IOverlayTexturedRect setTexture(String texture) {
this.texture = texture;
return this;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public IOverlayTexturedRect setSize(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public float getScale() {
return this.scale;
}
public IOverlayTexturedRect setScale(float scale) {
this.scale = scale;
return this;
}
public int getTextureX() {
return this.textureX;
}
public int getTextureY() {
return this.textureY;
}
public IOverlayTexturedRect setTextureOffset(int offsetX, int offsetY) {
this.textureX = offsetX;
this.textureY = offsetY;
return this;
}
@Override
public int getType() {
return 0;
}
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setFloat("scale", this.scale);
nbt.setString("texture", this.texture);
if (this.textureX >= 0 && this.textureY >= 0) {
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
}
return nbt;
}
public ScriptOverlayComponent fromNBT(NBTTagCompound nbt) {
super.fromNBT(nbt);
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setScale(nbt.getFloat("scale"));
this.setTexture(nbt.getString("texture"));
if (nbt.hasKey("texPos")) {
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
}
return this;
}
}
@@ -41,6 +41,7 @@ import noppes.npcs.scripted.entity.*;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.*;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.util.JsonException;
import noppes.npcs.util.LRUHashMap;
import noppes.npcs.util.NBTJsonUtil;
@@ -233,7 +234,10 @@ public class WrapperNpcAPI extends NpcAPI {
}
public IDamageSource getIDamageSource(IEntity entity) {
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity()));
if(entity.getType() == 1)//if player
return new ScriptDamageSource(new EntityDamageSource("player",entity.getMCEntity()));
else
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity()));
}
public void executeCommand(IWorld world, String command) {
@@ -272,4 +276,8 @@ public class WrapperNpcAPI extends NpcAPI {
public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) {
return new ScriptGui(id, width, height, pauseGame);
}
public ICustomOverlay createCustomOverlay(int id) {
return new ScriptOverlay(id);
}
}