mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 21:04:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36992c5abd | ||
|
|
09f2e19c88 | ||
|
|
a53baefafa | ||
|
|
d6cd41946c | ||
|
|
1e088323e9 | ||
|
|
b90406ddd6 | ||
|
|
0ed0893682 | ||
|
|
ff37a8bec2 | ||
|
|
1e88a4458d | ||
|
|
a3414d8d75 | ||
|
|
e72672ad71 | ||
|
|
77ed924492 | ||
|
|
628fd1084e | ||
|
|
18a86d30e7 | ||
|
|
71216350d8 | ||
|
|
0732d98ff8 | ||
|
|
5ad6bb094a | ||
|
|
465f52b811 | ||
|
|
32f89f8e92 | ||
|
|
65bb3b5939 | ||
|
|
8c677901d0 | ||
|
|
dd67f12818 | ||
|
|
e95eb0ee98 | ||
|
|
ea3669fed8 | ||
|
|
6294062d23 | ||
|
|
5aa5fb335c | ||
|
|
be44db63d3 | ||
|
|
993e7a9d7c | ||
|
|
ebc0b96582 | ||
|
|
6101e75306 | ||
|
|
4abe8dca92 | ||
|
|
8749ba0280 | ||
|
|
6a0af3b0a0 | ||
|
|
f59b5d1e87 | ||
|
|
cddada1984 | ||
|
|
917f0d030a | ||
|
|
3454ecb78a | ||
|
|
57de575d42 | ||
|
|
8ab652361e | ||
|
|
694afb7b6b | ||
|
|
464f5ecb1e | ||
|
|
3066e1dfbc | ||
|
|
286f6862cb | ||
|
|
9a244ca2fe | ||
|
|
33378fba59 | ||
|
|
e26a0a1bd5 | ||
|
|
50fe08ce2e | ||
|
|
18ff2bff78 | ||
|
|
092592bd27 | ||
|
|
769a574210 | ||
|
|
df2e742cbb | ||
|
|
c0bac481ad | ||
|
|
d867017871 | ||
|
|
1752cdd14d | ||
|
|
1e771bce8a | ||
|
|
a507f06d7f | ||
|
|
df5c6afd2e | ||
|
|
dafd5f4460 | ||
|
|
08fb12f716 | ||
|
|
c0fa3935cd | ||
|
|
a10d79da9b | ||
|
|
0226001596 | ||
|
|
60e14f548e | ||
|
|
16321dd4ff | ||
|
|
1cb27a9e7a | ||
|
|
89b7019e29 | ||
|
|
3339488a6f | ||
|
|
1a7267349f | ||
|
|
5578f2055e | ||
|
|
e23620d724 | ||
|
|
3bc9686816 | ||
|
|
805054ceb0 | ||
|
|
75b7c01f87 | ||
|
|
f1741b4660 | ||
|
|
7f8246e04e | ||
|
|
65ab37158f | ||
|
|
d2d3cef681 | ||
|
|
403738262c | ||
|
|
90c6574125 | ||
|
|
7b0a6b7497 | ||
|
|
54fa6d106f | ||
|
|
451a60f297 | ||
|
|
3ac531a49d | ||
|
|
34b6eb05e5 | ||
|
|
4bdbe0efee | ||
|
|
c3bba543f0 | ||
|
|
d4f6df5a81 | ||
|
|
22b622d46c | ||
|
|
ee02988d8c | ||
|
|
450e065e27 | ||
|
|
c2a669fbeb | ||
|
|
732e97e0fe | ||
|
|
33e884c217 | ||
|
|
3d1caf494b | ||
|
|
18e02461a6 | ||
|
|
6bfbffb0e6 | ||
|
|
e42c4cab7e | ||
|
|
47f41ff5b7 | ||
|
|
5a86d1cc6f | ||
|
|
7d647d788f | ||
|
|
01e568d0c7 | ||
|
|
6d6daeb345 | ||
|
|
3844a26e8b | ||
|
|
2a4ace286e | ||
|
|
79ef0e07a1 | ||
|
|
7e0ff3c836 | ||
|
|
e3e55e4256 | ||
|
|
0c4ead5752 | ||
|
|
5d39c5b356 | ||
|
|
19ccdd60d2 | ||
|
|
d3145f4868 | ||
|
|
70536de655 | ||
|
|
1ebf747302 | ||
|
|
632e92f82e | ||
|
|
90ca1a0200 | ||
|
|
9109c134c1 | ||
|
|
1af875aea9 | ||
|
|
7de585843d | ||
|
|
67c83b1ce9 | ||
|
|
bc54e8cd7b | ||
|
|
8675d22ebb | ||
|
|
83e13285f9 | ||
|
|
3be088c4cc | ||
|
|
54fadbe63f | ||
|
|
da3b04e78e | ||
|
|
e7a19264b2 | ||
|
|
966ab4bf72 | ||
|
|
e5e1aa1972 | ||
|
|
be61bd4e17 | ||
|
|
534f716991 | ||
|
|
8b24dad211 | ||
|
|
6974476d92 | ||
|
|
fcaafe4b26 | ||
|
|
f876f13d77 | ||
|
|
989effb5c5 | ||
|
|
f14337f1bb | ||
|
|
eb45a6a959 | ||
|
|
a04f023d53 | ||
|
|
092b3ce0c1 | ||
|
|
971010bda8 | ||
|
|
06c730b166 | ||
|
|
b9bc1e5ed7 | ||
|
|
83756381e4 | ||
|
|
52f342302c | ||
|
|
0788b2750f | ||
|
|
8a9defd3a1 | ||
|
|
dff71c5a98 | ||
|
|
cb72f6c50e | ||
|
|
dd22f604cc | ||
|
|
05e6a97721 | ||
|
|
f8a6fe3d75 |
No files matched your search
Binary file not shown.
@@ -1,44 +1,47 @@
|
|||||||
|
|
||||||
|
## 👋 Welcome to the CustomNPC+ Repository.
|
||||||

|

|
||||||
|
|
||||||
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)
|
### 🔹 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
|
- PlayerData Storage Options [JSON/Zstd]
|
||||||
|
- Script Enchanments and Fixes
|
||||||
|
- 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 +51,12 @@ 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.
|
||||||
|
|
||||||
|
[](https://discord.gg/rgeWsmQaKa)
|
||||||
|
[](https://discord.gg/pQqRTvFeJ5)
|
||||||
|
[](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
|
||||||
|
[](https://github.com/KAMKEEL/Plugin-Mod)
|
||||||
|
<a href="https://ko-fi.com/kamkeel"> <img src="https://i.imgur.com/zvdVbeW.png" alt="Support Me on Kofi" width="180" height="27"> </a>
|
||||||
|
|
||||||
Binary file not shown.
+20
-21
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.4.2"
|
version = "1.6-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"
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ dependencies {
|
|||||||
// or you may define them like so..
|
// or you may define them like so..
|
||||||
//compile "some.group:artifact:version:classifier"
|
//compile "some.group:artifact:version:classifier"
|
||||||
//compile "some.group:artifact:version"
|
//compile "some.group:artifact:version"
|
||||||
|
|
||||||
// real examples
|
// real examples
|
||||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||||
@@ -42,27 +42,26 @@ dependencies {
|
|||||||
// for more info...
|
// for more info...
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources
|
processResources
|
||||||
{
|
{
|
||||||
// this will ensure that this task is redone when the versions change.
|
// this will ensure that this task is redone when the versions change.
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
inputs.property "mcversion", project.minecraft.version
|
inputs.property "mcversion", project.minecraft.version
|
||||||
|
|
||||||
// replace stuff in mcmod.info, nothing else
|
// replace stuff in mcmod.info, nothing else
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'mcmod.info'
|
include 'mcmod.info'
|
||||||
|
|
||||||
// replace version and mcversion
|
|
||||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy everything else, thats not the mcmod.info
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude 'mcmod.info'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {main { output.resourcesDir = output.classesDir }}
|
// replace version and mcversion
|
||||||
|
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy everything else, thats not the mcmod.info
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude 'mcmod.info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||||
@@ -123,6 +123,6 @@ public class CmdDialog extends ChMcLogger {
|
|||||||
option.dialogId = diagid;
|
option.dialogId = diagid;
|
||||||
option.title = dialog.title;
|
option.title = dialog.title;
|
||||||
npc.dialogs.put(0, option);
|
npc.dialogs.put(0, option);
|
||||||
NoppesUtilServer.openDialog(player, npc, dialog);
|
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.io.File;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
@@ -25,56 +23,46 @@ import net.minecraftforge.common.MinecraftForge;
|
|||||||
import nikedemos.markovnames.generators.*;
|
import nikedemos.markovnames.generators.*;
|
||||||
import noppes.npcs.config.ConfigLoader;
|
import noppes.npcs.config.ConfigLoader;
|
||||||
import noppes.npcs.config.ConfigProp;
|
import noppes.npcs.config.ConfigProp;
|
||||||
import noppes.npcs.controllers.BankController;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.ChunkController;
|
|
||||||
import noppes.npcs.controllers.DialogController;
|
|
||||||
import noppes.npcs.controllers.FactionController;
|
|
||||||
import noppes.npcs.controllers.GlobalDataController;
|
|
||||||
import noppes.npcs.controllers.LinkedNpcController;
|
|
||||||
import noppes.npcs.controllers.PixelmonHelper;
|
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.QuestController;
|
|
||||||
import noppes.npcs.controllers.RecipeController;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
import noppes.npcs.controllers.ServerCloneController;
|
|
||||||
import noppes.npcs.controllers.SpawnController;
|
|
||||||
import noppes.npcs.controllers.TransportController;
|
|
||||||
import noppes.npcs.enchants.EnchantInterface;
|
import noppes.npcs.enchants.EnchantInterface;
|
||||||
import noppes.npcs.entity.*;
|
import noppes.npcs.entity.*;
|
||||||
import noppes.npcs.entity.old.EntityNPCDwarfFemale;
|
import noppes.npcs.entity.old.*;
|
||||||
import noppes.npcs.entity.old.EntityNPCDwarfMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCElfFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCElfMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCEnderman;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCFurryFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCFurryMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCHumanFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCHumanMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCOrcFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCOrcMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCVillager;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcEnderchibi;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcMonsterFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcMonsterMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcNagaFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcNagaMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.4.2")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6-beta")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@ConfigProp(info = "Disable Chat Bubbles")
|
@ConfigProp(info = "Disable Chat Bubbles")
|
||||||
public static boolean EnableChatBubbles = true;
|
public static boolean EnableChatBubbles = true;
|
||||||
|
|
||||||
private static int NewEntityStartId = 0;
|
private static int NewEntityStartId = 0;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables/Disables ALL scripting. You can still see and write code in the scripter, but these scripts won't run. True by default")
|
||||||
|
public static boolean ScriptingEnabled = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global player event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
|
||||||
|
public static boolean GlobalPlayerScripts = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global forge event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
|
||||||
|
public static boolean GlobalForgeScripts = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global NPC scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. False by default, use with caution!")
|
||||||
|
public static boolean GlobalNPCScripts = false;
|
||||||
|
|
||||||
@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 +159,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();
|
||||||
|
|
||||||
@@ -215,14 +209,12 @@ public class CustomNpcs {
|
|||||||
registerNpc(EntityNPCGolem.class, "npcGolem");
|
registerNpc(EntityNPCGolem.class, "npcGolem");
|
||||||
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
|
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
|
||||||
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
|
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
|
||||||
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
|
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
|
||||||
|
|
||||||
new RecipeController();
|
new RecipeController();
|
||||||
|
|
||||||
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
||||||
|
|
||||||
new CustomNpcsPermissions();
|
new CustomNpcsPermissions();
|
||||||
@@ -258,6 +250,7 @@ public class CustomNpcs {
|
|||||||
new LinkedNpcController();
|
new LinkedNpcController();
|
||||||
ScriptController.Instance.loadStoredData();
|
ScriptController.Instance.loadStoredData();
|
||||||
ScriptController.Instance.loadForgeScripts();
|
ScriptController.Instance.loadForgeScripts();
|
||||||
|
ScriptController.Instance.loadNPCScripts();
|
||||||
ScriptController.Instance.loadPlayerScripts();
|
ScriptController.Instance.loadPlayerScripts();
|
||||||
ScriptController.HasStart = false;
|
ScriptController.HasStart = false;
|
||||||
WrapperNpcAPI.clearCache();
|
WrapperNpcAPI.clearCache();
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class DataScript implements IScriptHandler {
|
|||||||
return false;
|
return false;
|
||||||
if(!hasInited){
|
if(!hasInited){
|
||||||
hasInited = true;
|
hasInited = true;
|
||||||
|
EventHooks.onNPCInit(this.npc);
|
||||||
callScript(EnumScriptType.INIT);
|
callScript(EnumScriptType.INIT);
|
||||||
}
|
}
|
||||||
ScriptContainer script = scripts.get(type.ordinal());
|
ScriptContainer script = scripts.get(type.ordinal());
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.event.entity.EntityEvent;
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import noppes.npcs.controllers.CustomGuiController;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.Quest;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
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.*;
|
import noppes.npcs.scripted.*;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
import noppes.npcs.scripted.event.*;
|
import noppes.npcs.scripted.event.*;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
||||||
@@ -42,7 +42,6 @@ import noppes.npcs.scripted.interfaces.IItemStack;
|
|||||||
import noppes.npcs.scripted.interfaces.IWorld;
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -51,12 +50,146 @@ public class EventHooks {
|
|||||||
public EventHooks() {
|
public EventHooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onNPCInit(EntityNPCInterface npc) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
|
||||||
|
npc.script.callScript(EnumScriptType.INIT);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCUpdate(EntityNPCInterface npc) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event);
|
||||||
|
npc.script.callScript(EnumScriptType.TICK);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
|
||||||
|
|
||||||
|
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
|
||||||
|
|
||||||
|
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCRangedAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event);
|
||||||
|
npc.script.callScript(EnumScriptType.KILLS, "target", entity);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event);
|
||||||
|
npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCKilled(EntityNPCInterface npc, DamageSource damagesource, Entity entity, ScriptEventKilled killedEvent){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||||
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||||
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,9 +395,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -267,7 +253,7 @@ public class NoppesUtilPlayer {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
|
EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
|
||||||
|
|
||||||
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
||||||
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
@@ -285,7 +271,7 @@ public class NoppesUtilPlayer {
|
|||||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||||
}
|
}
|
||||||
else if(option.optionType == EnumOptionType.DialogOption){
|
else if(option.optionType == EnumOptionType.DialogOption){
|
||||||
NoppesUtilServer.openDialog(player, npc, option.getDialog());
|
NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1);
|
||||||
}
|
}
|
||||||
else if(option.optionType == EnumOptionType.CommandBlock){
|
else if(option.optionType == EnumOptionType.CommandBlock){
|
||||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class NoppesUtilServer {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
|
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
|
||||||
Dialog dialog = dia.copy(player);
|
Dialog dialog = dia.copy(player);
|
||||||
|
|
||||||
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
@@ -203,7 +203,7 @@ public class NoppesUtilServer {
|
|||||||
if(!data.dialogsRead.contains(dialog.id))
|
if(!data.dialogsRead.contains(dialog.id))
|
||||||
data.dialogsRead.add(dialog.id);
|
data.dialogsRead.add(dialog.id);
|
||||||
setEditingNpc(player, npc);
|
setEditingNpc(player, npc);
|
||||||
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id);
|
EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog);
|
||||||
}
|
}
|
||||||
public static void runCommand(EntityPlayer player, String name, String command){
|
public static void runCommand(EntityPlayer player, String name, String command){
|
||||||
runCommand(player, name, command, player);
|
runCommand(player, name, command, player);
|
||||||
@@ -312,11 +312,14 @@ public class NoppesUtilServer {
|
|||||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnScriptedParticle(Entity entity, String directory, int HEXcolor, int amount, int maxAge,
|
public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
double x, double y, double z,
|
double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||||
int entityID
|
int entityID
|
||||||
){
|
){
|
||||||
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||||
@@ -325,6 +328,9 @@ public class NoppesUtilServer {
|
|||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import noppes.npcs.containers.ContainerMail;
|
|||||||
import noppes.npcs.controllers.*;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
@@ -102,7 +103,7 @@ public class PacketHandlerServer{
|
|||||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||||
//player doesnt have permission to do this
|
//player doesnt have permission to do this
|
||||||
}
|
}
|
||||||
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
||||||
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
||||||
else {
|
else {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@@ -118,6 +119,8 @@ public class PacketHandlerServer{
|
|||||||
featherPackets(type, buffer, player);
|
featherPackets(type, buffer, player);
|
||||||
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||||
playerScriptPackets(type, buffer, player);
|
playerScriptPackets(type, buffer, player);
|
||||||
|
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
|
||||||
|
npcScriptPackets(type, buffer, player);
|
||||||
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||||
forgeScriptPackets(type, buffer, player);
|
forgeScriptPackets(type, buffer, player);
|
||||||
else if (item.getItem() == CustomItems.scripter)
|
else if (item.getItem() == CustomItems.scripter)
|
||||||
@@ -172,6 +175,18 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void npcScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if(type == EnumPacketServer.ScriptNPCGet) {
|
||||||
|
NPCDataScript data = ScriptController.Instance.npcScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
|
} else if(type == EnumPacketServer.ScriptNPCSave) {
|
||||||
|
ScriptController.Instance.setNPCScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
if(type == EnumPacketServer.DimensionsGet){
|
if(type == EnumPacketServer.DimensionsGet){
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
@@ -259,7 +257,7 @@ public class ServerEventsHandler {
|
|||||||
if(line != null)
|
if(line != null)
|
||||||
npc.saySurrounding(line.formatTarget(event.entityLiving));
|
npc.saySurrounding(line.formatTarget(event.entityLiving));
|
||||||
|
|
||||||
npc.script.callScript(EnumScriptType.KILLS, "target", event.entityLiving);
|
EventHooks.onNPCKilledEntity(npc,event.entityLiving);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityPlayer player = null;
|
EntityPlayer player = null;
|
||||||
@@ -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,17 @@ public class ServerEventsHandler {
|
|||||||
}
|
}
|
||||||
String name = entityName;
|
String name = entityName;
|
||||||
QuestKill quest = (QuestKill) data.quest.questInterface;
|
QuestKill quest = (QuestKill) data.quest.questInterface;
|
||||||
|
|
||||||
|
Class entityType = EntityNPCInterface.class;
|
||||||
|
if(quest.targetType == 2) {
|
||||||
|
try {
|
||||||
|
entityType = Class.forName(quest.customTargetType);
|
||||||
|
} catch (ClassNotFoundException notFoundException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(quest.targetType > 0 && !(entityType.isInstance(entity)))
|
||||||
|
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 +336,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
|
||||||
|
|||||||
@@ -12,11 +12,32 @@ import noppes.npcs.controllers.Lines;
|
|||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class VersionCompatibility {
|
public class VersionCompatibility {
|
||||||
public static int ModRev = 16;
|
public static int ModRev = 18;
|
||||||
|
|
||||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
||||||
if(npc.npcVersion == ModRev)
|
if(npc.npcVersion == ModRev)
|
||||||
return;
|
return;
|
||||||
|
if(npc.npcVersion < 18){
|
||||||
|
|
||||||
|
// Fix 64-Texture (Reorganization)
|
||||||
|
|
||||||
|
// Fix CloakTexture (Reorganization)
|
||||||
|
String cloakTexture = compound.getString("CloakTexture");
|
||||||
|
cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/");
|
||||||
|
cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/");
|
||||||
|
cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/");
|
||||||
|
compound.setString("CloakTexture", cloakTexture);
|
||||||
|
}
|
||||||
|
if(npc.npcVersion < 17){
|
||||||
|
// Fix DialogDarkenScreen
|
||||||
|
if(compound.hasKey("DialogDarkenScreen")){
|
||||||
|
compound.removeTag("DialogDarkenScreen");
|
||||||
|
}
|
||||||
|
// Remove MPM Texture Requirement
|
||||||
|
String texture = compound.getString("Texture");
|
||||||
|
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
|
||||||
|
compound.setString("Texture", texture);
|
||||||
|
}
|
||||||
if(npc.npcVersion < 12){
|
if(npc.npcVersion < 12){
|
||||||
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||||
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||||
|
|||||||
@@ -166,79 +166,27 @@ public class FlyPathFinder extends PathFinder
|
|||||||
b0 = 1;
|
b0 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
for(int y = -1; y <= 1; y ++) {
|
||||||
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
|
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
||||||
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
|
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
this.pathOptions[i++] = pathpoint3;
|
||||||
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
}
|
||||||
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
|
||||||
|
|
||||||
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
this.pathOptions[i++] = pathpoint4;
|
||||||
FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
}
|
||||||
FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
|
||||||
|
|
||||||
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_)
|
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
{
|
this.pathOptions[i++] = pathpoint5;
|
||||||
this.pathOptions[i++] = pathpoint3;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_)
|
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
{
|
this.pathOptions[i++] = pathpoint6;
|
||||||
this.pathOptions[i++] = pathpoint4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint7;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint9;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint11;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint12;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint13;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint14;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -29,48 +29,36 @@ public class FlyingMoveHelper extends EntityMoveHelper{
|
|||||||
if (this.update) {
|
if (this.update) {
|
||||||
this.update = false;
|
this.update = false;
|
||||||
|
|
||||||
double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
|
||||||
double speedMult = 0.6000000238418579D / 0.5D;
|
|
||||||
|
|
||||||
double d0 = this.posX - this.entity.posX;
|
double d0 = this.posX - this.entity.posX;
|
||||||
double d1 = this.posY - this.entity.posY;
|
double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D);
|
||||||
double d2 = this.posZ - this.entity.posZ;
|
double d2 = this.posZ - this.entity.posZ;
|
||||||
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
double d5 = MathHelper.sqrt_double(d4);
|
||||||
|
|
||||||
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
double heightOffGround = 0;
|
||||||
if (this.posY != this.entity.posY) {
|
if(this.entity.ai.hasFlyLimit) {
|
||||||
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) {
|
for (int blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||||
this.entity.motionY = 0.0D;
|
heightOffGround = this.posY - blockY;
|
||||||
|
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
|
||||||
if(verticalSpeed > speed * speedMult)
|
|
||||||
verticalSpeed = speed * speedMult;
|
|
||||||
verticalSpeed += this.entity.ai.flySpeed/2.0D;
|
|
||||||
|
|
||||||
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
|
|
||||||
verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
|
||||||
|
|
||||||
int blockY = (int) this.posY;
|
|
||||||
double heightOffGround = 0;
|
|
||||||
if(this.entity.ai.hasFlyLimit) {
|
|
||||||
for (blockY = (int) this.posY; blockY > 0; blockY--) {
|
|
||||||
heightOffGround = this.posY - blockY;
|
|
||||||
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit)
|
|
||||||
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double d5 = MathHelper.sqrt_double(d4);
|
|
||||||
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult;
|
|
||||||
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F);
|
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
||||||
|
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed;
|
||||||
|
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed;
|
||||||
|
|
||||||
|
if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) {
|
||||||
|
this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entity.velocityChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,15 +289,15 @@ public class PathNavigateFlying extends PathNavigate {
|
|||||||
|
|
||||||
private Vec3 getEntityPosition()
|
private Vec3 getEntityPosition()
|
||||||
{
|
{
|
||||||
return Vec3.createVectorHelper(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ);
|
return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
||||||
*/
|
*/
|
||||||
private int getPathableYPos()
|
private double getPathableYPos()
|
||||||
{
|
{
|
||||||
return (int)(this.theEntity.boundingBox.minY + 0.5D);
|
return this.theEntity.boundingBox.minY + 0.05D;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
else if(gui == EnumGuiType.PlayerTransporter)
|
else if(gui == EnumGuiType.PlayerTransporter)
|
||||||
return new GuiTransportSelection(npc);
|
return new GuiTransportSelection(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.Script)
|
else if(gui == EnumGuiType.Script && CustomNpcs.ScriptingEnabled)
|
||||||
return new GuiScript(npc);
|
return new GuiScript(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerAnvil)
|
else if(gui == EnumGuiType.PlayerAnvil)
|
||||||
|
|||||||
@@ -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()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,21 @@ public class NoppesUtil {
|
|||||||
float alphaRate = buffer.readFloat();
|
float alphaRate = buffer.readFloat();
|
||||||
int alphaRateStart = buffer.readInt();
|
int alphaRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationX1 = buffer.readFloat();
|
||||||
|
float rotationX2 = buffer.readFloat();
|
||||||
|
float rotationXRate = buffer.readFloat();
|
||||||
|
int rotationXRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationY1 = buffer.readFloat();
|
||||||
|
float rotationY2 = buffer.readFloat();
|
||||||
|
float rotationYRate = buffer.readFloat();
|
||||||
|
int rotationYRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationZ1 = buffer.readFloat();
|
||||||
|
float rotationZ2 = buffer.readFloat();
|
||||||
|
float rotationZRate = buffer.readFloat();
|
||||||
|
int rotationZRateStart = buffer.readInt();
|
||||||
|
|
||||||
int entityID = buffer.readInt();
|
int entityID = buffer.readInt();
|
||||||
|
|
||||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||||
@@ -113,6 +128,9 @@ public class NoppesUtil {
|
|||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
maxAge
|
maxAge
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ public class TranslateUtil {
|
|||||||
return null;
|
return null;
|
||||||
element = array.get(0);
|
element = array.get(0);
|
||||||
}
|
}
|
||||||
System.out.println(element.getAsString());
|
// System.out.println(element.getAsString());
|
||||||
return element.getAsString();
|
return element.getAsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import noppes.npcs.client.ClientProxy;
|
import noppes.npcs.client.ClientProxy;
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
public class EntityCustomFX extends EntityFX {
|
public class EntityCustomFX extends EntityFX {
|
||||||
@@ -27,10 +26,31 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
public float alphaRate = 0.0F;
|
public float alphaRate = 0.0F;
|
||||||
public int alphaRateStart = 0;
|
public int alphaRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationX = 0;
|
||||||
|
public float rotationX1 = 0;
|
||||||
|
public float rotationX2 = 0;
|
||||||
|
public float rotationXRate = 0.0F;
|
||||||
|
public int rotationXRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationY = 0;
|
||||||
|
public float rotationY1 = 0;
|
||||||
|
public float rotationY2 = 0;
|
||||||
|
public float rotationYRate = 0.0F;
|
||||||
|
public int rotationYRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationZ = 0;
|
||||||
|
public float rotationZ1 = 0;
|
||||||
|
public float rotationZ2 = 0;
|
||||||
|
public float rotationZRate = 0.0F;
|
||||||
|
public int rotationZRateStart = 0;
|
||||||
|
|
||||||
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||||
int age) {
|
int age) {
|
||||||
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||||
|
|
||||||
@@ -50,6 +70,30 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
if(alpha1 > alpha2)
|
if(alpha1 > alpha2)
|
||||||
this.alphaRate *= -1;
|
this.alphaRate *= -1;
|
||||||
|
|
||||||
|
this.rotationX1 = rotationX1;
|
||||||
|
this.rotationX2 = rotationX2;
|
||||||
|
this.rotationXRate = Math.abs(rotationXRate);
|
||||||
|
this.rotationXRateStart = rotationXRateStart;
|
||||||
|
rotationX = rotationX1;
|
||||||
|
if(rotationX1 > rotationX2)
|
||||||
|
this.rotationXRate *= -1;
|
||||||
|
|
||||||
|
this.rotationY1 = rotationY1;
|
||||||
|
this.rotationY2 = rotationY2;
|
||||||
|
this.rotationYRate = Math.abs(rotationYRate);
|
||||||
|
this.rotationYRateStart = rotationYRateStart;
|
||||||
|
rotationY = rotationY1;
|
||||||
|
if(rotationY1 > rotationY2)
|
||||||
|
this.rotationYRate *= -1;
|
||||||
|
|
||||||
|
this.rotationZ1 = rotationZ1;
|
||||||
|
this.rotationZ2 = rotationZ2;
|
||||||
|
this.rotationZRate = Math.abs(rotationZRate);
|
||||||
|
this.rotationZRateStart = rotationZRateStart;
|
||||||
|
rotationZ = rotationZ1;
|
||||||
|
if(rotationZ1 > rotationZ2)
|
||||||
|
this.rotationZRate *= -1;
|
||||||
|
|
||||||
particleGravity = gravity/0.04F;
|
particleGravity = gravity/0.04F;
|
||||||
particleMaxAge = age;
|
particleMaxAge = age;
|
||||||
|
|
||||||
@@ -75,85 +119,91 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
|
||||||
{
|
{
|
||||||
if(move){
|
|
||||||
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)par2);
|
|
||||||
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)par2);
|
|
||||||
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)par2);
|
|
||||||
}
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
float scale = this.scaleRate / (float)particleMaxAge;
|
|
||||||
if((this.scaleRate < 0 && particleScale+scale < this.scale2) || (this.scaleRate > 0 && particleScale+scale > this.scale2))
|
|
||||||
particleScale = this.scale2;
|
|
||||||
else if(particleAge >= this.scaleRateStart)
|
|
||||||
particleScale += scale;
|
|
||||||
|
|
||||||
float alpha = this.alphaRate / (float)particleMaxAge;
|
|
||||||
if((this.alphaRate < 0 && particleAlpha+alpha < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alpha > this.alpha2))
|
|
||||||
particleAlpha = this.alpha2;
|
|
||||||
else if(particleAge >= this.alphaRateStart)
|
|
||||||
particleAlpha += alpha;
|
|
||||||
|
|
||||||
ClientProxy.bindTexture(location);
|
|
||||||
|
|
||||||
float f = 0.0f;
|
|
||||||
float f1 = 1.0f;
|
|
||||||
float f2 = 0.0f;
|
|
||||||
float f3 = 1.0f;
|
|
||||||
float f4 = 0.1F * particleScale;
|
|
||||||
float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX);
|
|
||||||
float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY);
|
|
||||||
float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ);
|
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.setBrightness(240);
|
|
||||||
par1Tessellator.setColorOpaque_F(1, 1, 1);
|
|
||||||
par1Tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
|
||||||
par1Tessellator.addVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f1, f3);
|
|
||||||
par1Tessellator.addVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f1, f2);
|
|
||||||
par1Tessellator.addVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f, f2);
|
|
||||||
par1Tessellator.addVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f, f3);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
|
||||||
EntityPlayer player = minecraft.thePlayer;
|
|
||||||
|
|
||||||
double yaw = (player.rotationYaw/180)*Math.PI;
|
|
||||||
double pitch = (player.rotationPitch/180)*Math.PI;
|
|
||||||
|
|
||||||
double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
|
|
||||||
double angleRad = (angle/180)*Math.PI;
|
|
||||||
|
|
||||||
double angleX = Math.sin(yaw)*Math.cos(pitch);
|
|
||||||
if(Math.abs(angleX) < 0.0001){
|
|
||||||
angleX = 0.0D;
|
|
||||||
}
|
|
||||||
double angleY = Math.sin(pitch);
|
|
||||||
if(Math.abs(angleY) < 0.0001){
|
|
||||||
angleY = 0.0D;
|
|
||||||
}
|
|
||||||
double angleZ = -Math.cos(yaw)*Math.cos(pitch);
|
|
||||||
if(Math.abs(angleZ) < 0.0001){
|
|
||||||
angleZ = 0.0D;
|
|
||||||
}
|
|
||||||
|
|
||||||
double translateX = 0;
|
|
||||||
double translateY = 0;
|
|
||||||
double translateZ = 0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glColor4f(1, 1, 1, 1.0F);
|
ClientProxy.bindTexture(location);
|
||||||
//GL11.glTranslated(translateX,translateY,translateZ);
|
|
||||||
//GL11.glRotated(angle, angleX, angleY, angleZ);
|
if(move){
|
||||||
|
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
|
||||||
|
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
|
||||||
|
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
|
||||||
|
}
|
||||||
|
|
||||||
|
float scaleChange = this.scaleRate / (float)particleMaxAge;
|
||||||
|
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
|
||||||
|
particleScale = this.scale2;
|
||||||
|
else if(particleAge >= this.scaleRateStart)
|
||||||
|
particleScale += scaleChange;
|
||||||
|
|
||||||
|
float alphaChange = this.alphaRate / (float)particleMaxAge;
|
||||||
|
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
|
||||||
|
particleAlpha = this.alpha2;
|
||||||
|
else if(particleAge >= this.alphaRateStart)
|
||||||
|
particleAlpha += alphaChange;
|
||||||
|
|
||||||
|
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
|
||||||
|
rotationX = this.rotationX2;
|
||||||
|
else if(particleAge >= this.rotationXRateStart)
|
||||||
|
rotationX += rotationXChange;
|
||||||
|
|
||||||
|
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
|
||||||
|
rotationY = this.rotationY2;
|
||||||
|
else if(particleAge >= this.rotationYRateStart)
|
||||||
|
rotationY += rotationYChange;
|
||||||
|
|
||||||
|
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
|
||||||
|
rotationZ = this.rotationZ2;
|
||||||
|
else if(particleAge >= this.rotationZRateStart)
|
||||||
|
rotationZ += rotationZChange;
|
||||||
|
|
||||||
|
float u1 = 0.0f;
|
||||||
|
float u2 = 1.0f;
|
||||||
|
float v1 = 0.0f;
|
||||||
|
float v2 = 1.0f;
|
||||||
|
|
||||||
|
float renderScale = 0.1F * particleScale;
|
||||||
|
|
||||||
|
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
|
||||||
|
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
|
||||||
|
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
|
||||||
|
|
||||||
|
GL11.glTranslated((double)posX, (double)posY, (double)posZ);
|
||||||
|
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
double yaw = (player.rotationYaw/180)*Math.PI;
|
||||||
|
double pitch = (player.rotationPitch/180)*Math.PI;
|
||||||
|
|
||||||
|
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
|
||||||
|
rotationX += 180*Math.signum(rotationX);
|
||||||
|
}
|
||||||
|
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
|
||||||
|
rotationY += 180*Math.signum(rotationY);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
|
||||||
|
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
|
||||||
|
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(240);
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||||
|
tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2);
|
||||||
|
tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1);
|
||||||
|
tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1);
|
||||||
|
tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
ClientProxy.bindTexture(resource);
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||||
|
ClientProxy.bindTexture(resource);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFXLayer(){
|
public int getFXLayer(){
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
|
|
||||||
public GuiNpcMobSpawner(int i, int j, int k) {
|
public GuiNpcMobSpawner(int i, int j, int k) {
|
||||||
super();
|
super();
|
||||||
xSize = 384;
|
xSize = 354;
|
||||||
|
|
||||||
posX = i;
|
posX = i;
|
||||||
posY = j;
|
posY = j;
|
||||||
posZ = k;
|
posZ = k;
|
||||||
@@ -53,6 +52,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
guiTop += 10;
|
guiTop += 10;
|
||||||
|
guiLeft += 30;
|
||||||
|
|
||||||
if(scroll == null){
|
if(scroll == null){
|
||||||
scroll = new GuiCustomScroll(this,0);
|
scroll = new GuiCustomScroll(this,0);
|
||||||
@@ -69,36 +69,37 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
GuiMenuTopButton button;
|
GuiMenuTopButton button;
|
||||||
addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
|
addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
|
||||||
button.active = showingClones == 0;
|
button.active = showingClones == 0;
|
||||||
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
|
|
||||||
button.active = showingClones == 1;
|
|
||||||
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
|
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
|
||||||
button.active = showingClones == 2;
|
button.active = showingClones == 2;
|
||||||
|
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
|
||||||
|
button.active = showingClones == 1;
|
||||||
|
|
||||||
addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 82, 20, "item.monsterPlacer.name"));
|
addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 52, 20, "item.monsterPlacer.name"));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 82, 20, "spawner.mobspawner"));
|
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 52, 20, "spawner.mobspawner"));
|
||||||
|
|
||||||
if(showingClones == 0 || showingClones == 2){
|
if(showingClones == 0 || showingClones == 2){
|
||||||
|
|
||||||
addSideButton(new GuiMenuSideButton(21,guiLeft - 90, this.guiTop + 2, 90,22, "1"));
|
addSideButton(new GuiMenuSideButton(21,guiLeft - 70, this.guiTop + 2, 70,22, "1"));
|
||||||
addSideButton(new GuiMenuSideButton(22,guiLeft - 90, this.guiTop + 23, 90,22, "2"));
|
addSideButton(new GuiMenuSideButton(22,guiLeft - 70, this.guiTop + 23, 70,22, "2"));
|
||||||
addSideButton(new GuiMenuSideButton(23,guiLeft - 90, this.guiTop + 44, 90,22, "3"));
|
addSideButton(new GuiMenuSideButton(23,guiLeft - 70, this.guiTop + 44, 70,22, "3"));
|
||||||
addSideButton(new GuiMenuSideButton(24,guiLeft - 90, this.guiTop + 65, 90,22, "4"));
|
addSideButton(new GuiMenuSideButton(24,guiLeft - 70, this.guiTop + 65, 70,22, "4"));
|
||||||
addSideButton(new GuiMenuSideButton(25,guiLeft - 90, this.guiTop + 86, 90,22, "5"));
|
addSideButton(new GuiMenuSideButton(25,guiLeft - 70, this.guiTop + 86, 70,22, "5"));
|
||||||
addSideButton(new GuiMenuSideButton(26,guiLeft - 90, this.guiTop + 107, 45,22, "6"));
|
addSideButton(new GuiMenuSideButton(26,guiLeft - 70, this.guiTop + 107, 35,22, "6"));
|
||||||
addSideButton(new GuiMenuSideButton(27,guiLeft - 45, this.guiTop + 107, 45,22, "7"));
|
addSideButton(new GuiMenuSideButton(27,guiLeft - 35, this.guiTop + 107, 35,22, "7"));
|
||||||
addSideButton(new GuiMenuSideButton(28,guiLeft - 90, this.guiTop + 128, 45,22, "8"));
|
addSideButton(new GuiMenuSideButton(28,guiLeft - 70, this.guiTop + 128, 35,22, "8"));
|
||||||
addSideButton(new GuiMenuSideButton(29,guiLeft - 45, this.guiTop + 128, 45,22, "9"));
|
addSideButton(new GuiMenuSideButton(29,guiLeft - 35, this.guiTop + 128, 35,22, "9"));
|
||||||
addSideButton(new GuiMenuSideButton(30,guiLeft - 90, this.guiTop + 149, 45,22, "10"));
|
addSideButton(new GuiMenuSideButton(30,guiLeft - 70, this.guiTop + 149, 35,22, "10"));
|
||||||
addSideButton(new GuiMenuSideButton(31,guiLeft - 45, this.guiTop + 149, 45,22, "11"));
|
addSideButton(new GuiMenuSideButton(31,guiLeft - 35, this.guiTop + 149, 35,22, "11"));
|
||||||
addSideButton(new GuiMenuSideButton(32,guiLeft - 90, this.guiTop + 170, 45,22, "12"));
|
addSideButton(new GuiMenuSideButton(32,guiLeft - 70, this.guiTop + 170, 35,22, "12"));
|
||||||
addSideButton(new GuiMenuSideButton(33,guiLeft - 45, this.guiTop + 170, 45,22, "13"));
|
addSideButton(new GuiMenuSideButton(33,guiLeft - 35, this.guiTop + 170, 35,22, "13"));
|
||||||
addSideButton(new GuiMenuSideButton(34,guiLeft - 90, this.guiTop + 191, 45,22, "14"));
|
addSideButton(new GuiMenuSideButton(34,guiLeft - 70, this.guiTop + 191, 35,22, "14"));
|
||||||
addSideButton(new GuiMenuSideButton(35,guiLeft - 45, this.guiTop + 191, 45,22, "15"));
|
addSideButton(new GuiMenuSideButton(35,guiLeft - 35, this.guiTop + 191, 35,22, "15"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove"));
|
// addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove"));
|
||||||
|
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove"));
|
||||||
|
|
||||||
getSideButton(20 + activeTab).active = true;
|
getSideButton(20 + activeTab).active = true;
|
||||||
showClones();
|
showClones();
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.DataScript;
|
import noppes.npcs.DataScript;
|
||||||
import noppes.npcs.NoppesStringUtils;
|
import noppes.npcs.NoppesStringUtils;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -500,7 +513,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) {
|
protected void keyTyped(char typedChar, int keyCode) {
|
||||||
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
|
if (keyCode == 1)
|
||||||
{
|
{
|
||||||
this.mc.thePlayer.closeScreen();
|
this.mc.thePlayer.closeScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
@@ -59,7 +119,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f;
|
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.field_146167_a && mouseY < this.y + this.field_146161_f;
|
||||||
this.drawLabel();
|
this.drawLabel();
|
||||||
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;
|
||||||
@@ -75,14 +135,19 @@ 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();
|
||||||
|
lbl.field_146167_a = component.getWidth();
|
||||||
|
lbl.field_146161_f = component.getHeight();
|
||||||
|
|
||||||
return lbl;
|
return lbl;
|
||||||
}
|
}
|
||||||
@@ -90,34 +155,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-6
@@ -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) {
|
||||||
@@ -53,10 +71,38 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + 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.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
|
||||||
|
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
|
||||||
|
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||||
|
|
||||||
|
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 +113,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 +132,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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+553
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+132
@@ -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);
|
||||||
@@ -45,36 +46,70 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
|
|||||||
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
||||||
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
||||||
getTextField(0).integersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0);
|
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
||||||
getTextField(1).integersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0);
|
|
||||||
|
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
|
||||||
|
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
|
||||||
|
|
||||||
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
||||||
|
|
||||||
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 +117,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 +190,14 @@ 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()));
|
||||||
|
}
|
||||||
@Override
|
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
|
||||||
public void mousePressed(GuiNpcSlider guiNpcSlider) {
|
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
|
||||||
}
|
this.save();
|
||||||
|
}
|
||||||
@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,17 @@ 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 + 310, 98, 20, "gui.back"));
|
||||||
|
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType));
|
||||||
|
|
||||||
|
this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType));
|
||||||
|
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
|
||||||
|
|
||||||
|
guiTop -= 50;
|
||||||
|
|
||||||
scroll.visible = GuiNpcTextField.isFieldActive();
|
scroll.visible = GuiNpcTextField.isFieldActive();
|
||||||
}
|
}
|
||||||
@@ -90,6 +104,10 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
if (guibutton.id == 0) {
|
if (guibutton.id == 0) {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
if (guibutton.id == 1) {
|
||||||
|
quest.targetType = this.getButton(1).getValue();
|
||||||
|
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void mouseClicked(int i, int j, int k)
|
public void mouseClicked(int i, int j, int k)
|
||||||
{
|
{
|
||||||
@@ -101,18 +119,21 @@ 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;
|
||||||
|
|
||||||
|
if(guiNpcTextField.id == 36)
|
||||||
|
quest.customTargetType = guiNpcTextField.getText();
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,8 +163,6 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
|
|||||||
}
|
}
|
||||||
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
||||||
if(btn.id == 170){
|
if(btn.id == 170){
|
||||||
System.out.println(part.rotationX);
|
|
||||||
System.out.println(rotateX.sliderValue);
|
|
||||||
part.rotationX = 0.0f;
|
part.rotationX = 0.0f;
|
||||||
rotateX.sliderValue = 0.5f;
|
rotateX.sliderValue = 0.5f;
|
||||||
int percent = (int) ((rotateX.sliderValue) * 360);
|
int percent = (int) ((rotateX.sliderValue) * 360);
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
|
|
||||||
|
public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||||
|
private NPCDataScript script = new NPCDataScript(null);
|
||||||
|
|
||||||
|
public GuiScriptAllNPCs() {
|
||||||
|
this.handler = this.script;
|
||||||
|
Client.sendData(EnumPacketServer.ScriptNPCGet, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
this.script.readFromNBT(compound);
|
||||||
|
super.setGuiData(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
super.save();
|
||||||
|
Client.sendData(EnumPacketServer.ScriptNPCSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
ScriptController.Instance.npcScripts.errored.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ package noppes.npcs.client.gui.script;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
@@ -23,8 +24,17 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
|||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
this.addButton(new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players"));
|
GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players");
|
||||||
this.addButton(new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge"));
|
playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(playerButton);
|
||||||
|
|
||||||
|
GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge");
|
||||||
|
forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(forgeButton);
|
||||||
|
|
||||||
|
GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs");
|
||||||
|
npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(npcButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawScreen(int i, int j, float f) {
|
public void drawScreen(int i, int j, float f) {
|
||||||
@@ -42,6 +52,9 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
|||||||
if (guibutton.id == 1) {
|
if (guibutton.id == 1) {
|
||||||
this.displayGuiScreen(new GuiScriptForge());
|
this.displayGuiScreen(new GuiScriptForge());
|
||||||
}
|
}
|
||||||
|
if (guibutton.id == 2) {
|
||||||
|
this.displayGuiScreen(new GuiScriptAllNPCs());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyTyped(char c, int i) {
|
public void keyTyped(char c, int i) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import noppes.npcs.client.gui.util.*;
|
|||||||
import noppes.npcs.controllers.IScriptHandler;
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -147,6 +148,22 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
hookList.add("customGuiSlot");
|
hookList.add("customGuiSlot");
|
||||||
hookList.add("customGuiScroll");
|
hookList.add("customGuiScroll");
|
||||||
hookList.add("customGuiTextfield");
|
hookList.add("customGuiTextfield");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(handler instanceof NPCDataScript) {
|
||||||
|
hookList.add("init");
|
||||||
|
hookList.add("tick");
|
||||||
|
hookList.add("interact");
|
||||||
|
hookList.add("dialog");
|
||||||
|
hookList.add("damaged");
|
||||||
|
hookList.add("killed");
|
||||||
|
hookList.add("meleeAttack");
|
||||||
|
hookList.add("rangedLaunched");
|
||||||
|
hookList.add("target");
|
||||||
|
hookList.add("collide");
|
||||||
|
hookList.add("kills");
|
||||||
|
hookList.add("dialogClose");
|
||||||
|
hookList.add("timer");
|
||||||
}
|
}
|
||||||
else if(handler instanceof ForgeDataScript) {
|
else if(handler instanceof ForgeDataScript) {
|
||||||
hooks.setSize(238, 198);
|
hooks.setSize(238, 198);
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
|
|||||||
{
|
{
|
||||||
private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
||||||
private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
||||||
private GuiNpcMenu menu;
|
private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs","textures/gui/menubg2.png");
|
||||||
|
|
||||||
|
private GuiNpcMenu menu;
|
||||||
public int menuYOffset = 0;
|
public int menuYOffset = 0;
|
||||||
|
|
||||||
public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont)
|
public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont)
|
||||||
@@ -74,18 +76,12 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
|
|||||||
mc.renderEngine.bindTexture(background);
|
mc.renderEngine.bindTexture(background);
|
||||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256);
|
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
mc.renderEngine.bindTexture(defaultBackground);
|
mc.renderEngine.bindTexture(defaultBackground2);
|
||||||
drawTexturedModalRect(guiLeft + xSize-200, guiTop, 26, 0, 200, 220);
|
drawTexturedModalRect(guiLeft + xSize-256, guiTop, 0, 0, 256, 220);
|
||||||
|
|
||||||
menu.drawElements(fontRendererObj, i, j, mc, f);
|
menu.drawElements(fontRendererObj, i, j, mc, f);
|
||||||
|
|
||||||
super.drawGuiContainerBackgroundLayer(f, i, j);
|
super.drawGuiContainerBackgroundLayer(f, i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void drawSlotInventory(Slot par1Slot)
|
|
||||||
// {this.dra
|
|
||||||
// if(subgui == null)
|
|
||||||
// super.drawSlotInventory(par1Slot);
|
|
||||||
// } //TODO fix
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import noppes.npcs.entity.EntityCustomNpc;
|
|||||||
import noppes.npcs.roles.JobPuppet;
|
import noppes.npcs.roles.JobPuppet;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
public class ModelMPM extends ModelNPCMale{
|
public class ModelMPM extends ModelNPCMale{
|
||||||
private ModelPartInterface wings;
|
private ModelPartInterface wings;
|
||||||
@@ -65,13 +66,10 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
public boolean isArmor;
|
public boolean isArmor;
|
||||||
public float alpha = 1;
|
public float alpha = 1;
|
||||||
|
|
||||||
// Check Legacy Code for Old Version
|
|
||||||
|
|
||||||
// Updated False = 64x32 Skin
|
|
||||||
// Steve 64x64 and Alex 64x64
|
// Steve 64x64 and Alex 64x64
|
||||||
public ModelMPM(float par1, boolean arms) {
|
public ModelMPM(float par1, boolean alex) {
|
||||||
|
|
||||||
super(par1, arms);
|
super(par1, alex);
|
||||||
isArmor = par1 > 0;
|
isArmor = par1 > 0;
|
||||||
float par2 = 0;
|
float par2 = 0;
|
||||||
|
|
||||||
@@ -101,7 +99,7 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
// this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
|
// this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
|
||||||
|
|
||||||
// Steve 64x64 Model or Alex 64x64 Model
|
// Steve 64x64 Model or Alex 64x64 Model
|
||||||
if (arms){
|
if (alex){
|
||||||
// Alex Version
|
// Alex Version
|
||||||
this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
|
this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
|
||||||
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
|
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
|
||||||
@@ -114,13 +112,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Alex");
|
||||||
this.bipedRightArm.addChild(this.solidRightArmWear);
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Alex");
|
||||||
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -136,13 +134,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Steve");
|
||||||
this.bipedRightArm.addChild(this.solidRightArmWear);
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Steve");
|
||||||
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,13 +155,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
||||||
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
||||||
this.solidRightLegWear = new ModelLimbWear(this,"leg","right");
|
this.solidRightLegWear = new ModelLimbWear(this,"leg","right","Steve");
|
||||||
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
||||||
|
|
||||||
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
||||||
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
||||||
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left");
|
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left","Steve");
|
||||||
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ public class ModelNPCMale extends ModelBiped
|
|||||||
init(f, 0.0F);
|
init(f, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelNPCMale(float f, boolean arms)
|
public ModelNPCMale(float f, boolean alex)
|
||||||
{
|
{
|
||||||
super(f, 0.0F, 64, 64);
|
super(f, 0.0F, 64, 64);
|
||||||
init(f, 0.0F, arms);
|
init(f, 0.0F, alex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
package noppes.npcs.client.model.part;
|
package noppes.npcs.client.model.part;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
@@ -6,18 +8,32 @@ import noppes.npcs.client.model.util.Model2DRenderer;
|
|||||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||||
|
|
||||||
public class ModelLimbWear extends ModelScaleRenderer {
|
public class ModelLimbWear extends ModelScaleRenderer {
|
||||||
public ModelLimbWear(ModelBase base, String limb, String side) {
|
public ModelLimbWear(ModelBase base, String limb, String side, String type) {
|
||||||
super(base);
|
super(base);
|
||||||
|
|
||||||
float thick = 0.55f;
|
float thick = 0.55f;
|
||||||
switch (limb){
|
switch (limb){
|
||||||
case "arm":
|
case "arm":
|
||||||
switch (side){
|
switch(type) {
|
||||||
case "right":
|
case "Steve":
|
||||||
rightArm(base,thick);
|
switch (side) {
|
||||||
|
case "right":
|
||||||
|
rightArm(base, thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftArm(base, thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "left":
|
case "Alex":
|
||||||
leftArm(base,thick);
|
switch (side) {
|
||||||
|
case "right":
|
||||||
|
rightArmAlex(base, thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftArmAlex(base, thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -36,6 +52,100 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rightArmAlex(ModelBase base, float thick){
|
||||||
|
float x = 0.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 44, 36, 3, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 51, 36, 3, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 47, 36, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 3, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 47, 32, 3, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leftArmAlex(ModelBase base,float thick){
|
||||||
|
float x = 1.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 44+8, 36+16, 3, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 51+8, 36+16, 3, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 47+8, 36+16, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 40+8, 36+16, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 44+8, 32+16, 3, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 47+8, 32+16, 3, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
public void rightArm(ModelBase base, float thick){
|
public void rightArm(ModelBase base, float thick){
|
||||||
float x = 0.95f;
|
float x = 0.95f;
|
||||||
float y = -2.0f;
|
float y = -2.0f;
|
||||||
@@ -55,17 +165,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.1f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-3.98f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
|
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
|
||||||
@@ -102,17 +212,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.06f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
@@ -150,17 +260,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
@@ -198,17 +308,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
|
|||||||
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
|
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.ModelBiped;
|
import net.minecraft.client.model.ModelBiped;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
@@ -11,7 +12,6 @@ import net.minecraft.client.renderer.entity.RenderBiped;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -23,8 +23,6 @@ import noppes.npcs.client.model.ModelNPCMale;
|
|||||||
import noppes.npcs.constants.EnumAnimation;
|
import noppes.npcs.constants.EnumAnimation;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.items.ItemClaw;
|
|
||||||
import noppes.npcs.items.ItemShield;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@@ -36,8 +34,8 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
protected ModelNPCMale modelArmor;
|
protected ModelNPCMale modelArmor;
|
||||||
|
|
||||||
protected final ModelNPCMale originalBipedMain;
|
protected final ModelNPCMale originalBipedMain;
|
||||||
protected final ModelMPM steve = new ModelMPM(0, false);
|
protected final static ModelMPM steve64 = new ModelMPM(0, false);
|
||||||
protected final ModelMPM alex = new ModelMPM(0, true);
|
protected final static ModelMPM alex = new ModelMPM(0, true);
|
||||||
|
|
||||||
public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor)
|
public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor)
|
||||||
{
|
{
|
||||||
@@ -113,14 +111,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2,
|
public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2,
|
||||||
float f, float f1)
|
float f, float f1)
|
||||||
{
|
{
|
||||||
// SEEMS TO WORK FOR NOW. Keeps NPC from outsyncing with Creature Models
|
|
||||||
if(npc instanceof EntityCustomNpc){
|
if(npc instanceof EntityCustomNpc){
|
||||||
EntityCustomNpc test = (EntityCustomNpc) npc;
|
EntityCustomNpc test = (EntityCustomNpc) npc;
|
||||||
if(test.modelData.entityClass == null){
|
if(test.modelData.entityClass == null){
|
||||||
int modelVal = npc.display.modelType;
|
int modelVal = npc.display.modelType;
|
||||||
if(modelVal == 1){
|
if(modelVal == 1){
|
||||||
this.mainModel = steve;
|
this.mainModel = steve64;
|
||||||
this.modelBipedMain = steve;
|
this.modelBipedMain = steve64;
|
||||||
}
|
}
|
||||||
else if(modelVal == 2){
|
else if(modelVal == 2){
|
||||||
this.mainModel = alex;
|
this.mainModel = alex;
|
||||||
@@ -177,7 +174,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture);
|
npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture);
|
||||||
}
|
}
|
||||||
bindTexture((ResourceLocation) npc.textureCloakLocation);
|
bindTexture((ResourceLocation) npc.textureCloakLocation);
|
||||||
//AbstractClientPlayer.func_110307_b(, null);
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
|
||||||
double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f);
|
double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f);
|
||||||
@@ -193,13 +189,12 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
f14 = 0.0F;
|
f14 = 0.0F;
|
||||||
}
|
}
|
||||||
float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f;
|
float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f;
|
||||||
//f13 += MathHelper.sin((entityplayer.prevDistanceWalkedModified + (entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified) * f) * 6F) * 32F * f16;
|
|
||||||
float f13 = 5f;
|
float f13 = 5f;
|
||||||
if (npc.isSneaking())
|
if (npc.isSneaking())
|
||||||
{
|
{
|
||||||
f13 += 25F;
|
f13 += 25F;
|
||||||
}
|
}
|
||||||
//System.out.println(entityplayer.prevDistanceWalkedModified);
|
|
||||||
GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F);
|
GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F);
|
||||||
GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F);
|
GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F);
|
||||||
GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F);
|
||||||
@@ -255,7 +250,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
||||||
}
|
}
|
||||||
this.modelBipedMain.bipedRightArm.postRender(0.0625F);
|
this.modelBipedMain.bipedRightArm.postRender(0.0625F);
|
||||||
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
|
|
||||||
|
if(npc.getModelType() == 2){
|
||||||
|
GL11.glTranslatef(-0.0125F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
||||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
||||||
@@ -269,8 +270,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||||
GL11.glScalef(-var6, -var6, var6);
|
GL11.glScalef(-var6, -var6, var6);
|
||||||
}
|
}
|
||||||
// CHANGE HERE
|
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
|
||||||
else if (itemstack2.getItem() instanceof ItemBow)
|
|
||||||
{
|
{
|
||||||
var6 = 0.625F;
|
var6 = 0.625F;
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
@@ -343,8 +343,15 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
||||||
}
|
}
|
||||||
this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
|
this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
|
||||||
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
|
|
||||||
float var6;
|
if(npc.getModelType() == 2){
|
||||||
|
GL11.glTranslatef(0.0125F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
|
||||||
|
float var6;
|
||||||
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
||||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
||||||
@@ -362,7 +369,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||||
GL11.glScalef(var6, -var6, var6);
|
GL11.glScalef(var6, -var6, var6);
|
||||||
}
|
}
|
||||||
else if (itemstack2.getItem() instanceof ItemBow)
|
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
|
||||||
{
|
{
|
||||||
var6 = 0.625F;
|
var6 = 0.625F;
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
|
||||||
public class RenderNPCInterface extends RenderLiving{
|
public class RenderNPCInterface extends RenderLiving{
|
||||||
public static long LastTextureTick = 0;
|
public static long LastTextureTick = 0;
|
||||||
|
|
||||||
public ModelBase originalModel;
|
public ModelBase originalModel;
|
||||||
|
|
||||||
public RenderNPCInterface(ModelBase model, float f){
|
public RenderNPCInterface(ModelBase model, float f){
|
||||||
super(model, f);
|
super(model, f);
|
||||||
this.originalModel = model;
|
this.originalModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) {
|
protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) {
|
||||||
if (!this.func_110813_b(npc))
|
if (!this.func_110813_b(npc))
|
||||||
return;
|
return;
|
||||||
float f2 = npc.getDistanceToEntity(renderManager.livingPlayer);
|
float f2 = npc.getDistanceToEntity(renderManager.livingPlayer);
|
||||||
float f3 = npc.isSneaking() ? 32F : 64F;
|
float f3 = npc.isSneaking() ? 32F : 64F;
|
||||||
|
|
||||||
if (f2 > f3)
|
if (f2 > f3)
|
||||||
return;
|
return;
|
||||||
if (npc.messages != null){
|
if (npc.messages != null){
|
||||||
@@ -69,199 +69,201 @@ public class RenderNPCInterface extends RenderLiving{
|
|||||||
height = 1;
|
height = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
|
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
|
|
||||||
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
|
|
||||||
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
|
|
||||||
FontRenderer fontrenderer = getFontRendererFromRenderManager();
|
|
||||||
|
|
||||||
i = npc.getBrightnessForRender(0);
|
|
||||||
int j = i % 65536;
|
|
||||||
int k = i / 65536;
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
|
|
||||||
|
|
||||||
float f1 = (npc.baseHeight / 5f) * npc.display.modelSize;
|
|
||||||
float f2 = 0.01666667F * f1;
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
|
|
||||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
float height = f1 / 6.5f;
|
|
||||||
for(j = 0; j < obs.length; j += 2){
|
|
||||||
float scale = (Float) obs[j + 1];
|
|
||||||
height += f1 / 6.5f * scale;
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
||||||
String s = obs[j].toString();
|
|
||||||
GL11.glTranslatef(0, height, 0);
|
|
||||||
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
int size = fontrenderer.getStringWidth(s) / 2;
|
|
||||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
|
||||||
tessellator.addVertex(-size - 1, -1, 0.0D);
|
|
||||||
tessellator.addVertex(-size - 1, 8 , 0.0D);
|
|
||||||
tessellator.addVertex(size + 1, 8 , 0.0D);
|
|
||||||
tessellator.addVertex(size + 1, -1 , 0.0D);
|
|
||||||
tessellator.draw();
|
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
int color = npc.faction.color;
|
|
||||||
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
|
|
||||||
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderPlayerScale(EntityNPCInterface npc, float f){
|
|
||||||
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
|
|
||||||
shadowSize = npc.display.modelSize / 10f;
|
|
||||||
|
|
||||||
float xOffset = 0;
|
|
||||||
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
|
|
||||||
float zOffset = 0;
|
|
||||||
|
|
||||||
if(npc.isEntityAlive()){
|
|
||||||
if(npc.isPlayerSleeping()){
|
|
||||||
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
|
|
||||||
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
|
|
||||||
yOffset += 0.14f;
|
|
||||||
}
|
|
||||||
else if(npc.isRiding()){
|
|
||||||
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
|
|
||||||
}
|
|
||||||
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
|
|
||||||
xoffset = (xoffset/ 5f) * npc.display.modelSize;
|
|
||||||
yoffset = (yoffset/ 5f) * npc.display.modelSize;
|
|
||||||
zoffset = (zoffset/ 5f) * npc.display.modelSize;
|
|
||||||
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
|
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
|
||||||
if(npc.isEntityAlive() && npc.isPlayerSleeping())
|
|
||||||
{
|
|
||||||
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
|
|
||||||
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
|
||||||
}
|
|
||||||
else if(npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING){
|
|
||||||
GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F);
|
|
||||||
float scale = ((EntityCustomNpc)npc).display.modelSize / 5f;
|
|
||||||
GL11.glTranslated(-scale +((EntityCustomNpc)npc).modelData.getLegsY() * scale, 0.14f, 0);
|
|
||||||
GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F);
|
|
||||||
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
super.rotateCorpse(npc, f, f1, f2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
|
|
||||||
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void preRenderCallback(EntityLivingBase entityliving, float f){
|
|
||||||
renderPlayerScale((EntityNPCInterface)entityliving, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
|
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
|
||||||
|
|
||||||
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
|
|
||||||
BossStatus.setBossStatus(npc, true);
|
|
||||||
|
|
||||||
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
|
|
||||||
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
|
|
||||||
}
|
|
||||||
super.doRender(entityliving, d, d1, d2, f, f1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){
|
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
|
||||||
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
|
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
|
||||||
if (!npc.display.glowTexture.isEmpty())
|
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
|
||||||
{
|
}
|
||||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
|
||||||
if(npc.textureGlowLocation == null){
|
|
||||||
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
|
|
||||||
}
|
|
||||||
bindTexture((ResourceLocation) npc.textureGlowLocation);
|
|
||||||
float f1 = 1.0F;
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
if (npc.isInvisible())
|
|
||||||
{
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
}
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glScalef(1.001f, 1.001f, 1.001f);
|
|
||||||
if(mainModel instanceof ModelMPM){
|
|
||||||
((ModelMPM)mainModel).isArmor = true;
|
|
||||||
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
|
|
||||||
((ModelMPM)mainModel).isArmor = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
|
|
||||||
|
|
||||||
|
|
||||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
FontRenderer fontrenderer = getFontRendererFromRenderManager();
|
||||||
}
|
|
||||||
}
|
i = npc.getBrightnessForRender(0);
|
||||||
@Override
|
int j = i % 65536;
|
||||||
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
|
int k = i / 65536;
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
|
||||||
if(npc.isKilled() || npc.display.disableLivingAnimation)
|
|
||||||
return 0;
|
float f1 = (npc.baseHeight / 5f) * npc.display.modelSize;
|
||||||
return super.handleRotationFloat(par1EntityLiving, par2);
|
float f2 = 0.01666667F * f1;
|
||||||
}
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
|
||||||
|
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
float height = f1 / 6.5f;
|
||||||
|
for(j = 0; j < obs.length; j += 2){
|
||||||
|
float scale = (Float) obs[j + 1];
|
||||||
|
height += f1 / 6.5f * scale;
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
String s = obs[j].toString();
|
||||||
|
GL11.glTranslatef(0, height, 0);
|
||||||
|
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
int size = fontrenderer.getStringWidth(s) / 2;
|
||||||
|
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
||||||
|
tessellator.addVertex(-size - 1, -1, 0.0D);
|
||||||
|
tessellator.addVertex(-size - 1, 8 , 0.0D);
|
||||||
|
tessellator.addVertex(size + 1, 8 , 0.0D);
|
||||||
|
tessellator.addVertex(size + 1, -1 , 0.0D);
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
int color = npc.faction.color;
|
||||||
|
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderPlayerScale(EntityNPCInterface npc, float f){
|
||||||
|
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
|
||||||
|
shadowSize = npc.display.modelSize / 10f;
|
||||||
|
|
||||||
|
float xOffset = 0;
|
||||||
|
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
|
||||||
|
float zOffset = 0;
|
||||||
|
|
||||||
|
if(npc.isEntityAlive()){
|
||||||
|
if(npc.isPlayerSleeping()){
|
||||||
|
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
|
||||||
|
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
|
||||||
|
yOffset += 0.14f;
|
||||||
|
}
|
||||||
|
else if(npc.isRiding()){
|
||||||
|
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
|
||||||
|
}
|
||||||
|
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
|
||||||
|
xoffset = (xoffset/ 5f) * npc.display.modelSize;
|
||||||
|
yoffset = (yoffset/ 5f) * npc.display.modelSize;
|
||||||
|
zoffset = (zoffset/ 5f) * npc.display.modelSize;
|
||||||
|
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
|
||||||
|
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||||
|
if(npc.isEntityAlive() && npc.isPlayerSleeping())
|
||||||
|
{
|
||||||
|
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
|
||||||
|
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
||||||
|
}
|
||||||
|
else if(npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING){
|
||||||
|
GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F);
|
||||||
|
float scale = ((EntityCustomNpc)npc).display.modelSize / 5f;
|
||||||
|
GL11.glTranslated(-scale +((EntityCustomNpc)npc).modelData.getLegsY() * scale, 0.14f, 0);
|
||||||
|
GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F);
|
||||||
|
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
super.rotateCorpse(npc, f, f1, f2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
|
||||||
|
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRenderCallback(EntityLivingBase entityliving, float f){
|
||||||
|
renderPlayerScale((EntityNPCInterface)entityliving, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
|
||||||
|
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
||||||
|
|
||||||
|
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
|
||||||
|
BossStatus.setBossStatus(npc, true);
|
||||||
|
|
||||||
|
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
|
||||||
|
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
|
||||||
|
}
|
||||||
|
super.doRender(entityliving, d, d1, d2, f, f1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){
|
||||||
|
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
|
||||||
|
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
|
||||||
|
if (!npc.display.glowTexture.isEmpty())
|
||||||
|
{
|
||||||
|
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||||
|
if(npc.textureGlowLocation == null){
|
||||||
|
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
|
||||||
|
}
|
||||||
|
bindTexture((ResourceLocation) npc.textureGlowLocation);
|
||||||
|
float f1 = 1.0F;
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
// Overlay & Glow
|
||||||
|
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
|
if (npc.isInvisible())
|
||||||
|
{
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
}
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glScalef(1.001f, 1.001f, 1.001f);
|
||||||
|
if(mainModel instanceof ModelMPM){
|
||||||
|
((ModelMPM)mainModel).isArmor = true;
|
||||||
|
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
|
||||||
|
((ModelMPM)mainModel).isArmor = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
|
||||||
|
|
||||||
|
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
|
||||||
|
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;
|
||||||
|
if(npc.isKilled() || npc.display.disableLivingAnimation)
|
||||||
|
return 0;
|
||||||
|
return super.handleRotationFloat(par1EntityLiving, par2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
|
||||||
|
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
|
|
||||||
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getEntityTexture(Entity entity) {
|
public ResourceLocation getEntityTexture(Entity entity) {
|
||||||
|
|
||||||
@@ -276,11 +278,11 @@ public class RenderNPCInterface extends RenderLiving{
|
|||||||
return AbstractClientPlayer.locationStevePng;
|
return AbstractClientPlayer.locationStevePng;
|
||||||
}
|
}
|
||||||
else if(npc.display.skinType == 1 && npc.display.playerProfile != null){
|
else if(npc.display.skinType == 1 && npc.display.playerProfile != null){
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
|
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
|
||||||
if (map.containsKey(Type.SKIN)){
|
if (map.containsKey(Type.SKIN)){
|
||||||
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
|
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
|
||||||
}
|
}
|
||||||
LastTextureTick = 0;
|
LastTextureTick = 0;
|
||||||
}
|
}
|
||||||
else if(npc.display.skinType == 2 || npc.display.skinType == 3){
|
else if(npc.display.skinType == 2 || npc.display.skinType == 3){
|
||||||
@@ -291,7 +293,6 @@ public class RenderNPCInterface extends RenderLiving{
|
|||||||
for(byte b : hash){
|
for(byte b : hash){
|
||||||
sb.append(String.format("%02x", b&0xff));
|
sb.append(String.format("%02x", b&0xff));
|
||||||
}
|
}
|
||||||
// SKIN CHANGE
|
|
||||||
if(npc.display.skinType == 2){
|
if(npc.display.skinType == 2){
|
||||||
npc.textureLocation = new ResourceLocation("skins/" + sb.toString());
|
npc.textureLocation = new ResourceLocation("skins/" + sb.toString());
|
||||||
loadSkin(null, npc.textureLocation, npc.display.url, false);
|
loadSkin(null, npc.textureLocation, npc.display.url, false);
|
||||||
@@ -313,10 +314,10 @@ public class RenderNPCInterface extends RenderLiving{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 64x64 Skin is True
|
// 64x64 Skin is True
|
||||||
private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){
|
private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){
|
||||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||||
ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version));
|
ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version));
|
||||||
texturemanager.loadTexture(resource, object);
|
texturemanager.loadTexture(resource, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,6 @@ public class RenderNPCPony extends RenderNPCInterface
|
|||||||
float f4 = 0.375F * f;
|
float f4 = 0.375F * f;
|
||||||
GL11.glScalef(f4, -f4, f4);
|
GL11.glScalef(f4, -f4, f4);
|
||||||
} else
|
} else
|
||||||
// CHANGE HERE
|
|
||||||
if(itemstack.getItem() instanceof ItemBow)
|
if(itemstack.getItem() instanceof ItemBow)
|
||||||
{
|
{
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,9 @@ public enum EnumPacketServer {
|
|||||||
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
ScriptForgeGet(false),
|
ScriptForgeGet(false),
|
||||||
|
|
||||||
|
ScriptNPCSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
|
ScriptNPCGet(false),
|
||||||
|
|
||||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||||
|
|||||||
@@ -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,14 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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 +99,8 @@ 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);
|
||||||
|
|
||||||
if(sound != null && !sound.isEmpty())
|
if(sound != null && !sound.isEmpty())
|
||||||
compound.setString("DialogSound", sound);
|
compound.setString("DialogSound", sound);
|
||||||
@@ -224,4 +232,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,11 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.constants.EnumRoleType;
|
import noppes.npcs.constants.EnumRoleType;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.entity.data.DataTimers;
|
import noppes.npcs.entity.data.DataTimers;
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import noppes.npcs.CustomNpcs;
|
|||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
public class PlayerDataController {
|
public class PlayerDataController {
|
||||||
public static PlayerDataController instance;
|
public static PlayerDataController instance;
|
||||||
|
|
||||||
public PlayerDataController(){
|
public PlayerDataController(){
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
@@ -42,24 +42,24 @@ public class PlayerDataController {
|
|||||||
filename = "noplayername";
|
filename = "noplayername";
|
||||||
filename += ".dat";
|
filename += ".dat";
|
||||||
try {
|
try {
|
||||||
File file = new File(saveDir, filename);
|
File file = new File(saveDir, filename);
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||||
file.delete();
|
file.delete();
|
||||||
file = new File(saveDir, filename+"_old");
|
file = new File(saveDir, filename+"_old");
|
||||||
if(file.exists())
|
if(file.exists())
|
||||||
file.delete();
|
file.delete();
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
File file = new File(saveDir, filename+"_old");
|
File file = new File(saveDir, filename+"_old");
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
@@ -74,34 +74,34 @@ public class PlayerDataController {
|
|||||||
filename = "noplayername";
|
filename = "noplayername";
|
||||||
filename += ".json";
|
filename += ".json";
|
||||||
try {
|
try {
|
||||||
File file = new File(saveDir, filename);
|
File file = new File(saveDir, filename);
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
return NBTJsonUtil.LoadFile(file);
|
return NBTJsonUtil.LoadFile(file);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.error("Error loading: " + filename, e);
|
LogWriter.error("Error loading: " + filename, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NBTTagCompound();
|
return new NBTTagCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savePlayerData(PlayerData data){
|
public void savePlayerData(PlayerData data){
|
||||||
NBTTagCompound compound = data.getNBT();
|
NBTTagCompound compound = data.getNBT();
|
||||||
String filename = data.uuid + ".json";
|
String filename = data.uuid + ".json";
|
||||||
try {
|
try {
|
||||||
File saveDir = getSaveDir();
|
File saveDir = getSaveDir();
|
||||||
File file = new File(saveDir, filename+"_new");
|
File file = new File(saveDir, filename+"_new");
|
||||||
File file1 = new File(saveDir, filename);
|
File file1 = new File(saveDir, filename);
|
||||||
NBTJsonUtil.SaveFile(file, compound);
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
if(file1.exists()){
|
if(file1.exists()){
|
||||||
file1.delete();
|
file1.delete();
|
||||||
}
|
}
|
||||||
file.renameTo(file1);
|
file.renameTo(file1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
|
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
|
||||||
Bank bank = BankController.getInstance().getBank(bankId);
|
Bank bank = BankController.getInstance().getBank(bankId);
|
||||||
PlayerBankData data = getPlayerData(player).bankData;
|
PlayerBankData data = getPlayerData(player).bankData;
|
||||||
@@ -110,7 +110,7 @@ public class PlayerDataController {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerData getPlayerData(EntityPlayer player){
|
public PlayerData getPlayerData(EntityPlayer player){
|
||||||
PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData");
|
PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData");
|
||||||
if(data == null){
|
if(data == null){
|
||||||
@@ -122,14 +122,14 @@ public class PlayerDataController {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
public String hasPlayer(String username) {
|
public String hasPlayer(String username) {
|
||||||
for(String name : getUsernameData().keySet()){
|
for(String name : getUsernameData().keySet()){
|
||||||
if(name.equalsIgnoreCase(username))
|
if(name.equalsIgnoreCase(username))
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerData getDataFromUsername(String username){
|
public PlayerData getDataFromUsername(String username){
|
||||||
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
||||||
PlayerData data = null;
|
PlayerData data = null;
|
||||||
@@ -145,37 +145,37 @@ public class PlayerDataController {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
data = getPlayerData(player);
|
data = getPlayerData(player);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerMessage(String username, PlayerMail mail) {
|
public void addPlayerMessage(String username, PlayerMail mail) {
|
||||||
mail.time = System.currentTimeMillis();
|
mail.time = System.currentTimeMillis();
|
||||||
|
|
||||||
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
||||||
PlayerData data = getDataFromUsername(username);
|
PlayerData data = getDataFromUsername(username);
|
||||||
data.mailData.playermail.add(mail.copy());
|
data.mailData.playermail.add(mail.copy());
|
||||||
savePlayerData(data);
|
savePlayerData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, NBTTagCompound> getUsernameData(){
|
public Map<String, NBTTagCompound> getUsernameData(){
|
||||||
Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>();
|
Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>();
|
||||||
for(File file : getSaveDir().listFiles()){
|
for(File file : getSaveDir().listFiles()){
|
||||||
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
if(compound.hasKey("PlayerName")){
|
if(compound.hasKey("PlayerName")){
|
||||||
map.put(compound.getString("PlayerName"), compound);
|
map.put(compound.getString("PlayerName"), compound);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMail(EntityPlayer player) {
|
public boolean hasMail(EntityPlayer player) {
|
||||||
return getPlayerData(player).mailData.hasMail();
|
return getPlayerData(player).mailData.hasMail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -110,10 +110,16 @@ public class ScriptContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run(EnumScriptType type, Event event) {
|
public void run(EnumScriptType type, Event event) {
|
||||||
|
if(!CustomNpcs.ScriptingEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
this.run((String)type.function, (Object)event);
|
this.run((String)type.function, (Object)event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String type, Object event) {
|
public void run(String type, Object event) {
|
||||||
|
if(!CustomNpcs.ScriptingEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
||||||
this.setEngine(this.handler.getLanguage());
|
this.setEngine(this.handler.getLanguage());
|
||||||
if (this.engine != null) {
|
if (this.engine != null) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
|||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
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.entity.*;
|
import noppes.npcs.scripted.entity.*;
|
||||||
@@ -56,6 +57,8 @@ public class ScriptController {
|
|||||||
|
|
||||||
public ForgeDataScript forgeScripts = new ForgeDataScript();
|
public ForgeDataScript forgeScripts = new ForgeDataScript();
|
||||||
|
|
||||||
|
public NPCDataScript npcScripts = new NPCDataScript((EntityNPCInterface) null);
|
||||||
|
|
||||||
public ScriptController(){
|
public ScriptController(){
|
||||||
loaded = false;
|
loaded = false;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@@ -111,6 +114,10 @@ public class ScriptController {
|
|||||||
return new File(dir, "player_scripts.json");
|
return new File(dir, "player_scripts.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File npcScriptsFile() {
|
||||||
|
return new File(dir, "npc_scripts.json");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean loadPlayerScripts() {
|
public boolean loadPlayerScripts() {
|
||||||
this.playerScripts.clear();
|
this.playerScripts.clear();
|
||||||
File file = this.playerScriptsFile();
|
File file = this.playerScriptsFile();
|
||||||
@@ -143,6 +150,37 @@ public class ScriptController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean loadNPCScripts() {
|
||||||
|
this.npcScripts.clear();
|
||||||
|
File file = this.npcScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(!file.exists()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.npcScripts.readFromNBT(NBTJsonUtil.LoadFile(file));
|
||||||
|
shouldSave = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception var3) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), var3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNPCScripts(NBTTagCompound compound) {
|
||||||
|
this.npcScripts.readFromNBT(compound);
|
||||||
|
File file = this.npcScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
|
} catch (IOException var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
} catch (JsonException var5) {
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadCategories(){
|
private void loadCategories(){
|
||||||
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class ServerCloneController implements ICloneHandler {
|
|||||||
try {
|
try {
|
||||||
File dir = new File(getDir(), "..");
|
File dir = new File(getDir(), "..");
|
||||||
File file = new File(dir, "clonednpcs.dat");
|
File file = new File(dir, "clonednpcs.dat");
|
||||||
System.out.println(file.getAbsolutePath());
|
// System.out.println(file.getAbsolutePath());
|
||||||
System.out.println(file.exists());
|
// System.out.println(file.exists());
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file);
|
Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file);
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.EventHooks;
|
import noppes.npcs.EventHooks;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
@@ -84,7 +85,7 @@ public class ForgeDataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getEnabled() {
|
public boolean getEnabled() {
|
||||||
return this.enabled;
|
return CustomNpcs.GlobalForgeScripts && this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean bo) {
|
public void setEnabled(boolean bo) {
|
||||||
|
|||||||
@@ -0,0 +1,297 @@
|
|||||||
|
package noppes.npcs.controllers.data;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.NBTTags;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class NPCDataScript implements IScriptHandler {
|
||||||
|
public List<ScriptContainer> scripts = new ArrayList();
|
||||||
|
public String scriptLanguage = "ECMAScript";
|
||||||
|
private EntityNPCInterface npc;
|
||||||
|
private ICustomNpc npcAPI;
|
||||||
|
public long lastInited = -1L;
|
||||||
|
public boolean enabled = false;
|
||||||
|
private Map<Long, String> console = new TreeMap();
|
||||||
|
public List<Integer> errored = new ArrayList();
|
||||||
|
|
||||||
|
public NPCDataScript(EntityNPCInterface npc) {
|
||||||
|
if(npc != null) {
|
||||||
|
this.npc = npc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void clear() {
|
||||||
|
this.console = new TreeMap();
|
||||||
|
this.errored = new ArrayList();
|
||||||
|
this.scripts = new ArrayList();
|
||||||
|
}
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
|
||||||
|
this.scriptLanguage = compound.getString("ScriptLanguage");
|
||||||
|
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||||
|
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
|
||||||
|
}
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||||
|
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
|
||||||
|
compound.setString("ScriptLanguage", this.scriptLanguage);
|
||||||
|
compound.setBoolean("ScriptEnabled", this.enabled);
|
||||||
|
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(EnumScriptType type, Event event) {
|
||||||
|
if (this.isEnabled()) {
|
||||||
|
ScriptContainer script;
|
||||||
|
if (ScriptController.Instance.lastLoaded > this.lastInited) {
|
||||||
|
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||||
|
errored.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < ScriptController.Instance.npcScripts.scripts.size(); ++i) {
|
||||||
|
script = (ScriptContainer)ScriptController.Instance.npcScripts.scripts.get(i);
|
||||||
|
if (!errored.contains(i)) {
|
||||||
|
if(script == null || script.errored || !script.hasCode() || ScriptController.Instance.npcScripts.errored.contains(i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
script.run(type, event);
|
||||||
|
|
||||||
|
if (script.errored) {
|
||||||
|
ScriptController.Instance.npcScripts.errored.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var8 = script.console.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var8.hasNext()) {
|
||||||
|
Map.Entry<Long, String> entry = (Map.Entry)var8.next();
|
||||||
|
if (!ScriptController.Instance.npcScripts.console.containsKey(entry.getKey())) {
|
||||||
|
ScriptController.Instance.npcScripts.console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + (String)entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
script.console.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return CustomNpcs.GlobalNPCScripts && ScriptController.Instance.npcScripts.enabled && ScriptController.HasStart && (this.npc == null || !this.npc.worldObj.isRemote);
|
||||||
|
}
|
||||||
|
public boolean isClient() {
|
||||||
|
return this.npc.isClientWorld();
|
||||||
|
}
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return ScriptController.Instance.npcScripts.enabled;
|
||||||
|
}
|
||||||
|
public void setEnabled(boolean bo) {
|
||||||
|
ScriptController.Instance.npcScripts.enabled = bo;
|
||||||
|
this.enabled = bo;
|
||||||
|
}
|
||||||
|
public String getLanguage() {
|
||||||
|
return ScriptController.Instance.npcScripts.scriptLanguage;
|
||||||
|
}
|
||||||
|
public void setLanguage(String lang) {
|
||||||
|
this.scriptLanguage = lang;
|
||||||
|
}
|
||||||
|
public List<ScriptContainer> getScripts() {
|
||||||
|
return this.scripts;
|
||||||
|
}
|
||||||
|
public String noticeString() {
|
||||||
|
if(this.npc == null) {
|
||||||
|
return "Global script";
|
||||||
|
} else {
|
||||||
|
BlockPos pos = new BlockPos(this.npc);
|
||||||
|
return NPCDataScript.toStringHelper(this.npc).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ICustomNpc getNpc() {
|
||||||
|
if (this.npcAPI == null) {
|
||||||
|
this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc);
|
||||||
|
}
|
||||||
|
return this.npcAPI;
|
||||||
|
}
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
return this.console;
|
||||||
|
}
|
||||||
|
public void clearConsole() {
|
||||||
|
this.console.clear();
|
||||||
|
}
|
||||||
|
public static final class ToStringHelper {
|
||||||
|
private final String className;
|
||||||
|
private final NPCDataScript.ToStringHelper.ValueHolder holderHead;
|
||||||
|
private NPCDataScript.ToStringHelper.ValueHolder holderTail;
|
||||||
|
private boolean omitNullValues;
|
||||||
|
private boolean omitEmptyValues;
|
||||||
|
private ToStringHelper(String className) {
|
||||||
|
this.holderHead = new NPCDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderHead;
|
||||||
|
this.omitNullValues = false;
|
||||||
|
this.omitEmptyValues = false;
|
||||||
|
this.className = (String) Preconditions.checkNotNull(className);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper omitNullValues() {
|
||||||
|
this.omitNullValues = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
|
||||||
|
return this.addHolder(name, value);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, boolean value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, char value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, double value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, float value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, int value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, long value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(@CheckForNull Object value) {
|
||||||
|
return this.addHolder(value);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(boolean value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(char value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(double value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(float value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(int value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(long value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
private static boolean isEmpty(Object value) {
|
||||||
|
if (value instanceof CharSequence) {
|
||||||
|
return ((CharSequence)value).length() == 0;
|
||||||
|
} else if (value instanceof Collection) {
|
||||||
|
return ((Collection)value).isEmpty();
|
||||||
|
} else if (value instanceof Map) {
|
||||||
|
return ((Map)value).isEmpty();
|
||||||
|
} else if (value instanceof Optional) {
|
||||||
|
return !((Optional)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalInt) {
|
||||||
|
return !((OptionalInt)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalLong) {
|
||||||
|
return !((OptionalLong)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalDouble) {
|
||||||
|
return !((OptionalDouble)value).isPresent();
|
||||||
|
} else if (value instanceof com.google.common.base.Optional) {
|
||||||
|
return !((com.google.common.base.Optional)value).isPresent();
|
||||||
|
} else if (value.getClass().isArray()) {
|
||||||
|
return Array.getLength(value) == 0;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
boolean omitNullValuesSnapshot = this.omitNullValues;
|
||||||
|
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
|
||||||
|
String nextSeparator = "";
|
||||||
|
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
|
||||||
|
for(NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
|
||||||
|
Object value = valueHolder.value;
|
||||||
|
if (!(valueHolder instanceof NPCDataScript.ToStringHelper.UnconditionalValueHolder)) {
|
||||||
|
if (value == null) {
|
||||||
|
if (omitNullValuesSnapshot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (omitEmptyValuesSnapshot && isEmpty(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.append(nextSeparator);
|
||||||
|
nextSeparator = ", ";
|
||||||
|
if (valueHolder.name != null) {
|
||||||
|
builder.append(valueHolder.name).append('=');
|
||||||
|
}
|
||||||
|
if (value != null && value.getClass().isArray()) {
|
||||||
|
Object[] objectArray = new Object[]{value};
|
||||||
|
String arrayString = Arrays.deepToString(objectArray);
|
||||||
|
builder.append(arrayString, 1, arrayString.length() - 1);
|
||||||
|
} else {
|
||||||
|
builder.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.append('}').toString();
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper.ValueHolder addHolder() {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = new NPCDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new NPCDataScript.ToStringHelper.UnconditionalValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addUnconditionalHolder(Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private static final class UnconditionalValueHolder extends NPCDataScript.ToStringHelper.ValueHolder {
|
||||||
|
private UnconditionalValueHolder() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class ValueHolder {
|
||||||
|
@CheckForNull
|
||||||
|
String name;
|
||||||
|
@CheckForNull
|
||||||
|
Object value;
|
||||||
|
@CheckForNull
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder next;
|
||||||
|
private ValueHolder() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static NPCDataScript.ToStringHelper toStringHelper(Object self) {
|
||||||
|
return new NPCDataScript.ToStringHelper(self.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.EventHooks;
|
import noppes.npcs.EventHooks;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
@@ -106,7 +107,7 @@ public class PlayerDataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
return CustomNpcs.GlobalPlayerScripts && ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
||||||
}
|
}
|
||||||
public boolean isClient() {
|
public boolean isClient() {
|
||||||
return this.player.isClientWorld();
|
return this.player.isClientWorld();
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ import noppes.npcs.ModelData;
|
|||||||
import noppes.npcs.ModelPartData;
|
import noppes.npcs.ModelPartData;
|
||||||
import noppes.npcs.client.EntityUtil;
|
import noppes.npcs.client.EntityUtil;
|
||||||
|
|
||||||
// FLY CHANGE
|
|
||||||
// extends EntityNPCInterface
|
|
||||||
// extends EntityNPCFlying
|
|
||||||
public class EntityCustomNpc extends EntityNPCFlying {
|
public class EntityCustomNpc extends EntityNPCFlying {
|
||||||
public ModelData modelData = new ModelData();
|
public ModelData modelData = new ModelData();
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package noppes.npcs.entity;
|
package noppes.npcs.entity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
|
||||||
import net.minecraft.entity.ai.EntityAISwimming;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||||
@@ -30,17 +26,21 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
super.updateFallState(p_180433_1_, p_180433_3_);
|
super.updateFallState(p_180433_1_, p_180433_3_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLivingUpdate()
|
@Override
|
||||||
|
public boolean isOnLadder(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
|
||||||
{
|
{
|
||||||
super.onLivingUpdate();
|
if(!this.canFly() || this.hurtTime != 0) {
|
||||||
if(!canFly()){
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockY = (int) this.posY;
|
|
||||||
double heightOffGround = 0;
|
double heightOffGround = 0;
|
||||||
if(this.ai.hasFlyLimit) {
|
if(this.ai.hasFlyLimit) {
|
||||||
for (blockY = (int) this.posY; blockY > 0; blockY--) {
|
for (int blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||||
heightOffGround = this.posY - blockY;
|
heightOffGround = this.posY - blockY;
|
||||||
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
|
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
|
||||||
break;
|
break;
|
||||||
@@ -48,24 +48,19 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0)
|
if(heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit){
|
||||||
{
|
super.moveEntityWithHeading(p_70612_1_,p_70612_2_);
|
||||||
if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){
|
return;
|
||||||
this.motionY *= 0.8D;
|
|
||||||
this.velocityChanged = true;
|
|
||||||
} else {
|
|
||||||
this.motionY *= this.ai.flyGravity;
|
|
||||||
this.velocityChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double d3 = this.motionY;
|
||||||
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||||
|
this.motionY = d3;
|
||||||
|
|
||||||
|
this.fallDistance = 0.0F;
|
||||||
|
this.velocityChanged = true;
|
||||||
|
|
||||||
|
if(this.getNavigator().noPath())
|
||||||
|
this.motionY = 0.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnLadder(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,20 +40,7 @@ import net.minecraft.world.WorldServer;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.ServerChatEvent;
|
import net.minecraftforge.event.ServerChatEvent;
|
||||||
import noppes.npcs.CustomItems;
|
import noppes.npcs.*;
|
||||||
import noppes.npcs.CustomNpcs;
|
|
||||||
import noppes.npcs.DataAI;
|
|
||||||
import noppes.npcs.DataAdvanced;
|
|
||||||
import noppes.npcs.DataDisplay;
|
|
||||||
import noppes.npcs.DataInventory;
|
|
||||||
import noppes.npcs.DataScript;
|
|
||||||
import noppes.npcs.DataStats;
|
|
||||||
import noppes.npcs.IChatMessages;
|
|
||||||
import noppes.npcs.NBTTags;
|
|
||||||
import noppes.npcs.NoppesUtilServer;
|
|
||||||
import noppes.npcs.NpcDamageSource;
|
|
||||||
import noppes.npcs.Server;
|
|
||||||
import noppes.npcs.VersionCompatibility;
|
|
||||||
import noppes.npcs.ai.*;
|
import noppes.npcs.ai.*;
|
||||||
import noppes.npcs.ai.EntityAIMoveIndoors;
|
import noppes.npcs.ai.EntityAIMoveIndoors;
|
||||||
import noppes.npcs.ai.EntityAIPanic;
|
import noppes.npcs.ai.EntityAIPanic;
|
||||||
@@ -153,7 +140,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
public boolean updateClient = false;
|
public boolean updateClient = false;
|
||||||
public boolean updateAI = false;
|
public boolean updateAI = false;
|
||||||
|
|
||||||
// Fly Change
|
|
||||||
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
||||||
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
||||||
|
|
||||||
@@ -233,8 +219,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
@Override
|
@Override
|
||||||
public void onUpdate(){
|
public void onUpdate(){
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
if(this.ticksExisted % 10 == 0)
|
if(this.ticksExisted % 10 == 0) {
|
||||||
script.callScript(EnumScriptType.TICK);
|
EventHooks.onNPCUpdate(this);
|
||||||
|
}
|
||||||
this.timers.update();
|
this.timers.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,6 +230,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
script.setWorld(world);
|
script.setWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxSafePointTries()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attackEntityAsMob(Entity par1Entity){
|
public boolean attackEntityAsMob(Entity par1Entity){
|
||||||
float f = stats.getAttackStrength();
|
float f = stats.getAttackStrength();
|
||||||
@@ -252,7 +244,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
if(par1Entity instanceof EntityLivingBase){
|
if(par1Entity instanceof EntityLivingBase){
|
||||||
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
|
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
|
||||||
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", par1Entity))
|
if(EventHooks.onNPCMeleeAttack(this, f, (EntityLivingBase)par1Entity))
|
||||||
return false;
|
return false;
|
||||||
f = event.getDamage();
|
f = event.getDamage();
|
||||||
}
|
}
|
||||||
@@ -393,8 +385,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(script.callScript(EnumScriptType.INTERACT, "player", player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player))
|
if(EventHooks.onNPCInteract(this, player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
addInteract(player);
|
addInteract(player);
|
||||||
@@ -406,7 +398,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
else if (dialog != null){
|
else if (dialog != null){
|
||||||
NoppesUtilServer.openDialog(player, this, dialog);
|
NoppesUtilServer.openDialog(player, this, dialog, 0);
|
||||||
}
|
}
|
||||||
else if(roleInterface != null)
|
else if(roleInterface != null)
|
||||||
roleInterface.interact(player);
|
roleInterface.interact(player);
|
||||||
@@ -434,7 +426,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 +468,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);
|
||||||
@@ -506,7 +502,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
|
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
|
||||||
return false;
|
return false;
|
||||||
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
|
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
|
||||||
if(script.callScript(EnumScriptType.DAMAGED, "event", result) || isKilled())
|
if(EventHooks.onNPCDamaged(this, attackingEntity, i, damagesource, result) || isKilled())
|
||||||
return false;
|
return false;
|
||||||
i = result.getDamage();
|
i = result.getDamage();
|
||||||
|
|
||||||
@@ -556,7 +552,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return;
|
return;
|
||||||
if(getAttackTarget() != entity && entity != null){
|
if(getAttackTarget() != entity && entity != null){
|
||||||
ScriptEventTarget event = new ScriptEventTarget(entity);
|
ScriptEventTarget event = new ScriptEventTarget(entity);
|
||||||
if(script.callScript(EnumScriptType.TARGET, "event", event))
|
if(EventHooks.onNPCTarget(this,entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(event.getTarget() == null)
|
if(event.getTarget() == null)
|
||||||
@@ -581,7 +577,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
|
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
|
||||||
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", entity))
|
if(EventHooks.onNPCRangedAttack(this, f, (EntityLivingBase)entity))
|
||||||
return;
|
return;
|
||||||
for(int i = 0; i < this.stats.shotCount; i++)
|
for(int i = 0; i < this.stats.shotCount; i++)
|
||||||
{
|
{
|
||||||
@@ -910,7 +906,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saySurrounding(Line line) {
|
public void saySurrounding(Line line) {
|
||||||
if (line == null || line.text == null)
|
if (line == null || line.text == null || getFakePlayer() == null)
|
||||||
return;
|
return;
|
||||||
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
|
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
|
||||||
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
|
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
|
||||||
@@ -1063,8 +1059,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
if(jobInterface != null)
|
if(jobInterface != null)
|
||||||
jobInterface.reset();
|
jobInterface.reset();
|
||||||
|
|
||||||
script.callScript(EnumScriptType.INIT);
|
EventHooks.onNPCInit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCollide() {
|
public void onCollide() {
|
||||||
@@ -1086,8 +1082,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i){
|
for (int i = 0; i < list.size(); ++i){
|
||||||
Entity entity = (Entity)list.get(i);
|
Entity entity = (Entity)list.get(i);
|
||||||
if (entity.isEntityAlive())
|
if (entity.isEntityAlive()) {
|
||||||
script.callScript(EnumScriptType.COLLIDE, "entity", entity);
|
EventHooks.onNPCCollide(this,entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1214,7 +1211,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
attackingEntity = ((EntityThrowable) entity).getThrower();
|
attackingEntity = ((EntityThrowable) entity).getThrower();
|
||||||
|
|
||||||
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
|
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
|
||||||
if(script.callScript(EnumScriptType.KILLED, "event", result))
|
if(EventHooks.onNPCKilled(this,damagesource,attackingEntity,result))
|
||||||
return;
|
return;
|
||||||
if(!isRemote()){
|
if(!isRemote()){
|
||||||
if(this.recentlyHit > 0)
|
if(this.recentlyHit > 0)
|
||||||
@@ -1289,7 +1286,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIcon getItemIcon(ItemStack par1ItemStack, int par2){
|
public IIcon getItemIcon(ItemStack par1ItemStack, int par2){
|
||||||
// Change Here
|
|
||||||
if (par1ItemStack.getItem() instanceof ItemBow){
|
if (par1ItemStack.getItem() instanceof ItemBow){
|
||||||
return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
|
return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
|
||||||
}
|
}
|
||||||
@@ -1808,4 +1804,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
{
|
{
|
||||||
this.display.modelType = val;
|
this.display.modelType = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateLeashedState(){}
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,42 @@ public class DataTimers implements ITimers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ticks(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTicks(int id, int ticks){
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||||
|
if(ticks < 0)
|
||||||
|
ticks = 0;
|
||||||
|
if(ticks > timer.timerTicks)
|
||||||
|
ticks = timer.timerTicks;
|
||||||
|
|
||||||
|
timer.ticks = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int maxTicks(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).timerTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxTicks(int id, int maxTicks){
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||||
|
if(maxTicks < 0)
|
||||||
|
maxTicks = 0;
|
||||||
|
if(timer.ticks > maxTicks)
|
||||||
|
timer.ticks = maxTicks;
|
||||||
|
|
||||||
|
timer.timerTicks = maxTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean repeats(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepeats(int id, boolean repeat){
|
||||||
|
this.timers.get(Integer.valueOf(id)).repeat = repeat;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
public void writeToNBT(NBTTagCompound compound) {
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
Iterator var3 = this.timers.values().iterator();
|
Iterator var3 = this.timers.values().iterator();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -14,28 +14,57 @@ 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 String customTargetType = "noppes.npcs.entity.EntityCustomNpc";
|
||||||
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);
|
||||||
|
compound.setString("CustomTargetType",customTargetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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");
|
||||||
|
customTargetType = compound.getString("CustomTargetType");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
HashMap<String,Integer> killed = getKilled(data);
|
HashMap<String,Integer> killed = getKilled(data);
|
||||||
|
int completed = 0;
|
||||||
|
for(String entityName : targets.keySet()){
|
||||||
|
int amount = 0;
|
||||||
|
if(killed.containsKey(entityName))
|
||||||
|
amount = killed.get(entityName);
|
||||||
|
if(amount >= targets.get(entityName)){
|
||||||
|
completed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(completed >= targets.keySet().size())
|
||||||
|
return true;
|
||||||
|
|
||||||
if(killed.size() != targets.size())
|
if(killed.size() != targets.size())
|
||||||
return false;
|
return false;
|
||||||
for(String entity : killed.keySet()){
|
for(String entity : killed.keySet()){
|
||||||
@@ -90,6 +119,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 > 2)
|
||||||
|
type = 2;
|
||||||
|
|
||||||
|
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 +145,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 +154,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,35 @@ public class ScriptEntityParticle {
|
|||||||
private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
|
private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
|
||||||
private int scaleRateStart = 0, alphaRateStart = 0;
|
private int scaleRateStart = 0, alphaRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationX1 = 0;
|
||||||
|
public float rotationX2 = 0;
|
||||||
|
public float rotationXRate = 0.0F;
|
||||||
|
public int rotationXRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationY1 = 0;
|
||||||
|
public float rotationY2 = 0;
|
||||||
|
public float rotationYRate = 0.0F;
|
||||||
|
public int rotationYRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationZ1 = 0;
|
||||||
|
public float rotationZ2 = 0;
|
||||||
|
public float rotationZRate = 0.0F;
|
||||||
|
public int rotationZRateStart = 0;
|
||||||
|
|
||||||
public ScriptEntityParticle(String directory){
|
public ScriptEntityParticle(String directory){
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnOnEntity(ScriptEntity entity){
|
public void spawnOnEntity(ScriptEntity entity){
|
||||||
int entityID = entity.getMCEntity().getEntityId();
|
int entityID = entity.getMCEntity().getEntityId();
|
||||||
NoppesUtilServer.spawnScriptedParticle(entity.getMCEntity(), directory, HEXcolor, amount, maxAge,
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,11 +70,9 @@ public class ScriptEntityParticle {
|
|||||||
public double getX() {
|
public double getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
@@ -64,50 +80,56 @@ public class ScriptEntityParticle {
|
|||||||
public double getMotionX() {
|
public double getMotionX() {
|
||||||
return motionX;
|
return motionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMotionY() {
|
public double getMotionY() {
|
||||||
return motionY;
|
return motionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMotionZ() {
|
public double getMotionZ() {
|
||||||
return motionZ;
|
return motionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getGravity() {
|
public float getGravity() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getScale1() {
|
|
||||||
return scale1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScale2() {
|
|
||||||
return scale2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScaleRate() {
|
|
||||||
return scaleRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAlpha1() {
|
public float getAlpha1() {
|
||||||
return alpha1;
|
return alpha1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAlpha2() {
|
public float getAlpha2() {
|
||||||
return alpha2;
|
return alpha2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAlphaRate() {
|
public float getAlphaRate() {
|
||||||
return alphaRate;
|
return alphaRate;
|
||||||
}
|
}
|
||||||
|
public int getAlphaRateStart() {
|
||||||
|
return alphaRateStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getScale1() {
|
||||||
|
return scale1;
|
||||||
|
}
|
||||||
|
public float getScale2() {
|
||||||
|
return scale2;
|
||||||
|
}
|
||||||
|
public float getScaleRate() {
|
||||||
|
return scaleRate;
|
||||||
|
}
|
||||||
public int getScaleRateStart() {
|
public int getScaleRateStart() {
|
||||||
return scaleRateStart;
|
return scaleRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAlphaRateStart() {
|
public float getRotationX1() {return rotationX1;}
|
||||||
return alphaRateStart;
|
public float getRotationX2() {return rotationX2;}
|
||||||
}
|
public float getRotationXRate() {return rotationXRate;}
|
||||||
|
public int getRotationXRateStart() {return rotationXRateStart;}
|
||||||
|
|
||||||
|
public float getRotationY1() {return rotationY1;}
|
||||||
|
public float getRotationY2() {return rotationY2;}
|
||||||
|
public float getRotationYRate() {return rotationYRate;}
|
||||||
|
public int getRotationYRateStart() {return rotationYRateStart;}
|
||||||
|
|
||||||
|
public float getRotationZ1() {return rotationZ1;}
|
||||||
|
public float getRotationZ2() {return rotationZ2;}
|
||||||
|
public float getRotationZRate() {return rotationZRate;}
|
||||||
|
public int getRotationZRateStart() {return rotationZRateStart;}
|
||||||
|
|
||||||
public void setDirectory(String directory) {
|
public void setDirectory(String directory) {
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
@@ -130,15 +152,12 @@ public class ScriptEntityParticle {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setX(double x) {
|
public void setX(double x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setY(double y) {
|
public void setY(double y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZ(double z) {
|
public void setZ(double z) {
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
@@ -149,19 +168,15 @@ public class ScriptEntityParticle {
|
|||||||
this.motionZ = motionZ;
|
this.motionZ = motionZ;
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionX(double motionX) {
|
public void setMotionX(double motionX) {
|
||||||
this.motionX = motionX;
|
this.motionX = motionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionY(double motionY) {
|
public void setMotionY(double motionY) {
|
||||||
this.motionY = motionY;
|
this.motionY = motionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionZ(double motionZ) {
|
public void setMotionZ(double motionZ) {
|
||||||
this.motionZ = motionZ;
|
this.motionZ = motionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGravity(float gravity) {
|
public void setGravity(float gravity) {
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
}
|
}
|
||||||
@@ -172,19 +187,15 @@ public class ScriptEntityParticle {
|
|||||||
this.scaleRate = scaleRate;
|
this.scaleRate = scaleRate;
|
||||||
this.scaleRateStart = scaleRateStart;
|
this.scaleRateStart = scaleRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale1(float scale1) {
|
public void setScale1(float scale1) {
|
||||||
this.scale1 = scale1;
|
this.scale1 = scale1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale2(float scale2) {
|
public void setScale2(float scale2) {
|
||||||
this.scale2 = scale2;
|
this.scale2 = scale2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScaleRate(float scaleRate) {
|
public void setScaleRate(float scaleRate) {
|
||||||
this.scaleRate = scaleRate;
|
this.scaleRate = scaleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScaleRateStart(int scaleRateStart) {
|
public void setScaleRateStart(int scaleRateStart) {
|
||||||
this.scaleRateStart = scaleRateStart;
|
this.scaleRateStart = scaleRateStart;
|
||||||
}
|
}
|
||||||
@@ -195,20 +206,49 @@ public class ScriptEntityParticle {
|
|||||||
this.alphaRate = alphaRate;
|
this.alphaRate = alphaRate;
|
||||||
this.alphaRateStart = alphaRateStart;
|
this.alphaRateStart = alphaRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlpha1(float alpha1) {
|
public void setAlpha1(float alpha1) {
|
||||||
this.alpha1 = alpha1;
|
this.alpha1 = alpha1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlpha2(float alpha2) {
|
public void setAlpha2(float alpha2) {
|
||||||
this.alpha2 = alpha2;
|
this.alpha2 = alpha2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlphaRate(float alphaRate) {
|
public void setAlphaRate(float alphaRate) {
|
||||||
this.alphaRate = alphaRate;
|
this.alphaRate = alphaRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlphaRateStart(int alphaRateStart) {
|
public void setAlphaRateStart(int alphaRateStart) {
|
||||||
this.alphaRateStart = alphaRateStart;
|
this.alphaRateStart = alphaRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){
|
||||||
|
this.rotationX1 = rotationX1;
|
||||||
|
this.rotationX2 = rotationX2;
|
||||||
|
this.rotationXRate = rotationXRate;
|
||||||
|
this.rotationXRateStart = rotationXRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationX1(float rotationX1) {this.rotationX1 = rotationX1;}
|
||||||
|
public void setRotationX2(float rotationX2) {this.rotationX2 = rotationX2;}
|
||||||
|
public void setRotationXRate(float rotationXRate) {this.rotationXRate = rotationXRate;}
|
||||||
|
public void setRotationXRateStart(int rotationXRateStart) {this.rotationXRateStart = rotationXRateStart;}
|
||||||
|
|
||||||
|
public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){
|
||||||
|
this.rotationY1 = rotationY1;
|
||||||
|
this.rotationY2 = rotationY2;
|
||||||
|
this.rotationYRate = rotationYRate;
|
||||||
|
this.rotationYRateStart = rotationYRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationY1(float rotationY1) {this.rotationY1 = rotationY1;}
|
||||||
|
public void setRotationY2(float rotationY2) {this.rotationY2 = rotationY2;}
|
||||||
|
public void setRotationYRate(float rotationYRate) {this.rotationYRate = rotationYRate;}
|
||||||
|
public void setRotationYRateStart(int rotationYRateStart) {this.rotationYRateStart = rotationYRateStart;}
|
||||||
|
|
||||||
|
public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){
|
||||||
|
this.rotationZ1 = rotationZ1;
|
||||||
|
this.rotationZ2 = rotationZ2;
|
||||||
|
this.rotationZRate = rotationZRate;
|
||||||
|
this.rotationZRateStart = rotationZRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationZ1(float rotationZ1) {this.rotationZ1 = rotationZ1;}
|
||||||
|
public void setRotationZ2(float rotationZ2) {this.rotationZ2 = rotationZ2;}
|
||||||
|
public void setRotationZRate(float rotationZRate) {this.rotationZRate = rotationZRate;}
|
||||||
|
public void setRotationZRateStart(int rotationZRateStart) {this.rotationZRateStart = rotationZRateStart;}
|
||||||
}
|
}
|
||||||
@@ -224,23 +224,33 @@ public class ScriptItemStack implements IItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String[] getLore() {
|
public String[] getLore() {
|
||||||
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
if (this.item.getTagCompound() != null) {
|
||||||
if (compound != null && compound.func_150299_b("Lore") == 9) {
|
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
||||||
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
if(compound != null && compound.func_150299_b("Lore") == 9) {
|
||||||
if (nbttaglist.tagCount() < 1) {
|
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
||||||
return new String[0];
|
if (nbttaglist.tagCount() > 0) {
|
||||||
} else {
|
List<String> lore = new ArrayList();
|
||||||
List<String> lore = new ArrayList();
|
|
||||||
|
|
||||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||||
lore.add(nbttaglist.getStringTagAt(i));
|
lore.add(nbttaglist.getStringTagAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String[]) ((String[]) lore.toArray(new String[lore.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String[])((String[])lore.toArray(new String[lore.size()]));
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return new String[0];
|
|
||||||
}
|
}
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLore() {
|
||||||
|
if (this.item.getTagCompound() != null) {
|
||||||
|
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
||||||
|
if (compound != null && compound.func_150299_b("Lore") == 9) {
|
||||||
|
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
||||||
|
return nbttaglist.tagCount() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLore(String[] lore) {
|
public void setLore(String[] lore) {
|
||||||
|
|||||||
@@ -445,6 +445,26 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setForm(byte form){
|
public void setForm(byte form){
|
||||||
|
if(form < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(getRace()){
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
if(form > 3)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
if(form > 15)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if(form > 7)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
||||||
}
|
}
|
||||||
public byte getForm(){
|
public byte getForm(){
|
||||||
|
|||||||
@@ -67,14 +67,101 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
|||||||
double x, double y, double z,
|
double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
|
||||||
) {
|
) {
|
||||||
int entityID = entity.getEntityId();
|
int entityID = entity.getEntityId();
|
||||||
NoppesUtilServer.spawnScriptedParticle(entity, directory, HEXcolor, amount, maxAge,
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -179,6 +266,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 +596,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) {
|
||||||
@@ -103,7 +106,11 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
|||||||
public T getMCEntity(){
|
public T getMCEntity(){
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T getMinecraftEntity(){
|
||||||
|
return getMCEntity();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the entity swing its hand
|
* Makes the entity swing its hand
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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,30 @@ 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){
|
||||||
|
int prevHunger = this.getHunger();
|
||||||
|
if(hunger < 0)
|
||||||
|
hunger = 0;
|
||||||
|
|
||||||
|
player.getFoodStats().addStats(hunger-prevHunger,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSaturation(){
|
||||||
|
return player.getFoodStats().getSaturationLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaturation(float saturation){
|
||||||
|
float prevSaturation = this.getHunger();
|
||||||
|
if(saturation < 0)
|
||||||
|
saturation = 0;
|
||||||
|
|
||||||
|
player.getFoodStats().addStats(0,saturation-prevSaturation);
|
||||||
|
}
|
||||||
|
|
||||||
public int getDimension(){
|
public int getDimension(){
|
||||||
return player.dimension;
|
return player.dimension;
|
||||||
}
|
}
|
||||||
@@ -91,7 +113,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
|||||||
if(dialog == null)
|
if(dialog == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog);
|
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReadDialog(int id){
|
public boolean hasReadDialog(int id){
|
||||||
@@ -331,6 +353,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 +414,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 +425,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 +480,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() {
|
||||||
|
|||||||
@@ -13,4 +13,10 @@ public class CustomNPCsEvent extends Event{
|
|||||||
|
|
||||||
public CustomNPCsEvent() {
|
public CustomNPCsEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean bo){
|
||||||
|
this.setCanceled(bo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled(){return this.isCanceled();}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import noppes.npcs.controllers.Dialog;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.interfaces.*;
|
import noppes.npcs.scripted.interfaces.*;
|
||||||
|
|
||||||
@@ -51,6 +52,10 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType(){
|
||||||
|
return damageSource.getMCDamageSource().damageType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RangedLaunchedEvent extends NpcEvent {
|
public static class RangedLaunchedEvent extends NpcEvent {
|
||||||
@@ -58,7 +63,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
public float damage;
|
public float damage;
|
||||||
//public List<IProjectile> projectiles = new ArrayList();
|
//public List<IProjectile> projectiles = new ArrayList();
|
||||||
|
|
||||||
public RangedLaunchedEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||||
super(npc);
|
super(npc);
|
||||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
@@ -70,7 +75,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
public final IEntityLivingBase target;
|
public final IEntityLivingBase target;
|
||||||
public float damage;
|
public float damage;
|
||||||
|
|
||||||
public MeleeAttackEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||||
super(npc);
|
super(npc);
|
||||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
@@ -99,6 +104,10 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
this.type = damagesource.damageType;
|
this.type = damagesource.damageType;
|
||||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType(){
|
||||||
|
return damageSource.getMCDamageSource().damageType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
@@ -111,6 +120,36 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DialogEvent extends NpcEvent {
|
||||||
|
public final IPlayer player;
|
||||||
|
public final int id;
|
||||||
|
public final int optionId;
|
||||||
|
public final Dialog dialog;
|
||||||
|
|
||||||
|
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||||
|
super(npc);
|
||||||
|
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||||
|
this.id = id;
|
||||||
|
this.optionId = optionId;
|
||||||
|
this.dialog = dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DialogClosedEvent extends NpcEvent {
|
||||||
|
public final IPlayer player;
|
||||||
|
public final int id;
|
||||||
|
public final int optionId;
|
||||||
|
public final Dialog dialog;
|
||||||
|
|
||||||
|
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||||
|
super(npc);
|
||||||
|
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||||
|
this.id = id;
|
||||||
|
this.optionId = optionId;
|
||||||
|
this.dialog = dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class TargetLostEvent extends NpcEvent {
|
public static class TargetLostEvent extends NpcEvent {
|
||||||
public final IEntityLivingBase entity;
|
public final IEntityLivingBase entity;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 308 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user