Compare commits

..
50 Commits
Author SHA1 Message Date
KAMKEEL 6d6daeb345 Update build.gradle 2022-02-02 19:26:24 -05:00
KAMKEEL 3844a26e8b Merge branch 'dev' 2022-02-02 19:25:29 -05:00
KAMKEEL 2a4ace286e Quick Patch 2022-02-02 19:25:17 -05:00
Kamron Vaswani 79ef0e07a1 Merge pull request #33 from c0508383/master
Removed println statement please forgive me oh god
2022-02-02 19:22:35 -05:00
luisc 7e0ff3c836 Removed println statement please forgive me oh god 2022-02-02 18:21:08 -06:00
KAMKEEL e3e55e4256 Merge branch 'dev' 2022-02-02 17:44:46 -05:00
KAMKEEL 0c4ead5752 Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2022-02-02 16:20:17 -05:00
KAMKEEL 5d39c5b356 Fixed Disable Block Error 2022-02-02 16:20:11 -05:00
Kamron Vaswani 19ccdd60d2 Merge pull request #32 from c0508383/master
Bug fixes & GUI rotations
2022-02-02 15:43:23 -05:00
luisc d3145f4868 Added config for how often a player's quests are checked for completion. 2022-02-02 07:53:42 -06:00
luisc 70536de655 Removed checkQuestCompleted from ScriptPlayer, now redundant with new quest checks that happen periodically. 2022-02-02 07:21:45 -06:00
luisc 1ebf747302 Optimized NBT access of player data when checking quest completion, player data variable is passed down to lower functions.
Player's quests are checked for completion every couple seconds now.
2022-02-02 07:18:33 -06:00
luisc 632e92f82e Added set/getPitch to ScriptEntity 2022-02-01 05:10:38 -06:00
luisc 90ca1a0200 Added isAirborne() function to ScriptEntity 2022-02-01 02:30:50 -06:00
luisc 9109c134c1 Added more general setMotion function with x y and z parameters. 2022-01-31 23:59:15 -06:00
luisc 1af875aea9 Fixed concurrent modification bug with NPC tasks. 2022-01-31 23:01:52 -06:00
luisc 7de585843d Added get/setHunger, and get/setSaturation functions for ScriptPlayer.
The player KeyPressed event now sends a list of keys that are currently pressed by the player.
2022-01-31 20:16:00 -06:00
luisc 67c83b1ce9 Added rotation for custom GUI lines, labels, and textured rectangles 2022-01-31 15:39:21 -06:00
Kamron Vaswani bc54e8cd7b Merge pull request #31 from c0508383/master
Increased NPC Inventory & Other Additions.
2022-01-31 16:27:15 -05:00
Kamron Vaswani 8675d22ebb Merge pull request #30 from PewDizinho/patch-1
Update README.md
2022-01-31 16:27:01 -05:00
luisc 83e13285f9 Added rotation to overlay components, and color codes to overlay labels 2022-01-31 14:51:06 -06:00
luisc 3be088c4cc Moved OpenGL lines to within the loop that renders each component, fixing some weird alpha errors. 2022-01-30 22:58:12 -06:00
luisc 54fadbe63f Implemented label, alpha, and formatting for Custom GUI labels. 2022-01-30 22:49:03 -06:00
luisc da3b04e78e Implemented MC chat formatting for color codes: &l, &m, &r, &o, and &k all affect overlay labels. 2022-01-30 22:41:55 -06:00
luisc e7a19264b2 Added alpha and style options for overlay labels. 2022-01-30 14:22:29 -06:00
luisc 966ab4bf72 Custom Overlays and GUIs now properly set alpha values for some components. 2022-01-30 13:29:00 -06:00
luisc e5e1aa1972 Made color and alpha components global among ScriptGui classes. 2022-01-30 05:20:45 -06:00
luisc be61bd4e17 Made color and alpha components global among ScriptOverlay classes. 2022-01-30 04:33:00 -06:00
luisc 534f716991 Implemented Scripted Overlays which stay on the player's screen. Overlays persist in the client, and can be removed from the screen as well. 2022-01-30 04:05:01 -06:00
luisc 8b24dad211 Added Custom GUI Lines, with configurable thickness & color. Draws a line between one point defined by (x1,y1), and another defined by (x2,y2) 2022-01-28 03:21:00 -06:00
PewDizinho 6974476d92 Update README.md 2022-01-27 14:36:20 -03:00
luisc fcaafe4b26 Fixed NBT issue with the new quest kill amounts. 2022-01-27 06:14:03 -06:00
luisc f876f13d77 Added 9 more slots for quest kill objectives, and an option for kill quests to progress only if a player kills an NPC with that name.
Added quest interface support to get and modify data from specific quest types.
2022-01-27 05:40:51 -06:00
luisc 989effb5c5 Added more a full inventory to NPCs, selectable on two tabs and double-point values for NPC droprates. 2022-01-27 03:50:36 -06:00
luisc f14337f1bb Added config for NPC sizes, default 100. 2022-01-25 14:54:15 -06:00
luisc eb45a6a959 Added several more dialog functions for the rest of the dialog options. 2022-01-25 14:44:24 -06:00
Kamron Vaswani a04f023d53 Merge pull request #28 from c0508383/master
Custom GUI fixes
2022-01-24 01:06:56 -05:00
luisc 092b3ce0c1 Fixed overloaded hurt(damage,entity) function not working when an entity is to be hurt by a player 2022-01-22 22:50:01 -06:00
KAMKEEL 971010bda8 Darken Screen Dialog Fix 2022-01-21 18:31:32 -05:00
luisc 06c730b166 Fixed scale & color issues for custom GUI textured rectangles. 2022-01-21 01:15:21 -06:00
luisc b9bc1e5ed7 Merge remote-tracking branch 'origin/master' 2022-01-20 20:27:39 -06:00
luisc 83756381e4 Added toggleable shadows and scaling to custom GUI labels. 2022-01-20 20:27:26 -06:00
Luis C.M 52f342302c Merge branch 'KAMKEEL:master' into master 2022-01-20 16:32:16 -06:00
luisc 0788b2750f Quick fix for custom GUI textured rectangles, now with working x and y offsets. 2022-01-20 00:15:21 -06:00
KAMKEEL 8a9defd3a1 Part Data Texture Fix for Upgrading from CNPC
Issue where already saved NPCs cannot locate texture if upgrading from CNPC to CNPC+
2022-01-19 18:21:12 -05:00
KAMKEEL dff71c5a98 Update 1.5-beta
💯
Starting new version
2022-01-18 00:20:50 -05:00
Kamron Vaswani cb72f6c50e Merge pull request #26 from c0508383/master
Compatibility fix pt.2
2022-01-15 23:54:55 -05:00
luisc dd22f604cc Compatibility fix for mods that initialize player or worldobj fields as null. 2022-01-15 22:52:27 -06:00
Kamron Vaswani 05e6a97721 Merge pull request #25 from c0508383/master
Compatibility fix for mods that initialize player or worldobj fields as null.
2022-01-15 23:50:33 -05:00
luisc f8a6fe3d75 Compatibility fix for mods that initialize player or worldobj fields as null. 2022-01-15 22:49:07 -06:00
83 changed files with 3272 additions and 349 deletions

No files matched your search

+37 -30
View File
@@ -1,44 +1,46 @@
## 👋 Welcome to the CustomNPC+ Repository.
![](images/logo.png) ![](images/logo.png)
Welcome to the CustomNPC+ Repository. > CustomNPC+ is a [Minecraft](https://minecraft.net/) mod that allows you to add custom NPCs to your world. It is developed for creative and storytelling players who want to make their Minecraft worlds more in-depth and unique. CustomNPC+ is only a branch version of the **1.7.10** Forge version of the original (down below) and has no plans to add or update any other version. This is not an official version of CustomNPC.
CustomNPC+ is a [Minecraft](https://minecraft.net/) mod that allows you to add custom NPCs to your world. It is developed for creative and storytelling players who want to make their Minecraft worlds more in-depth and unique. CustomNPC+ is only a branch version of the **1.7.10** Forge version of the original (down below) and has no plans to add or update any other version. This is not an official version of CustomNPC.
Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus) Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
#### Notice ### ❗ Notice
I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs) I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs)
#### First Release! V1.0 (Installation) ### 🔹 First Release! V1.0 (Installation)
This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy. This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy.
### Features: ### ❓ Features:
- [x] More Wing Types - More Wing Types
- [x] More Fin Types - More Fin Types
- [x] More Capes* - More Capes*
- [x] More Overlays - More Overlays
- [x] Added Horns - Added Horns
- [x] Added Dolphin Tail - Added Dolphin Tail
- [x] Larger Clone GUI - Larger Clone GUI
- [x] More Clone Tabs - More Clone Tabs
- [x] Increased Resolution to Additional Body Parts - Increased Resolution to Additional Body Parts
- [x] ~~Update Local Skin Textures (64x64) [WIP]~~ - ~~Update Local Skin Textures (64x64) [WIP]~~
- [x] Added (New) Local 64x64 Skin Textures - Added (New) Local 64x64 Skin Textures
- [x] 1.8 Skins (64x64) - 1.8 Skins (64x64)
- [x] Alex Model (64x64) - Alex Model (64x64)
- [x] Fix Part Rendering - Fix Part Rendering
- [x] Backported GUI Features - Backported GUI Features
- [x] Backported New Part Models - Backported New Part Models
- [X] Custom Part Disabling - Custom Part Disabling
- [X] Markov Name Generator - Markov Name Generator
- [X] Flying NPCS - Flying NPCS
- [X] Better Script Speeds - Better Script Speeds
- Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation)
--- Please Suggest New Features! --- Please Suggest New Features!
###### **Majority of these cape designs are taken from the internet with fair-usage.*
#### Skin Model Feature: ## 🔰 Skin Model Feature:
##### Please note all *local* skins in this version of CustomNPC, must match the model selected. ###### **Majority of these cape designs are taken from the internet with fair-usage.*
##### ❔ Please note all *local* skins in this version of CustomNPC, must match the model selected.
<img src="images/skinAnimation.gif" width="474" height="260"/> <img src="images/skinAnimation.gif" width="474" height="260"/>
#### Scale/Puppet Reset: #### Scale/Puppet Reset:
@@ -48,6 +50,11 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
<img src="images/Url64Example.gif" width="474" height="260"/> <img src="images/Url64Example.gif" width="474" height="260"/>
#### Want to check out my other mods? ## 🔗 Want to check out my other mods?
[Plugin Mod](https://github.com/KAMKEEL/Plugin-Mod) is a mod designed to add more aesthetic items for RPG and storytelling. It is compatible with CustomNPC+ and has many items intended to be used and wielded by created NPCs. [Plugin Mod](https://github.com/KAMKEEL/Plugin-Mod) is a mod designed to add more aesthetic items for RPG and storytelling. It is compatible with CustomNPC+ and has many items intended to be used and wielded by created NPCs.
[![Discord Badge](https://img.shields.io/badge/CustomNPC-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/rgeWsmQaKa)
[![Discord Badge](https://img.shields.io/badge/CustomNPC+-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/pQqRTvFeJ5)
[![Download CustomNPC+](https://img.shields.io/badge/Download⠀CustomNPC⠀Plus!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
[![Download CustomNPC+](https://img.shields.io/badge/Download⠀Plugin⠀Mod!-0081CB?style=for-the-badge&logo=material-ui&logoColor=white)](https://github.com/KAMKEEL/Plugin-Mod)
+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.4.2" version = "1.5.1-beta"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus" archivesBaseName = "CustomNPC-Plus"
+3 -2
View File
@@ -445,6 +445,9 @@ public class CustomItems {
Item.getItemFromBlock(sign).setHasSubtypes(true); Item.getItemFromBlock(sign).setHasSubtypes(true);
Item.getItemFromBlock(beam).setHasSubtypes(true); Item.getItemFromBlock(beam).setHasSubtypes(true);
Item.getItemFromBlock(pedestal).setHasSubtypes(true); Item.getItemFromBlock(pedestal).setHasSubtypes(true);
tabBlocks.item = Item.getItemFromBlock(couchWool);
tabBlocks.meta = 1;
} }
banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo"); banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo");
@@ -887,8 +890,6 @@ public class CustomItems {
tabArmor.item = cowarmor; tabArmor.item = cowarmor;
tabWeapon.item = CustomItems.shuriken; tabWeapon.item = CustomItems.shuriken;
tabMisc.item = CustomItems.coinGold; tabMisc.item = CustomItems.coinGold;
tabBlocks.item = Item.getItemFromBlock(couchWool);
tabBlocks.meta = 1;
} }
tab.item = wand; tab.item = wand;
+13 -1
View File
@@ -61,7 +61,7 @@ import noppes.npcs.entity.old.EntityNpcNagaMale;
import noppes.npcs.entity.old.EntityNpcSkeleton; import noppes.npcs.entity.old.EntityNpcSkeleton;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.4.2") @Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.1-beta")
public class CustomNpcs { public class CustomNpcs {
@ConfigProp(info = "Disable Chat Bubbles") @ConfigProp(info = "Disable Chat Bubbles")
@@ -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.") @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; 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") @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; 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 @ConfigProp
public static boolean InventoryGuiEnabled = true; public static boolean InventoryGuiEnabled = true;
@@ -171,6 +177,12 @@ public class CustomNpcs {
NpcNavRange = 96; NpcNavRange = 96;
} }
if(NpcSizeLimit < 1)
NpcSizeLimit = 1;
if(PlayerQuestCheck < 1)
PlayerQuestCheck = 1;
EnchantInterface.load(); EnchantInterface.load();
CustomItems.load(); CustomItems.load();
@@ -133,6 +133,9 @@ public class DataDisplay {
glowTexture = nbttagcompound.getString("GlowTexture"); glowTexture = nbttagcompound.getString("GlowTexture");
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > CustomNpcs.NpcSizeLimit)
modelSize = CustomNpcs.NpcSizeLimit;
modelType = nbttagcompound.getInteger("modelType"); modelType = nbttagcompound.getInteger("modelType");
showName = nbttagcompound.getInteger("ShowName"); showName = nbttagcompound.getInteger("ShowName");
+15 -5
View File
@@ -18,7 +18,7 @@ import noppes.npcs.entity.EntityNPCInterface;
public class DataInventory implements IInventory{ public class DataInventory implements IInventory{
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>(); 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> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer, ItemStack> armor = 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("NpcInv", NBTTags.nbtItemStackList(items));
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor())); nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons())); nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
nbttagcompound.setTag("DropChance", NBTTags.nbtIntegerIntegerMap(dropchance)); nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
nbttagcompound.setInteger("LootMode", lootMode); nbttagcompound.setInteger("LootMode", lootMode);
return nbttagcompound; return nbttagcompound;
@@ -49,7 +49,17 @@ public class DataInventory implements IInventory{
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10)); items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10))); setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 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"); lootMode = nbttagcompound.getInteger("LootMode");
} }
public HashMap<Integer, ItemStack> getWeapons() { public HashMap<Integer, ItemStack> getWeapons() {
@@ -89,10 +99,10 @@ public class DataInventory implements IInventory{
ItemStack item = items.get(i); ItemStack item = items.get(i);
if(item == null) if(item == null)
continue; continue;
int dchance = 100; double dchance = 100;
if(dropchance.containsKey(i)) if(dropchance.containsKey(i))
dchance = dropchance.get(i); dchance = dropchance.get(i);
int chance = npc.worldObj.rand.nextInt(100) + dchance; double chance = Math.random()*100 + dchance;
if(chance >= 100){ if(chance >= 100){
EntityItem e = getEntityItem(item.copy()); EntityItem e = getEntityItem(item.copy());
if(e != null) if(e != null)
+2 -2
View File
@@ -262,9 +262,9 @@ public class EventHooks {
WrapperNpcAPI.EVENT_BUS.post(event); 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; 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); handler.callScript(EnumScriptType.KEY_PRESSED, event);
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
+5 -1
View File
@@ -24,8 +24,9 @@ public class ModelPartData {
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type); compound.setByte("Type", type);
compound.setInteger("Color", color); compound.setInteger("Color", color);
if(texture != null && !texture.isEmpty()) if(texture != null && !texture.isEmpty()) {
compound.setString("Texture", texture); compound.setString("Texture", texture);
}
compound.setBoolean("PlayerTexture", playerTexture); compound.setBoolean("PlayerTexture", playerTexture);
return compound; return compound;
} }
@@ -34,6 +35,9 @@ public class ModelPartData {
type = compound.getByte("Type"); type = compound.getByte("Type");
color = compound.getInteger("Color"); color = compound.getInteger("Color");
texture = compound.getString("Texture"); texture = compound.getString("Texture");
if(texture.contains("moreplayermodels:textures")){
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
}
playerTexture = compound.getBoolean("PlayerTexture"); playerTexture = compound.getBoolean("PlayerTexture");
location = null; location = null;
} }
+24
View File
@@ -69,6 +69,17 @@ public class NBTTags {
} }
return list; 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( public static HashMap<Integer, Long> getIntegerLongMap(
NBTTagList tagList) { NBTTagList tagList) {
@@ -239,6 +250,19 @@ public class NBTTags {
return nbttaglist; 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) { public static NBTTagList nbtIntegerLongMap(HashMap<Integer, Long> lines) {
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
if(lines == null) if(lines == null)
@@ -26,21 +26,7 @@ import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.containers.ContainerNPCBankInterface; import noppes.npcs.containers.ContainerNPCBankInterface;
import noppes.npcs.containers.ContainerNPCFollower; import noppes.npcs.containers.ContainerNPCFollower;
import noppes.npcs.containers.ContainerNPCFollowerHire; import noppes.npcs.containers.ContainerNPCFollowerHire;
import noppes.npcs.controllers.Bank; import noppes.npcs.controllers.*;
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.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleFollower;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.common.network.internal.FMLProxyPacket;
@@ -303,13 +289,14 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT()); Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
} }
public static void questCompletion(EntityPlayerMP player, int questId) { public static void questCompletion(EntityPlayerMP player, int questId) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
QuestData data = playerdata.activeQuests.get(questId); PlayerQuestData questData = playerData.questData;
QuestData data = questData.activeQuests.get(questId);
if(data == null) if(data == null)
return; return;
if(!data.quest.questInterface.isCompleted(player)) if(!data.quest.questInterface.isCompleted(playerData))
return; return;
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest); QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest);
@@ -3,6 +3,8 @@ package noppes.npcs;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
@@ -16,11 +18,7 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileBook; import noppes.npcs.blocks.tiles.TileBook;
import noppes.npcs.constants.EnumCompanionTalent; import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.containers.ContainerMail; import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.*; import noppes.npcs.controllers.*;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -66,7 +64,31 @@ public class PacketHandlerPlayer{
return; 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) { else if(type == EnumPlayerPacket.MouseClicked) {
if(ScriptController.Instance.languages.isEmpty()) { if(ScriptController.Instance.languages.isEmpty()) {
@@ -135,8 +157,9 @@ public class PacketHandlerPlayer{
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc); NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
} }
else if(type == EnumPlayerPacket.CheckQuestCompletion){ else if(type == EnumPlayerPacket.CheckQuestCompletion){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
playerdata.checkQuestCompletion(player, null); PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
questData.checkQuestCompletion(playerData, null);
} }
else if(type == EnumPlayerPacket.QuestLog){ else if(type == EnumPlayerPacket.QuestLog){
NoppesUtilPlayer.sendQuestLogData(player); NoppesUtilPlayer.sendQuestLogData(player);
+4 -2
View File
@@ -6,6 +6,8 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.PlayerQuestController;
import noppes.npcs.controllers.Quest; import noppes.npcs.controllers.Quest;
@@ -34,7 +36,7 @@ public class QuestLogData {
} }
public void setData(EntityPlayer player){ public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(Quest quest : PlayerQuestController.getActiveQuests(player)) for(Quest quest : PlayerQuestController.getActiveQuests(player))
{ {
String category = quest.category.title; String category = quest.category.title;
@@ -46,7 +48,7 @@ public class QuestLogData {
questText.put(category + ":" + quest.title, quest.logText); questText.put(category + ":" + quest.title, quest.logText);
questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player)); 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); finish.put(category + ":" + quest.title, quest.completerNpc);
} }
} }
@@ -53,7 +53,7 @@ public class ScriptForgeEventHandler {
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) { } else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
if (event instanceof PlayerEvent) { if (event instanceof PlayerEvent) {
PlayerEvent ev = (PlayerEvent) event; PlayerEvent ev = (PlayerEvent) event;
if (!(ev.player.worldObj instanceof WorldServer)) { if (ev.player == null || !(ev.player.worldObj instanceof WorldServer)) {
return; return;
} }
} }
@@ -46,15 +46,13 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.*; import net.minecraftforge.event.world.*;
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns; import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
import noppes.npcs.controllers.PlayerData; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ForgeEvent; import noppes.npcs.scripted.event.ForgeEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
public class ScriptPlayerEventHandler { public class ScriptPlayerEventHandler {
@@ -62,6 +60,9 @@ public class ScriptPlayerEventHandler {
} }
@SubscribeEvent @SubscribeEvent
public void onServerTick(TickEvent.PlayerTickEvent event) { public void onServerTick(TickEvent.PlayerTickEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) { if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EntityPlayer player = event.player; EntityPlayer player = event.player;
@@ -71,15 +72,25 @@ public class ScriptPlayerEventHandler {
EventHooks.onPlayerTick(handler, scriptPlayer); EventHooks.onPlayerTick(handler, scriptPlayer);
} }
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
if(PlayerDataController.instance != null) { if(PlayerDataController.instance != null) {
if(PlayerDataController.instance.getPlayerData(player).timers.size() > 0) if(playerData.timers.size() > 0)
PlayerDataController.instance.getPlayerData(player).timers.update(); playerData.timers.update();
}
if(player.ticksExisted%(20*CustomNpcs.PlayerQuestCheck) == 0){
PlayerQuestData questData = playerData.questData;
for(EnumQuestType e : EnumQuestType.values())
questData.checkQuestCompletion(playerData, e);
} }
} }
} }
@SubscribeEvent @SubscribeEvent
public void invoke(EntityInteractEvent event) { public void invoke(EntityInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -90,6 +101,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(ArrowNockEvent event) { public void invoke(ArrowNockEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -100,6 +114,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(ArrowLooseEvent event) { public void invoke(ArrowLooseEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -110,6 +127,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(BlockEvent.BreakEvent event) { public void invoke(BlockEvent.BreakEvent event) {
if(event.getPlayer() == null || event.getPlayer().worldObj == null)
return;
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) { if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer()); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
@@ -121,6 +141,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) { public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -129,6 +152,9 @@ public class ScriptPlayerEventHandler {
} }
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) { public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -137,6 +163,9 @@ public class ScriptPlayerEventHandler {
} }
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) { public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -145,6 +174,9 @@ public class ScriptPlayerEventHandler {
} }
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) { public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -154,6 +186,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerDropsEvent event) { public void invoke(PlayerDropsEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -163,6 +198,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerPickupXpEvent event) { public void invoke(PlayerPickupXpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -172,6 +210,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) { public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -181,6 +222,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) { public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -190,6 +234,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerOpenContainerEvent event) { public void invoke(PlayerOpenContainerEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) { if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -199,6 +246,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(UseHoeEvent event) { public void invoke(UseHoeEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -208,6 +258,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerSleepInBedEvent event) { public void invoke(PlayerSleepInBedEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -217,6 +270,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerWakeUpEvent event) { public void invoke(PlayerWakeUpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -226,6 +282,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(FillBucketEvent event) { public void invoke(FillBucketEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -235,6 +294,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(BonemealEvent event) { public void invoke(BonemealEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -244,6 +306,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(AchievementEvent event) { public void invoke(AchievementEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) { if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
@@ -253,6 +318,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(ItemTossEvent event) { public void invoke(ItemTossEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -262,6 +330,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(LivingFallEvent event) { public void invoke(LivingFallEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) { if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) { if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -273,6 +344,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(LivingEvent.LivingJumpEvent event) { public void invoke(LivingEvent.LivingJumpEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) { if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) { if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -284,6 +358,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(EntityStruckByLightningEvent event) { public void invoke(EntityStruckByLightningEvent event) {
if(event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) { if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) { if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -295,6 +372,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlaySoundAtEntityEvent event) { public void invoke(PlaySoundAtEntityEvent event) {
if(event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) { if(event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) { if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -306,6 +386,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(LivingDeathEvent event) { public void invoke(LivingDeathEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) { if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source); Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -324,6 +407,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(LivingHurtEvent event) { public void invoke(LivingHurtEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) { if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source); Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
@@ -344,6 +430,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerEvent.PlayerRespawnEvent event) { public void invoke(PlayerEvent.PlayerRespawnEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -353,6 +442,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedInEvent event) { public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -362,6 +454,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent @SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) { public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) { if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -373,6 +468,9 @@ public class ScriptPlayerEventHandler {
priority = EventPriority.HIGHEST priority = EventPriority.HIGHEST
) )
public void invoke(net.minecraftforge.event.ServerChatEvent event) { public void invoke(net.minecraftforge.event.ServerChatEvent event) {
if(event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) { if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
@@ -21,7 +21,6 @@ import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent;
@@ -43,7 +42,6 @@ import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSoulstoneEmpty; import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.quests.QuestKill; import noppes.npcs.quests.QuestKill;
import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleFollower;
import noppes.npcs.scripted.event.ForgeEvent;
public class ServerEventsHandler { public class ServerEventsHandler {
@@ -293,11 +291,12 @@ public class ServerEventsHandler {
} }
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) { 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; boolean change = false;
String entityName = EntityList.getEntityString(entity); 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) if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue; continue;
if(data.quest.type == EnumQuestType.AreaKill && all){ if(data.quest.type == EnumQuestType.AreaKill && all){
@@ -309,6 +308,8 @@ public class ServerEventsHandler {
} }
String name = entityName; String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface; QuestKill quest = (QuestKill) data.quest.questInterface;
if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface))
continue;
if(quest.targets.containsKey(entity.getCommandSenderName())) if(quest.targets.containsKey(entity.getCommandSenderName()))
name = entity.getCommandSenderName(); name = entity.getCommandSenderName();
else if(!quest.targets.containsKey(name)) else if(!quest.targets.containsKey(name))
@@ -326,15 +327,16 @@ public class ServerEventsHandler {
if(!change) if(!change)
return; return;
playerdata.checkQuestCompletion(player,EnumQuestType.Kill); questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
} }
@SubscribeEvent @SubscribeEvent
public void pickUp(EntityItemPickupEvent event){ public void pickUp(EntityItemPickupEvent event){
if(event.entityPlayer.worldObj.isRemote) if(event.entityPlayer.worldObj.isRemote)
return; return;
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(event.entityPlayer).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(event.entityPlayer);
playerdata.checkQuestCompletion(event.entityPlayer, EnumQuestType.Item); PlayerQuestData questData = playerData.questData;
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
} }
@SubscribeEvent @SubscribeEvent
@@ -10,6 +10,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData; import noppes.npcs.controllers.QuestData;
@@ -43,15 +44,16 @@ public class TileWaypoint extends TileEntity {
if(toCheck.isEmpty()) if(toCheck.isEmpty())
return; return;
for(EntityPlayer player : toCheck){ for(EntityPlayer player : toCheck){
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(QuestData data : playerdata.activeQuests.values()){ PlayerQuestData questData = playerData.questData;
for(QuestData data : questData.activeQuests.values()){
if(data.quest.type != EnumQuestType.Location) if(data.quest.type != EnumQuestType.Location)
continue; continue;
QuestLocation quest = (QuestLocation) data.quest.questInterface; QuestLocation quest = (QuestLocation) data.quest.questInterface;
if(quest.setFound(data, name)){ if(quest.setFound(data, name)){
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found"))); 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 io.netty.buffer.Unpooled;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server; import noppes.npcs.Server;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.common.network.internal.FMLProxyPacket;
public class Client { public class Client {
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static void sendData(EnumPacketServer enu, Object... obs) { public static void sendData(EnumPacketServer enu, Object... obs) {
ByteBuf buffer = Unpooled.buffer(); ByteBuf buffer = Unpooled.buffer();
@@ -1,5 +1,18 @@
package noppes.npcs.client; 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 isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
boolean keyDown = Keyboard.isKeyDown(key); 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.ClientProxy.FontContainer;
import noppes.npcs.client.controllers.MusicController; import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd; 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.player.GuiBook;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface; import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface;
@@ -259,5 +260,15 @@ public class PacketHandlerClient extends PacketHandlerServer{
NoppesUtil.isGUIOpen(isGUIOpen); 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); location = new ResourceLocation(directory);
} }
/*
par2 = partial tick time
par3 = ActiveRenderInfo.rotationX;
par4 = ActiveRenderInfo.rotationZ;
par5 = ActiveRenderInfo.rotationYZ;
par6 = ActiveRenderInfo.rotationXY;
par7 = ActiveRenderInfo.rotationXZ;
*/
@Override @Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) 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(); Minecraft minecraft = Minecraft.getMinecraft();
EntityPlayer player = minecraft.thePlayer; 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 angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
double angleRad = (angle/180)*Math.PI; 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); double angleX = Math.sin(yaw)*Math.cos(pitch);
if(Math.abs(angleX) < 0.0001){ if(Math.abs(angleX) < 0.0001){
angleX = 0.0D; angleX = 0.0D;
@@ -140,13 +153,62 @@ public class EntityCustomFX extends EntityFX {
angleZ = 0.0D; 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 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.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1.0F); GL11.glColor4f(1, 1, 1, 1.0F);
//GL11.glTranslated(translateX,translateY,translateZ); //GL11.glTranslated(translateX,translateY,translateZ);
//GL11.glRotated(angle, angleX, angleY, angleZ); //GL11.glRotated(angle, angleX, angleY, angleZ);
@@ -12,11 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.controllers.ClientCloneController; import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
@@ -44,7 +40,8 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50)); addLabel(new GuiNpcLabel(1, "Tab", guiLeft + 10, guiTop + 50));
addButton(new GuiNpcButton(2, guiLeft + 40, guiTop + 45, 20, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1)); // addButton(new GuiNpcButton(2, guiLeft + 40, guiTop + 45, 20, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1));
addButton(new GuiButtonBiDirectional(2, guiLeft + 40, guiTop + 45, 60, 20, new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"}, tab - 1));
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide?1:0)); addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 95, new String[]{"Client side", "Server side"}, serverSide?1:0));
@@ -130,8 +130,16 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
Iterator var4 = this.components.values().iterator(); Iterator var4 = this.components.values().iterator();
while(var4.hasNext()) { 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(); IGuiComponent component = (IGuiComponent)var4.next();
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks); 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) { if (this.hoverText != null) {
@@ -429,6 +437,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
this.components.put(scroll.getID(), scroll); this.components.put(scroll.getID(), scroll);
this.addDataHolder(scroll); this.addDataHolder(scroll);
this.addClickListener(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; package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton; 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 net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IClickListener; import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiButton; import noppes.npcs.scripted.gui.ScriptGuiButton;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -23,17 +27,17 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
public int textureY; public int textureY;
boolean field_146123_n; boolean field_146123_n;
String label; String label;
int colour;
String[] hoverText; String[] hoverText;
int color;
float alpha;
public CustomGuiButton(int id, String buttonText, int x, int y) { public CustomGuiButton(int id, String buttonText, int x, int y) {
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText); 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) { 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); 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) { 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.textureY = textureY;
this.label = buttonText; this.label = buttonText;
this.texture = new ResourceLocation(texture); 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) { 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 = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY());
} }
btn.color = component.getColor();
btn.alpha = component.getAlpha();
if (component.hasHoverText()) { if (component.hasHoverText()) {
btn.hoverText = component.getHoverText(); btn.hoverText = component.getHoverText();
} }
@@ -81,59 +94,59 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
//GL11.func_179094_E(); //GL11.func_179094_E();
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id); //GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id); float red = (color >> 16 & 255) / 255f;
FontRenderer fontRenderer = mc.fontRenderer; float green = (color >> 8 & 255) / 255f;
int i; float blue = (color & 255) / 255f;
if (this.texture == null) { GL11.glColor4f(red,green,blue,this.alpha);
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (this.packedFGColour != 0) {
j = this.packedFGColour;
} else if (!this.enabled) {
j = 10526880;
} else if (this.field_146123_n) {
j = 16777120;
}
GL11.glTranslated(0.0D, 0.0D, 0.1D); GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); FontRenderer fontRenderer = mc.fontRenderer;
} else { int i;
mc.getTextureManager().bindTexture(this.texture); if (this.texture == null) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(buttonTextures);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; 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); i = this.getHoverState(this.field_146123_n);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 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_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); //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.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.colour); this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) { this.mouseDragged(mc, mouseX, mouseY);
this.parent.hoverText = this.hoverText; 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(); GL11.glPopMatrix();
} }
public ICustomGuiComponent toComponent() { 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); 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.setHoverText(this.hoverText);
component.setColor(this.color);
component.setAlpha(this.alpha);
return component; return component;
} }
public void setColour(int colour) {
this.colour = colour;
}
protected int hoverState(boolean mouseOver) { protected int hoverState(boolean mouseOver) {
int i = 0; int i = 0;
if (mouseOver) { if (mouseOver) {
@@ -5,53 +5,113 @@
package noppes.npcs.client.gui.custom.components; 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.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiLabel; import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.renderer.OpenGlHelper; 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.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.scripted.gui.ScriptGuiLabel; import noppes.npcs.scripted.gui.ScriptGuiLabel;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11; 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; import java.util.ArrayList;
public class CustomGuiLabel extends Gui implements IGuiComponent { public class CustomGuiLabel extends Gui implements IGuiComponent {
int x, y, width, height; int x, y, width, height;
GuiCustom parent; GuiCustom parent;
String fullLabel; String fullLabel;
int color;
String[] hoverText; String[] hoverText;
float scale; float scale;
int id; int id;
int border = 2; int border = 2;
boolean labelBgEnabled = true; boolean labelBgEnabled = true;
boolean labelShadowEnabled = false;
int color;
float alpha;
float rotation;
protected int field_146167_a; protected int field_146167_a;
protected int field_146161_f; protected int field_146161_f;
public int field_146162_g; public int field_146162_g;
public int field_146174_h; 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.id = id;
this.fullLabel = fullLabel; this.fullLabel = fullLabel;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.width = width; this.width = width;
this.height = height; 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) { public void setParent(GuiCustom parent) {
@@ -75,14 +135,17 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
} }
public static CustomGuiLabel fromComponent(ScriptGuiLabel component) { 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.scale = 1.0F;
lbl.color = component.getColor(); lbl.color = component.getColor();
lbl.field_146172_j = true;
lbl.setScale(component.getScale()); lbl.setScale(component.getScale());
if (component.hasHoverText()) { if (component.hasHoverText()) {
lbl.hoverText = component.getHoverText(); lbl.hoverText = component.getHoverText();
} }
lbl.labelShadowEnabled = component.hasShadow();
lbl.color = component.getColor();
lbl.alpha = component.getAlpha();
lbl.rotation = component.getRotation();
return lbl; return lbl;
} }
@@ -90,34 +153,416 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
public ICustomGuiComponent toComponent() { 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); 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.setHoverText(this.hoverText);
component.enableShadow(this.labelShadowEnabled);
component.setColor(this.color);
component.setAlpha(this.alpha);
component.setRotation(this.rotation);
return component; return component;
} }
public void drawLabel() 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); l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true);
OpenGlHelper.glBlendFunc(770, 771, 1, 0); l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false));
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); }
this.drawLabelBackground(); else
this.drawString(Minecraft.getMinecraft().fontRenderer, fullLabel, this.x, this.y, this.color); {
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; char c0 = p_78255_1_.charAt(i);
int l = this.height + this.border * 2; int j;
int i1 = this.x - this.border; int k;
int j1 = this.y - this.border;
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor if (c0 == 38 && i + 1 < p_78255_1_.length())
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor {
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1));
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor 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; String[] hoverText;
public boolean multiSelect = false; public boolean multiSelect = false;
int color;
float alpha;
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) { public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
super(parent, id); super(parent, id);
this.mc = mc; 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) { public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, (float)this.id); float red = (color >> 16 & 255) / 255f;
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize; float green = (color >> 8 & 255) / 255f;
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel); float blue = (color & 255) / 255f;
if (hovered && this.hoverText != null && this.hoverText.length > 0) { GL11.glColor4f(red,green,blue,this.alpha);
this.parent.hoverText = this.hoverText;
}
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(); GL11.glPopMatrix();
} }
@@ -79,11 +86,15 @@ public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHo
this.hoverText = component.getHoverText(); this.hoverText = component.getHoverText();
} }
this.color = component.getColor();
this.alpha = component.getAlpha();
} }
public ICustomGuiComponent toComponent() { 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])); 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.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component; return component;
} }
@@ -16,12 +16,16 @@ import noppes.npcs.client.gui.custom.interfaces.IKeyListener;
import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.scripted.gui.ScriptGuiTextField; import noppes.npcs.scripted.gui.ScriptGuiTextField;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11;
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener { public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
GuiCustom parent; GuiCustom parent;
String[] hoverText; String[] hoverText;
int id; int id;
int color;
float alpha;
public CustomGuiTextField(int id, int x, int y, int width, int height) { public CustomGuiTextField(int id, int x, int y, int width, int height) {
super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height); super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
this.id = id; 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) { 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; 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(); this.drawTextBox();
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
if (hovered && this.hoverText != null && this.hoverText.length > 0) { if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText; 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); ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height);
component.setText(this.getText()); component.setText(this.getText());
component.setHoverText(this.hoverText); component.setHoverText(this.hoverText);
component.setColor(color);
component.setAlpha(alpha);
return component; return component;
} }
@@ -72,6 +83,9 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID
txt.setText(component.getText()); txt.setText(component.getText());
} }
txt.color = component.getColor();
txt.alpha = component.getAlpha();
return txt; return txt;
} }
@@ -8,13 +8,21 @@ package noppes.npcs.client.gui.custom.components;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator; 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 net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ImageDownloadAlt;
import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect; import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import org.lwjgl.opengl.GL11; 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 { public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
GuiCustom parent; GuiCustom parent;
ResourceLocation texture; ResourceLocation texture;
@@ -28,6 +36,10 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
float scale; float scale;
String[] hoverText; String[] hoverText;
int color;
float alpha;
float rotation;
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) { public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
this(id, texture, x, y, width, height, 0, 0); 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.scale = 1.0F;
this.id = id; this.id = id;
this.texture = new ResourceLocation(texture); this.texture = new ResourceLocation(texture);
this.x = GuiCustom.guiLeft + x; this.x = x;
this.y = GuiCustom.guiTop + y; this.y = y;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.textureX = textureX; this.textureX = textureX;
this.textureY = textureY; 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) { 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; boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(this.texture); 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) { if (hovered && this.hoverText != null && this.hoverText.length > 0) {
this.parent.hoverText = this.hoverText; 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); 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.setHoverText(this.hoverText);
component.setScale(this.scale); component.setScale(this.scale);
component.setColor(color);
component.setAlpha(alpha);
component.setRotation(rotation);
return component; return component;
} }
@@ -83,6 +133,10 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
rect.hoverText = component.getHoverText(); rect.hoverText = component.getHoverText();
} }
rect.color = component.getColor();
rect.alpha = component.getAlpha();
rect.rotation = component.getRotation();
return rect; 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.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager; 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.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2; import noppes.npcs.client.gui.util.*;
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.constants.EnumPacketServer; import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.containers.ContainerNPCInv; import noppes.npcs.containers.ContainerNPCInv;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11; 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 ContainerNPCInv container;
private ResourceLocation slot; private ResourceLocation slot;
private int inventoryTab = 0;
public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container) public GuiNPCInv(EntityNPCInterface npc,ContainerNPCInv container)
{ {
super(npc,container,3); 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(2,"inv.npcInventory", guiLeft + 191, guiTop + 5));
addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101)); addLabel(new GuiNpcLabel(3,"inv.inventory", guiLeft + 8, guiTop + 101));
for(int i = 0; i < 9; i++){ addLabel(new GuiNpcLabel(4,"Tab", guiLeft + 381, guiTop + 5));
int chance = 100; addButton(new GuiNpcButton(11, guiLeft + 375, guiTop + 13, 30, 20, "1"));
if(npc.inventory.dropchance.containsKey(i)){ addButton(new GuiNpcButton(12, guiLeft + 375, guiTop + 34, 30, 20, "2"));
chance = npc.inventory.dropchance.get(i);
} for(int c = 0; c < 4; c++) {
if(chance <= 0 || chance > 100) for (int r = 0; r < 9; r++) {
chance = 100; double chance = 100;
chances.put(i, chance); if (npc.inventory.dropchance.containsKey(r + c*9)) {
GuiNpcSlider slider = new GuiNpcSlider(this, i, guiLeft + 211, guiTop + 14 + i * 21, ((float)chance)/100); chance = npc.inventory.dropchance.get(r + c*9);
addSlider(slider); }
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 @Override
protected void actionPerformed(GuiButton guibutton) { protected void actionPerformed(GuiButton guibutton) {
if(guibutton.id == 10){ if(guibutton.id == 10){
npc.inventory.lootMode = ((GuiNpcButton)guibutton).getValue(); 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) 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); super.drawGuiContainerBackgroundLayer(f, i, j);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(slot); mc.renderEngine.bindTexture(slot);
for(int id = 4; id <= 6;id++){ for(int id = 4; id <= 6;id++){
Slot slot = container.getSlot(id); Slot slot = container.getSlot(id);
if(slot.getHasStack()) if(slot.getHasStack())
drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 1, guiTop + slot.yDisplayPosition -1, 0, 0, 18, 18); 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) public void drawScreen(int i, int j, float f)
{ {
@@ -149,18 +189,12 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
npc.inventory.readEntityFromNBT(compound); npc.inventory.readEntityFromNBT(compound);
initGui(); initGui();
} }
@Override @Override
public void mouseDragged(GuiNpcSlider guiNpcSlider) { public void unFocused(GuiNpcTextField textfield) {
guiNpcSlider.displayString = StatCollector.translateToLocal("inv.dropChance") + ": " + (int) (guiNpcSlider.sliderValue * 100) + "%"; if(textfield.id >= 2){
} chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
this.save();
@Override }
public void mousePressed(GuiNpcSlider guiNpcSlider) { }
}
@Override
public void mouseReleased(GuiNpcSlider guiNpcSlider) {
chances.put(guiNpcSlider.id, (int) (guiNpcSlider.sliderValue * 100));
}
} }
@@ -141,7 +141,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
} }
else if (button.id == 17) { else if (button.id == 17) {
ai.tacticalVariant = EnumNavType.values()[button.getValue()]; 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(); initGui();
} }
else if (button.id == 22) { else if (button.id == 22) {
@@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay; import noppes.npcs.DataDisplay;
import noppes.npcs.client.Client; import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil; 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)); addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + "")); addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
getTextField(2).integersOnly = true; 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)); //addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
y+=23; y+=23;
@@ -37,29 +37,35 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
quest = (QuestKill) q.questInterface; quest = (QuestKill) q.questInterface;
setBackground("menubg.png"); setBackground("largebg.png");
xSize = 356; bgScale = 1.7F;
ySize = 216; bgScaleX = 1.1F;
xSize = 300;
ySize = 300;
closeOnEsc = true; closeOnEsc = true;
} }
public void initGui() { public void initGui() {
super.initGui(); super.initGui();
guiTop -= 20;
int i = 0; 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()) { 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, this, fontRendererObj, guiLeft + 4, guiTop + 40 + 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.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, quest.targets.get(name) + ""));
this.getTextField(i+3).integersOnly = true; this.getTextField(i+12).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
i++; i++;
} }
for(;i < 3; i++){ for(;i < 12; i++){
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, "")); this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 40 + i * 22, 180, 20, ""));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1")); this.addTextField(new GuiNpcTextField(i + 12, this, fontRendererObj, guiLeft + 186, guiTop + 40 + i * 22, 24, 20, "1"));
this.getTextField(i+3).integersOnly = true; this.getTextField(i+12).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1); this.getTextField(i+12).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
} }
Map<?,?> data = EntityList.stringToClassMapping; Map<?,?> data = EntityList.stringToClassMapping;
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
@@ -78,9 +84,13 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
scroll.setList(list); scroll.setList(list);
scroll.setSize(130, 198); scroll.setSize(130, 198);
scroll.guiLeft = guiLeft + 220; scroll.guiLeft = guiLeft + 220;
scroll.guiTop = guiTop + 14; scroll.guiTop = guiTop + 40;
addScroll(scroll); 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(); scroll.visible = GuiNpcTextField.isFieldActive();
} }
@@ -90,6 +100,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
if (guibutton.id == 0) { if (guibutton.id == 0) {
close(); close();
} }
if (guibutton.id == 1) {
quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0;
}
} }
public void mouseClicked(int i, int j, int k) public void mouseClicked(int i, int j, int k)
{ {
@@ -101,18 +114,18 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
@Override @Override
public void unFocused(GuiNpcTextField guiNpcTextField) { public void unFocused(GuiNpcTextField guiNpcTextField) {
if(guiNpcTextField.id < 3) if(guiNpcTextField.id < 12)
lastSelected = guiNpcTextField; lastSelected = guiNpcTextField;
saveTargets(); saveTargets();
} }
private void saveTargets(){ private void saveTargets(){
HashMap<String,Integer> map = new HashMap<String,Integer>(); 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(); String name = getTextField(i).getText();
if(name.isEmpty()) if(name.isEmpty())
continue; continue;
map.put(name, getTextField(i+3).getInteger()); map.put(name, getTextField(i+12).getInteger());
} }
quest.targets = map; quest.targets = map;
} }
@@ -45,7 +45,10 @@ public abstract class GuiNPCInterface extends GuiScreen
public int mouseX, mouseY; public int mouseX, mouseY;
public float bgScale = 1; public float bgScale = 1;
public float bgScaleX = 1;
public float bgScaleY = 1;
public float bgScaleZ = 1;
public GuiNPCInterface(EntityNPCInterface npc) public GuiNPCInterface(EntityNPCInterface npc)
{ {
this.player = Minecraft.getMinecraft().thePlayer; this.player = Minecraft.getMinecraft().thePlayer;
@@ -102,7 +105,7 @@ public abstract class GuiNPCInterface extends GuiScreen
gui.setWorldAndResolution(mc, 350, 250); gui.setWorldAndResolution(mc, 350, 250);
extra.put(gui.id, gui); extra.put(gui.id, gui);
} }
public void mouseClicked(int i, int j, int k) public void mouseClicked(int i, int j, int k)
{ {
if(AWTWindow != null) if(AWTWindow != null)
@@ -202,11 +205,11 @@ public abstract class GuiNPCInterface extends GuiScreen
scrolls.put(scroll.id, scroll); scrolls.put(scroll.id, scroll);
} }
public GuiCustomScroll getScroll(int id){ public GuiCustomScroll getScroll(int id){
return scrolls.get(id); return scrolls.get(id);
} }
public abstract void save(); public abstract void save();
@Override @Override
public void drawScreen(int i, int j, float f){ public void drawScreen(int i, int j, float f){
if(AWTWindow != null){ if(AWTWindow != null){
@@ -223,12 +226,12 @@ public abstract class GuiNPCInterface extends GuiScreen
mouseY = j; mouseY = j;
if(drawDefaultBackground && subgui == null) if(drawDefaultBackground && subgui == null)
drawDefaultBackground(); drawDefaultBackground();
if(background != null && mc.renderEngine != null){ if(background != null && mc.renderEngine != null){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(guiLeft, guiTop, 0); GL11.glTranslatef(guiLeft, guiTop, 0);
GL11.glScalef(bgScale, bgScale, bgScale); GL11.glScalef(bgScale*bgScaleX, bgScale*bgScaleY, bgScale*bgScaleZ);
mc.renderEngine.bindTexture(background); mc.renderEngine.bindTexture(background);
if(xSize > 256){ if(xSize > 256){
drawTexturedModalRect(0, 0, 0, 0, 250, ySize); drawTexturedModalRect(0, 0, 0, 0, 250, ySize);
@@ -112,8 +112,6 @@ public class RenderCustomNpc extends RenderNPCHumanMale{
@Override @Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){ 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); super.doRender(entityliving, d, d1, d2, f, f1);
} }
@@ -1,6 +1,6 @@
package noppes.npcs.constants; package noppes.npcs.constants;
public enum EnumPacketClient { 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, 5, 81, 40));
addSlotToContainer(new Slot(npc.inventory, 6, 81, 58)); addSlotToContainer(new Slot(npc.inventory, 6, 81, 58));
for(int l = 0; l < 9; l++){ for(int c = 0; c < 4; c++) {
addSlotToContainer(new Slot(npc.inventory, l + 7 , 191 , 16 + l * 21)); 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 i1 = 0; i1 < 3; i1++){
for(int l1 = 0; l1 < 9; l1++){ for(int l1 = 0; l1 < 9; l1++){
addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, l1 * 18 + 8, 113 + i1 * 18)); addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, l1 * 18 + 8, 113 + i1 * 18));
} }
} }
for(int j1 = 0; j1 < 9; j1++){ for(int j1 = 0; j1 < 9; j1++){
@@ -3,10 +3,7 @@ package noppes.npcs.controllers;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; 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.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.Server; import noppes.npcs.Server;
import noppes.npcs.constants.EnumGuiType; 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.event.CustomGuiEvent;
import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import java.io.IOException; 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) { static boolean checkGui(CustomGuiEvent event) {
EntityPlayer player = (EntityPlayer) event.player.getMCEntity(); EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
if (!(player.openContainer instanceof ContainerCustomGui)) { if (!(player.openContainer instanceof ContainerCustomGui)) {
@@ -60,7 +60,17 @@ public class Dialog implements ICompatibilty, IDialog {
else else
showWheel = true; showWheel = true;
disableEsc = compound.getBoolean("DialogDisableEsc"); disableEsc = compound.getBoolean("DialogDisableEsc");
darkenScreen = compound.getBoolean("DialogDarkenScreen");
if(compound.hasKey("DialogDarkScreen")) {
darkenScreen = compound.getBoolean("DialogDarkScreen");
}
else {
darkenScreen = true;
}
// Temporary Remove after Few Versions
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
NBTTagList options = compound.getTagList("Options", 10); NBTTagList options = compound.getTagList("Options", 10);
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>(); HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
@@ -92,7 +102,12 @@ public class Dialog implements ICompatibilty, IDialog {
compound.setBoolean("DialogHideNPC", hideNPC); compound.setBoolean("DialogHideNPC", hideNPC);
compound.setBoolean("DialogShowWheel", showWheel); compound.setBoolean("DialogShowWheel", showWheel);
compound.setBoolean("DialogDisableEsc", disableEsc); compound.setBoolean("DialogDisableEsc", disableEsc);
compound.setBoolean("DialogDarkenScreen", darkenScreen);
compound.setBoolean("DialogDarkScreen", darkenScreen);
// Temporary Remove after Few Versions
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
if(sound != null && !sound.isEmpty()) if(sound != null && !sound.isEmpty())
compound.setString("DialogSound", sound); compound.setString("DialogSound", sound);
@@ -224,4 +239,39 @@ public class Dialog implements ICompatibilty, IDialog {
public void setCommand(String command) { public void setCommand(String command) {
this.command = 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) { public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
for(QuestData data : activeQuests.values()){ for(QuestData data : activeQuests.values()){
Quest quest = data.quest; 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 data;
} }
} }
return null; return null;
} }
public boolean checkQuestCompletion(EntityPlayer player,EnumQuestType type) { public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) {
boolean bo = false; boolean bo = false;
EntityPlayer player = playerData.player;
for(QuestData data : this.activeQuests.values()){ for(QuestData data : this.activeQuests.values()){
if(data.quest.type != type && type != null) if(data.quest.type != type && type != null)
continue; continue;
QuestInterface inter = data.quest.questInterface; QuestInterface inter = data.quest.questInterface;
if(inter.isCompleted(player)){ if(inter.isCompleted(playerData)){
if(!data.isCompleted){ if(!data.isCompleted){
if(!data.quest.complete(player,data)){ if(!data.quest.complete(player,data)){
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.completed", data.quest.title); 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.NpcAPI;
import noppes.npcs.scripted.handler.data.IQuest; import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.handler.data.IQuestCategory; 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.handler.data.IQuestObjective;
import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.IPlayer; import noppes.npcs.scripted.interfaces.IPlayer;
@@ -242,4 +243,8 @@ public class Quest implements ICompatibilty, IQuest {
public IContainer getRewards() { public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems); 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() protected void updateAITasks()
{ {
super.updateAITasks(); try {
super.updateAITasks();
} catch (ConcurrentModificationException ignored){
}
this.getNavigator().onUpdateNavigation(); this.getNavigator().onUpdateNavigation();
this.getMoveHelper().onUpdateMoveHelper(); this.getMoveHelper().onUpdateMoveHelper();
} }
@@ -472,10 +476,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
@Override @Override
public boolean attackEntityFrom(DamageSource damagesource, float i) { 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; return false;
} }
if(damagesource.damageType.equals("outOfWorld") && isKilled()){ if(damagesource.damageType != null && damagesource.damageType.equals("outOfWorld") && isKilled()){
reset(); reset();
} }
i = stats.resistances.applyResistance(damagesource, i); i = stats.resistances.applyResistance(damagesource, i);
@@ -14,9 +14,10 @@ import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestDialog;
import noppes.npcs.scripted.handler.data.IQuestObjective; 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>(); public HashMap<Integer,Integer> dialogs = new HashMap<Integer,Integer>();
@@ -31,9 +32,9 @@ public class QuestDialog extends QuestInterface{
} }
@Override @Override
public boolean isCompleted(EntityPlayer player) { public boolean isCompleted(PlayerData playerData) {
for(int dialogId : dialogs.values()) for(int dialogId : dialogs.values())
if(!PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId)) if(!playerData.dialogData.dialogsRead.contains(dialogId))
return false; return false;
return true; return true;
} }
@@ -93,17 +94,17 @@ public class QuestDialog extends QuestInterface{
public void setProgress(int progress) { public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) { 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); boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
if (progress == 0 && completed) { if (progress == 0 && completed) {
data.dialogData.dialogsRead.remove(this.dialog.id); 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()); data.saveNBTData(data.getNBT());
} }
if (progress == 1 && !completed) { if (progress == 1 && !completed) {
data.dialogData.dialogsRead.add(this.dialog.id); 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()); data.saveNBTData(data.getNBT());
} }
@@ -117,7 +118,7 @@ public class QuestDialog extends QuestInterface{
} }
public boolean isCompleted() { public boolean isCompleted() {
PlayerData data = PlayerData.get(this.player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
return data.dialogData.dialogsRead.contains(this.dialog.id); 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.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.handler.data.IQuestInterface;
import noppes.npcs.scripted.handler.data.IQuestObjective; import noppes.npcs.scripted.handler.data.IQuestObjective;
public abstract class QuestInterface { public abstract class QuestInterface implements IQuestInterface {
public int questId; public int questId;
public abstract void writeEntityToNBT(NBTTagCompound compound); public abstract void writeEntityToNBT(NBTTagCompound compound);
public abstract void readEntityFromNBT(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 void handleComplete(EntityPlayer player);
public abstract Vector<String> getQuestLogStatus(EntityPlayer player); public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
public abstract IQuestObjective[] getObjectives(EntityPlayer var1); public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
@@ -8,11 +8,13 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.NpcMiscInventory; import noppes.npcs.NpcMiscInventory;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestItem;
import noppes.npcs.scripted.handler.data.IQuestObjective; import noppes.npcs.scripted.handler.data.IQuestObjective;
import noppes.npcs.util.ValueUtil; import noppes.npcs.util.ValueUtil;
public class QuestItem extends QuestInterface{ public class QuestItem extends QuestInterface implements IQuestItem {
public NpcMiscInventory items = new NpcMiscInventory(3); public NpcMiscInventory items = new NpcMiscInventory(3);
public boolean leaveItems = false; public boolean leaveItems = false;
public boolean ignoreDamage = false; public boolean ignoreDamage = false;
@@ -35,8 +37,8 @@ public class QuestItem extends QuestInterface{
} }
@Override @Override
public boolean isCompleted(EntityPlayer player) { public boolean isCompleted(PlayerData playerData) {
HashMap<Integer,ItemStack> map = getProcessSet(player); HashMap<Integer,ItemStack> map = getProcessSet(playerData.player);
for(ItemStack reqItem : items.items.values()){ for(ItemStack reqItem : items.items.values()){
boolean done = false; boolean done = false;
for(ItemStack item : map.values()){ for(ItemStack item : map.values()){
@@ -137,6 +139,27 @@ public class QuestItem extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); 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 { class QuestItemObjective implements IQuestObjective {
private final QuestItem parent; private final QuestItem parent;
private final EntityPlayer player; 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.PlayerQuestData;
import noppes.npcs.controllers.QuestData; import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestKill;
import noppes.npcs.scripted.handler.data.IQuestObjective; 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>(); public HashMap<String,Integer> targets = new HashMap<String,Integer>();
public int targetType = 0;
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
}
@Override @Override
public void writeEntityToNBT(NBTTagCompound compound) { 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 @Override
public boolean isCompleted(EntityPlayer player) { public void readEntityFromNBT(NBTTagCompound compound) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; 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); QuestData data = playerdata.activeQuests.get(questId);
if(data == null) if(data == null)
return false; return false;
@@ -90,6 +103,18 @@ public class QuestKill extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); 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 { class QuestKillObjective implements IQuestObjective {
private final QuestKill parent; private final QuestKill parent;
private final EntityPlayer player; private final EntityPlayer player;
@@ -104,7 +129,7 @@ public class QuestKill extends QuestInterface{
} }
public int getProgress() { public int getProgress() {
PlayerData data = PlayerData.get(this.player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData; PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata); HashMap<String, Integer> killed = this.parent.getKilled(questdata);
@@ -113,15 +138,15 @@ public class QuestKill extends QuestInterface{
public void setProgress(int progress) { public void setProgress(int progress) {
if (progress >= 0 && progress <= this.amount) { if (progress >= 0 && progress <= this.amount) {
PlayerData data = PlayerData.get(this.player); PlayerData data = PlayerDataController.instance.getPlayerData(player);
PlayerQuestData playerdata = data.questData; PlayerQuestData playerdata = data.questData;
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId); QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
HashMap<String, Integer> killed = this.parent.getKilled(questdata); HashMap<String, Integer> killed = this.parent.getKilled(questdata);
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) { if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
killed.put(this.entity, progress); killed.put(this.entity, progress);
this.parent.setKilled(questdata, killed); this.parent.setKilled(questdata, killed);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[2]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[4]); data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
data.saveNBTData(data.getNBT()); data.saveNBTData(data.getNBT());
} }
} else { } else {
@@ -13,9 +13,10 @@ import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.QuestData; import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.handler.data.IQuestLocation;
import noppes.npcs.scripted.handler.data.IQuestObjective; import noppes.npcs.scripted.handler.data.IQuestObjective;
public class QuestLocation extends QuestInterface{ public class QuestLocation extends QuestInterface implements IQuestLocation {
public String location = ""; public String location = "";
public String location2 = ""; public String location2 = "";
public String location3 = ""; public String location3 = "";
@@ -36,8 +37,8 @@ public class QuestLocation extends QuestInterface{
} }
@Override @Override
public boolean isCompleted(EntityPlayer player) { public boolean isCompleted(PlayerData playerData) {
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerQuestData playerdata = playerData.questData;
QuestData data = playerdata.activeQuests.get(questId); QuestData data = playerdata.activeQuests.get(questId);
if(data == null) if(data == null)
return false; return false;
@@ -118,6 +119,27 @@ public class QuestLocation extends QuestInterface{
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]); 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 { class QuestLocationObjective implements IQuestObjective {
private final QuestLocation parent; private final QuestLocation parent;
private final EntityPlayer player; private final EntityPlayer player;
@@ -137,12 +159,12 @@ public class QuestLocation extends QuestInterface{
public void setProgress(int progress) { public void setProgress(int progress) {
if (progress >= 0 && progress <= 1) { 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); QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
boolean completed = questData.extraData.getBoolean (this.nbtName); boolean completed = questData.extraData.getBoolean (this.nbtName);
if ((!completed || progress != 1) && (completed || progress != 0)) { if ((!completed || progress != 1) && (completed || progress != 0)) {
questData.extraData.setBoolean(this.nbtName, progress == 1); 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()); data.saveNBTData(data.getNBT());
} }
} else { } else {
@@ -155,7 +177,7 @@ public class QuestLocation extends QuestInterface{
} }
public boolean isCompleted() { 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); QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
return questData.extraData.getBoolean(this.nbtName); return questData.extraData.getBoolean(this.nbtName);
} }
@@ -179,6 +179,16 @@ public class ScriptEntity<T extends Entity> implements IEntity {
entity.velocityChanged = true; 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 * @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(){ public float getRotation(){
return entity.rotationYaw; 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 power How strong the knockback is
* @param direction The direction in which he flies back (0-360). Usually based on getRotation() * @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) { 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) { public void hurt(float damage, ScriptDamageSource damageSource) {
@@ -1,6 +1,7 @@
package noppes.npcs.scripted.entity; package noppes.npcs.scripted.entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer; import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.*; import noppes.npcs.constants.*;
import noppes.npcs.controllers.Line; import noppes.npcs.controllers.Line;
@@ -53,6 +54,9 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setSize(int size){ public void setSize(int size){
if(size < 1) if(size < 1)
size = 1; size = 1;
if(size > CustomNpcs.NpcSizeLimit)
size = CustomNpcs.NpcSizeLimit;
npc.display.modelSize = size; npc.display.modelSize = size;
npc.script.clientNeedsUpdate = true; 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) * @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. * @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)) if(!npc.inventory.dropchance.containsKey(slot))
return 100; 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 slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot * @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) {
if(slot < 0 || slot > 8) if(!npc.inventory.dropchance.containsKey(slot))
return; return;
if(chance < 0) if(chance < 0)
@@ -609,10 +613,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
} }
public void setTacticalVariant(int variant){ public void setTacticalVariant(int variant){
if(variant > EnumNavType.values().length-1) if(variant > EnumNavType.values().length-1 || variant < 0)
return; return;
npc.ai.tacticalVariant = EnumNavType.values()[variant]; npc.ai.tacticalVariant = EnumNavType.values()[variant];
npc.ai.directLOS = EnumNavType.values()[variant] != EnumNavType.Stalk && npc.ai.directLOS;
} }
public int getTacticalVariant(){ public int getTacticalVariant(){
@@ -25,10 +25,8 @@ import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.event.FactionEvent; import noppes.npcs.scripted.event.FactionEvent;
import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.data.IQuest; import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.ICustomGui; import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.util.ValueUtil; import noppes.npcs.util.ValueUtil;
import java.util.ArrayList; import java.util.ArrayList;
@@ -71,6 +69,22 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
NoppesUtilPlayer.teleportPlayer(player, x, y, z, dimensionId); 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(){ public int getDimension(){
return player.dimension; 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){ public void setRotation(float rotationYaw, float rotationPitch){
NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension); 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() { public void updatePlayerInventory() {
((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges(); ((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges();
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData; PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
playerdata.checkQuestCompletion((EntityPlayer)this.entity, EnumQuestType.Item); PlayerQuestData questData = playerData.questData;
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
} }
public boolean checkGUIOpen() { public boolean checkGUIOpen() {
@@ -398,12 +417,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
return data.getGUIOpen(); 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() { public ScriptDBCPlayer<T> getDBCPlayer() {
Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c(); Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c();
Iterator iterator = keySet.iterator(); Iterator iterator = keySet.iterator();
@@ -459,7 +472,15 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
public void closeGui() { public void closeGui() {
((EntityPlayerMP)this.entity).closeContainer(); ((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() { public IQuest[] getFinishedQuests() {
@@ -42,8 +42,9 @@ public class PlayerEvent extends CustomNPCsEvent {
public final boolean isShiftPressed; public final boolean isShiftPressed;
public final boolean isMetaPressed; public final boolean isMetaPressed;
public final boolean keyDown; 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); super(player);
this.key = key; this.key = key;
this.isCtrlPressed = isCtrlPressed; this.isCtrlPressed = isCtrlPressed;
@@ -51,6 +52,7 @@ public class PlayerEvent extends CustomNPCsEvent {
this.isShiftPressed = isShiftPressed; this.isShiftPressed = isShiftPressed;
this.isMetaPressed = isMetaPressed; this.isMetaPressed = isMetaPressed;
this.keyDown = keyDown; this.keyDown = keyDown;
this.keysDown = heldKeys;
} }
} }
@@ -13,17 +13,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; 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.scripted.entity.ScriptPlayer;
import noppes.npcs.controllers.CustomGuiController; import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptContainer;
@@ -170,6 +161,18 @@ public class ScriptGui implements ICustomGui {
return (IScroll)this.components.get(this.components.size() - 1); 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) { public void showPlayerInventory(int x, int y) {
this.showPlayerInv = true; this.showPlayerInv = true;
this.playerInvX = x; this.playerInvX = x;
@@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTTagString;
import noppes.npcs.scripted.interfaces.ICustomGuiComponent; import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
public abstract class ScriptGuiComponent implements ICustomGuiComponent { public abstract class ScriptGuiComponent implements ICustomGuiComponent {
int id; int id;
@@ -11,6 +12,10 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
int posY; int posY;
String[] hoverText; String[] hoverText;
int color = 0xFFFFFF;
float alpha = 1.0F;
float rotation = 0;
public ScriptGuiComponent() { public ScriptGuiComponent() {
} }
@@ -55,11 +60,39 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
return this; 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 abstract int getType();
public NBTTagCompound toNBT(NBTTagCompound nbt) { public NBTTagCompound toNBT(NBTTagCompound nbt) {
nbt.setInteger("id", this.id); nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY}); 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) { if (this.hoverText != null) {
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
String[] var3 = this.hoverText; String[] var3 = this.hoverText;
@@ -84,6 +117,9 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) { public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
this.setID(nbt.getInteger("id")); this.setID(nbt.getInteger("id"));
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]); 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")) { if (nbt.hasKey("hover")) {
NBTTagList list = nbt.getTagList("hover", 8); NBTTagList list = nbt.getTagList("hover", 8);
String[] hoverText = new String[list.tagCount()]; String[] hoverText = new String[list.tagCount()];
@@ -112,6 +148,8 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
return (new ScriptGuiScroll()).fromNBT(nbt); return (new ScriptGuiScroll()).fromNBT(nbt);
case 5: case 5:
return (new ScriptGuiItemSlot()).fromNBT(nbt); return (new ScriptGuiItemSlot()).fromNBT(nbt);
case 6:
return (new ScriptGuiLine()).fromNBT(nbt);
default: default:
return null; return null;
} }
@@ -7,21 +7,20 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
String label; String label;
int width; int width;
int height; int height;
int color;
float scale; float scale;
boolean shadow;
public ScriptGuiLabel() { public ScriptGuiLabel() {
this.color = 16777215;
this.scale = 1.0F; this.scale = 1.0F;
} }
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) { public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) {
this.color = 16777215;
this.scale = 1.0F; this.scale = 1.0F;
this.setID(id); this.setID(id);
this.setText(label); this.setText(label);
this.setPos(x, y); this.setPos(x, y);
this.setSize(width, height); this.setSize(width, height);
this.enableShadow(false);
} }
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) { 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; return this;
} }
public int getColor() {
return this.color;
}
public ILabel setColor(int color) {
this.color = color;
return this;
}
public float getScale() { public float getScale() {
return this.scale; return this.scale;
} }
@@ -70,6 +60,14 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
return this; return this;
} }
public boolean hasShadow(){
return this.shadow;
}
public void enableShadow(boolean shadow){
this.shadow = shadow;
}
public int getType() { public int getType() {
return 1; return 1;
} }
@@ -78,8 +76,8 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
super.toNBT(nbt); super.toNBT(nbt);
nbt.setString("label", this.label); nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height}); nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setInteger("color", this.color);
nbt.setFloat("scale", this.scale); nbt.setFloat("scale", this.scale);
nbt.setBoolean("shadow",this.shadow);
return nbt; return nbt;
} }
@@ -87,8 +85,8 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
super.fromNBT(nbt); super.fromNBT(nbt);
this.setText(nbt.getString("label")); this.setText(nbt.getString("label"));
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]); this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
this.setColor(nbt.getInteger("color"));
this.setScale(nbt.getFloat("scale")); this.setScale(nbt.getFloat("scale"));
this.enableShadow(nbt.getBoolean("shadow"));
return this; 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(); 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(); void save();
} }
@@ -44,4 +44,6 @@ public interface IQuest {
void save(); void save();
boolean getIsRepeatable(); 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); 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);
IItemSlot addItemSlot(int var1, int var2, IItemStack var3); 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) * @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. * @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 slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot * @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); ILabel setSize(int var1, int var2);
int getColor();
ILabel setColor(int var1);
float getScale(); float getScale();
ILabel setScale(float var1); 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.gui.ScriptGui;
import noppes.npcs.scripted.handler.*; import noppes.npcs.scripted.handler.*;
import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.overlay.ScriptOverlay;
import noppes.npcs.util.JsonException; import noppes.npcs.util.JsonException;
import noppes.npcs.util.LRUHashMap; import noppes.npcs.util.LRUHashMap;
import noppes.npcs.util.NBTJsonUtil; import noppes.npcs.util.NBTJsonUtil;
@@ -233,7 +234,10 @@ public class WrapperNpcAPI extends NpcAPI {
} }
public IDamageSource getIDamageSource(IEntity entity) { 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) { 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) { public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) {
return new ScriptGui(id, width, height, pauseGame); return new ScriptGui(id, width, height, pauseGame);
} }
public ICustomOverlay createCustomOverlay(int id) {
return new ScriptOverlay(id);
}
} }