Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0732d98ff8 | ||
|
|
32f89f8e92 | ||
|
|
65bb3b5939 | ||
|
|
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 | ||
|
|
f9ab885ddd | ||
|
|
e0f77bdcff | ||
|
|
6ff2678f26 | ||
|
|
a1a0864692 | ||
|
|
b3098053ec | ||
|
|
2155566113 | ||
|
|
9d88da30cf | ||
|
|
24e8648a1d | ||
|
|
e1c283a19e | ||
|
|
aba9dd250a | ||
|
|
f508fbed1a | ||
|
|
007660f16f | ||
|
|
e10aa09728 | ||
|
|
4f38edc147 | ||
|
|
6a6548845b | ||
|
|
0aef0827ec | ||
|
|
791adfc1b4 | ||
|
|
2874643c84 | ||
|
|
b0da137db5 | ||
|
|
c28a9156d5 | ||
|
|
4ba6f3086f | ||
|
|
555ceb741f | ||
|
|
04def38b63 | ||
|
|
b024f800ae | ||
|
|
8919a182c5 | ||
|
|
6b9cfb9d25 | ||
|
|
d50f51e208 | ||
|
|
69f96519dc | ||
|
|
7808e4a433 | ||
|
|
d74a1f2bee | ||
|
|
c3541df1dc | ||
|
|
32792e7d6f | ||
|
|
73db2da124 | ||
|
|
6459e7fe2a | ||
|
|
a32db79a0b | ||
|
|
de5f119fd7 | ||
|
|
b330678104 | ||
|
|
e6f97784ff | ||
|
|
e676c808e3 | ||
|
|
e5edbe002e | ||
|
|
ce9b9fb59d | ||
|
|
c8f6a24baf | ||
|
|
2743fa17d8 | ||
|
|
5409e4e924 | ||
|
|
6573970840 | ||
|
|
efdd1d6679 | ||
|
|
4cca8e562c | ||
|
|
4c31236590 | ||
|
|
b62149d5f6 | ||
|
|
ff810cbc8d | ||
|
|
69d4fb20ff | ||
|
|
953f6e0459 | ||
|
|
1a78b2dad7 | ||
|
|
d46d0aba7e | ||
|
|
03ee733620 | ||
|
|
7d94e0e210 | ||
|
|
f03516b00f | ||
|
|
23384d1d67 | ||
|
|
6bdc68337c | ||
|
|
3a9789b3fd | ||
|
|
69b7a9aab4 | ||
|
|
9d9c481bdd | ||
|
|
98d2d943ae | ||
|
|
e9a4471cd2 | ||
|
|
934d5a69d6 | ||
|
|
12cb6a2937 | ||
|
|
cad275e845 | ||
|
|
816445bccd | ||
|
|
cf91d8638f | ||
|
|
03395ad750 | ||
|
|
f2da93451f | ||
|
|
00557df9a7 | ||
|
|
541958b630 | ||
|
|
eac3d2c214 | ||
|
|
ba0f21dc26 | ||
|
|
743cdb9db7 | ||
|
|
fc1c16032f | ||
|
|
b7d2dab905 | ||
|
|
9560228ba8 | ||
|
|
ba4bf107b5 | ||
|
|
81881e6e19 | ||
|
|
909f69575a | ||
|
|
34f6f670eb | ||
|
|
8c602c4d16 | ||
|
|
d66f532643 | ||
|
|
d37e986006 | ||
|
|
29db4bfe33 | ||
|
|
90eec7a57b | ||
|
|
94c7df410b | ||
|
|
c2564de470 | ||
|
|
2147bd00d0 | ||
|
|
922708bf97 | ||
|
|
43b3241801 | ||
|
|
12333de3a1 | ||
|
|
3cd1410c19 | ||
|
|
3c1bc30e44 | ||
|
|
cd5b4c0633 | ||
|
|
f14bc107d3 | ||
|
|
547f5ab82d | ||
|
|
23686dc3b8 | ||
|
|
44d4e74279 | ||
|
|
17eb612fb8 | ||
|
|
72869e6a78 | ||
|
|
e8dd3e7ddc | ||
|
|
3dd8a60702 | ||
|
|
71c81bce27 | ||
|
|
f39ed1fd37 | ||
|
|
f3ebf86b1e | ||
|
|
f64399e40d | ||
|
|
d79ec52994 | ||
|
|
3069488c54 | ||
|
|
24790b7952 | ||
|
|
edabe3890f | ||
|
|
ecbfd7dab0 | ||
|
|
d24422c3a1 | ||
|
|
8a7f40189e | ||
|
|
77c2897109 | ||
|
|
d5c13ae65f | ||
|
|
d2fe832508 | ||
|
|
03e4400b2e | ||
|
|
0d807b36d9 | ||
|
|
27b88c1fce | ||
|
|
40b39d3b20 | ||
|
|
70f1ff2613 | ||
|
|
6b2a9d92b1 | ||
|
|
2ffa9bfcfa | ||
|
|
27dce4a90a | ||
|
|
1478841098 | ||
|
|
6fcf566ef7 | ||
|
|
18aa2d099f | ||
|
|
b068c76fc8 | ||
|
|
a29058d696 | ||
|
|
d1c4adf371 | ||
|
|
4de969f6c9 | ||
|
|
a993c8feff | ||
|
|
5515f5ef83 | ||
|
|
8b710ed520 | ||
|
|
b15f5221fd | ||
|
|
40e738384f | ||
|
|
f88cbb8b51 | ||
|
|
c8f917d8fb | ||
|
|
bb1da8376d | ||
|
|
feeef71b5a | ||
|
|
15bfbcdbd1 | ||
|
|
72f2c3c60a | ||
|
|
c5ed7497c8 | ||
|
|
a9bce4a3e3 | ||
|
|
2d70b0091b | ||
|
|
047552d9e5 | ||
|
|
699182f4c0 | ||
|
|
6752f8baec | ||
|
|
6c8c7671b8 | ||
|
|
1ee14920ff | ||
|
|
6aa98aecf3 | ||
|
|
44bd1692d1 | ||
|
|
95d2814651 | ||
|
|
8b6e84a8d4 | ||
|
|
5a1c4757cf | ||
|
|
69877e8edf | ||
|
|
79339be79a | ||
|
|
58a1ccc3e7 | ||
|
|
a5f9ec103f | ||
|
|
4ba0460a16 | ||
|
|
71e13a177f | ||
|
|
c39ebc4909 | ||
|
|
f6d9149038 | ||
|
|
50e3ae7f83 | ||
|
|
b43d89f91e | ||
|
|
1c2534bfc4 | ||
|
|
61ad3dc849 | ||
|
|
6e9c693d49 | ||
|
|
fbc22fdef2 | ||
|
|
9f4ab7f01e | ||
|
|
2a378190ae | ||
|
|
459976c54d | ||
|
|
a2e869ddb3 | ||
|
|
1b3f9dc019 | ||
|
|
3727d1af7a | ||
|
|
7e7aaa805b | ||
|
|
c05c4fdb0d | ||
|
|
acd666e073 | ||
|
|
a1d467f657 | ||
|
|
3a36be0ae4 | ||
|
|
f155ef2481 | ||
|
|
65eeca72cf | ||
|
|
f9bdc66956 | ||
|
|
8028dde5ae | ||
|
|
502d8faf73 | ||
|
|
de8f8c9a45 | ||
|
|
4c8045f4df | ||
|
|
efa3f0f263 | ||
|
|
d31a4b3879 | ||
|
|
44b6199062 | ||
|
|
7d4949b07a | ||
|
|
24fea99f72 | ||
|
|
4921b3a010 | ||
|
|
46fd50a6ae | ||
|
|
013a9f801e | ||
|
|
0088f750ee | ||
|
|
63f448b67d | ||
|
|
0a665a46be | ||
|
|
69a85769a4 | ||
|
|
169eba238b | ||
|
|
8d455c329b | ||
|
|
23cae600de | ||
|
|
c1f57ba1ce | ||
|
|
2749637ed6 | ||
|
|
0608068276 | ||
|
|
06df9e015e | ||
|
|
2262639182 |
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: CustomNPC+ Issue Report
|
||||||
|
about: Report an issue with the current version of CustomNPC+
|
||||||
|
title: ''
|
||||||
|
labels: Bug, Unreviewed
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Issue description:**
|
||||||
|
|
||||||
|
**If crashed, link to crash report (use a site such as pastebin):**
|
||||||
|
|
||||||
|
**Versions:**
|
||||||
|
* Minecraft: 1.7.10
|
||||||
|
* Forge:
|
||||||
|
* CustomNPC+:
|
||||||
|
|
||||||
|
**Can it be reproduced with *just* CustomNPC+? If not, list the other mods *required* to reproduce the issue.**
|
||||||
@@ -1,43 +1,62 @@
|
|||||||

|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
#### Notice
|
Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
|
||||||
|
|
||||||
|
### ❗ 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
|
||||||
- [ ] Custom Part Disabling [WIP]
|
- Custom Part Disabling
|
||||||
- [ ] Flying NPCS [WIP]
|
- Markov Name Generator
|
||||||
|
- Flying NPCS
|
||||||
|
- 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!
|
||||||
|
|
||||||
|
|
||||||
|
## 🔰 Skin Model Feature:
|
||||||
###### **Majority of these cape designs are taken from the internet with fair-usage.*
|
###### **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"/>
|
||||||
|
|
||||||
### Skin Model Feature:
|
#### Scale/Puppet Reset:
|
||||||
##### Please note all *local* skins in this version of CustomNPC, must match the model selected.
|
<img src="images/guiAnimation.gif" width="474" height="260"/>
|
||||||
<img src="skinAnimation.gif" width="474" height="260"/>
|
|
||||||
|
#### Url64:
|
||||||
|
<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>
|
||||||
|
|
||||||
@@ -17,15 +17,33 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.5.3"
|
||||||
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 = "modid"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.7.10-10.13.4.1614-1.7.10"
|
version = "1.7.10-10.13.4.1614-1.7.10"
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
shade
|
||||||
|
compile.extendsFrom shade
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of all supported OS for zstd compression (This is include only for anyone which is not using the default compression)
|
||||||
|
def supportedOS = [
|
||||||
|
"linux_amd64",
|
||||||
|
"linux_i386",
|
||||||
|
"win_amd64",
|
||||||
|
"win_x86",
|
||||||
|
"darwin_x86_64",
|
||||||
|
"darwin_aarch64"
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// you may put jars on which you depend on in ./libs
|
// you may put jars on which you depend on in ./libs
|
||||||
// or you may define them like so..
|
// or you may define them like so..
|
||||||
@@ -39,6 +57,11 @@ 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
|
||||||
|
// shade 'com.github.luben:zstd-jni:1.5.2-2' - Remove almost implementations of zstd
|
||||||
|
|
||||||
|
for (os in supportedOS) {
|
||||||
|
shade ("com.github.luben:zstd-jni:1.5.2-2:${os}")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,3 +84,17 @@ processResources
|
|||||||
exclude 'mcmod.info'
|
exclude 'mcmod.info'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
configurations.shade.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[0514/203945.010:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/203945.039:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/203945.047:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/205447.662:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/205458.151:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/205458.162:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0514/205458.186:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/004913.901:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/004914.692:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/004914.711:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/004914.724:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/011427.812:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/011427.829:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
[0515/011427.838:WARNING:dns_config_service_win.cc(668)] Failed to read DnsConfig.
|
||||||
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 787 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 8.0 MiB After Width: | Height: | Size: 8.0 MiB |
@@ -0,0 +1,187 @@
|
|||||||
|
package foxz.command;
|
||||||
|
|
||||||
|
import foxz.commandhelper.ChMcLogger;
|
||||||
|
import foxz.commandhelper.annotations.Command;
|
||||||
|
import foxz.commandhelper.annotations.SubCommand;
|
||||||
|
import foxz.commandhelper.permissions.OpOnly;
|
||||||
|
import luizotavio.compressor.ZstdCompressor;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static luizotavio.compressor.executor.IOExecutor.IO_EXECUTOR;
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "compressor",
|
||||||
|
desc = "Convert a file to a compressed file or back to json",
|
||||||
|
usage = "update [file|all] [json|zstd]"
|
||||||
|
)
|
||||||
|
public class CmdCompressor extends ChMcLogger {
|
||||||
|
|
||||||
|
public CmdCompressor(Object sender) {
|
||||||
|
super(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubCommand(
|
||||||
|
name = "update",
|
||||||
|
desc = "Convert all files in the current directory to compressed files",
|
||||||
|
permissions = {OpOnly.class}
|
||||||
|
)
|
||||||
|
public boolean onConvert(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
if (args.length == 0) {
|
||||||
|
sendmessage("Usage: /noppes compressor update [<filename>|all] [json|zstd]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
sendmessage("Please specify the type of compression to use");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type;
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("json")) {
|
||||||
|
type = "json";
|
||||||
|
} else if (args[1].equalsIgnoreCase("zstd")) {
|
||||||
|
type = "zstd";
|
||||||
|
} else {
|
||||||
|
sendmessage("Please specify the type of compression to use");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File directory = PlayerDataController.instance.getSaveDir();
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
sendmessage("Converting all files in the current directory to " + type + " files");
|
||||||
|
|
||||||
|
for (File file : directory.listFiles()) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".json") && type.equalsIgnoreCase("zstd")) {
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
|
||||||
|
File compressed = new File(file.getParentFile(), file.getName().replace(".json", ".zstd"));
|
||||||
|
|
||||||
|
byte[] bytes = ZstdCompressor.writeCompound(compound);
|
||||||
|
|
||||||
|
Files.write(
|
||||||
|
compressed.toPath(),
|
||||||
|
bytes,
|
||||||
|
StandardOpenOption.CREATE,
|
||||||
|
StandardOpenOption.WRITE
|
||||||
|
);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".zstd") && type.equalsIgnoreCase("json")) {
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
|
||||||
|
new RandomAccessFile(file, "r")
|
||||||
|
);
|
||||||
|
|
||||||
|
File compressed = new File(file.getParentFile(), file.getName().replace(".zstd", ".json"));
|
||||||
|
|
||||||
|
NBTJsonUtil.SaveFile(compressed, compound);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sendmessage("Done! All files were converted.");
|
||||||
|
} else {
|
||||||
|
File file = new File(directory, args[0] + ".json");
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
file = new File(directory, args[0] + ".zstd");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
sendmessage("File not found");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File finalFile = file;
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".json")) {
|
||||||
|
if (type.equalsIgnoreCase("json")) {
|
||||||
|
sendmessage("File is already in json format");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(finalFile);
|
||||||
|
|
||||||
|
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".json", ".zstd"));
|
||||||
|
|
||||||
|
byte[] bytes = ZstdCompressor.writeCompound(compound);
|
||||||
|
|
||||||
|
Files.write(
|
||||||
|
compressed.toPath(),
|
||||||
|
bytes,
|
||||||
|
StandardOpenOption.CREATE,
|
||||||
|
StandardOpenOption.WRITE
|
||||||
|
);
|
||||||
|
|
||||||
|
sendmessage("File compressed to zstd!");
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".zstd")) {
|
||||||
|
if (type.equalsIgnoreCase("zstd")) {
|
||||||
|
sendmessage("File is already in zstd format");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
|
||||||
|
new RandomAccessFile(finalFile, "r")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (compound == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".zstd", ".json"));
|
||||||
|
|
||||||
|
NBTJsonUtil.SaveFile(compressed, compound);
|
||||||
|
|
||||||
|
sendmessage("File converted to json!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submit(Runnable runnable) throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
CompletableFuture.runAsync(runnable, IO_EXECUTOR).get(5, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,10 @@ package foxz.command;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import noppes.npcs.EventHooks;
|
||||||
import noppes.npcs.controllers.Faction;
|
import noppes.npcs.controllers.Faction;
|
||||||
|
import noppes.npcs.controllers.FactionController;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.controllers.PlayerFactionData;
|
import noppes.npcs.controllers.PlayerFactionData;
|
||||||
import foxz.commandhelper.ChMcLogger;
|
import foxz.commandhelper.ChMcLogger;
|
||||||
@@ -10,6 +13,8 @@ import foxz.commandhelper.annotations.Command;
|
|||||||
import foxz.commandhelper.annotations.SubCommand;
|
import foxz.commandhelper.annotations.SubCommand;
|
||||||
import foxz.commandhelper.permissions.OpOnly;
|
import foxz.commandhelper.permissions.OpOnly;
|
||||||
import foxz.commandhelper.permissions.ParamCheck;
|
import foxz.commandhelper.permissions.ParamCheck;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.FactionEvent;
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "faction",
|
name = "faction",
|
||||||
@@ -43,7 +48,7 @@ public class CmdFaction extends ChMcLogger {
|
|||||||
|
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, points);
|
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -64,7 +69,7 @@ public class CmdFaction extends ChMcLogger {
|
|||||||
int factionid = this.selectedFaction.id;
|
int factionid = this.selectedFaction.id;
|
||||||
for(PlayerData playerdata : data){
|
for(PlayerData playerdata : data){
|
||||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||||
playerfactiondata.increasePoints(factionid, -points);
|
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,11 @@ import foxz.commandhelper.annotations.SubCommand;
|
|||||||
import foxz.commandhelper.permissions.OpOnly;
|
import foxz.commandhelper.permissions.OpOnly;
|
||||||
import foxz.commandhelper.permissions.ParamCheck;
|
import foxz.commandhelper.permissions.ParamCheck;
|
||||||
import foxz.commandhelper.permissions.PlayerOnly;
|
import foxz.commandhelper.permissions.PlayerOnly;
|
||||||
import foxz.utils.Utils;
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "noppes",
|
name = "noppes",
|
||||||
desc = "noppes root command",
|
desc = "noppes root command",
|
||||||
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
|
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class, CmdCompressor.class}
|
||||||
)
|
)
|
||||||
public class CmdNoppes extends ChMcLogger {
|
public class CmdNoppes extends ChMcLogger {
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ public class CmdNoppes extends ChMcLogger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
cmdfaction.selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
|
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e){
|
catch(NumberFormatException e){
|
||||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package kam.npcs;
|
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
|
||||||
import noppes.npcs.client.model.util.Model2DRenderer;
|
|
||||||
|
|
||||||
public class LegacyCode {
|
|
||||||
|
|
||||||
// Old MPM Model : Unused
|
|
||||||
|
|
||||||
// public ModelMPM(float par1) {
|
|
||||||
// super(par1);
|
|
||||||
// isArmor = par1 > 0;
|
|
||||||
// float par2 = 0;
|
|
||||||
// this.bipedCloak = new ModelRenderer(this, 0, 0);
|
|
||||||
// this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1);
|
|
||||||
// this.bipedEars = new ModelRenderer(this, 24, 0);
|
|
||||||
// this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1);
|
|
||||||
// this.bipedHead = new ModelScaleRenderer(this, 0, 0);
|
|
||||||
// this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1);
|
|
||||||
// this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
|
|
||||||
// this.bipedHeadwear = new ModelScaleRenderer(this, 32, 0);
|
|
||||||
// this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F);
|
|
||||||
// this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
|
|
||||||
// this.bipedBody = new ModelScaleRenderer(this, 16, 16);
|
|
||||||
// this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1);
|
|
||||||
// this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
|
|
||||||
// this.bipedRightArm = new ModelScaleRenderer(this, 40, 16);
|
|
||||||
// this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1);
|
|
||||||
// this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F);
|
|
||||||
// this.bipedLeftArm = new ModelScaleRenderer(this, 40, 16);
|
|
||||||
// this.bipedLeftArm.mirror = true;
|
|
||||||
// this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1);
|
|
||||||
// this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
|
|
||||||
// this.bipedRightLeg = new ModelScaleRenderer(this, 0, 16);
|
|
||||||
// this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1);
|
|
||||||
// this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F);
|
|
||||||
// this.bipedLeftLeg = new ModelScaleRenderer(this, 0, 16);
|
|
||||||
// this.bipedLeftLeg.mirror = true;
|
|
||||||
// this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1);
|
|
||||||
// this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F);
|
|
||||||
//
|
|
||||||
// headwear = new ModelHeadwear(this);
|
|
||||||
// legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg);
|
|
||||||
//
|
|
||||||
// this.bipedBody.addChild(breasts = new ModelBreasts(this));
|
|
||||||
// if(!isArmor){
|
|
||||||
// this.bipedHead.addChild(ears = new ModelEars(this));
|
|
||||||
// this.bipedHead.addChild(mohawk = new ModelMohawk(this));
|
|
||||||
// this.bipedHead.addChild(hair = new ModelHair(this));
|
|
||||||
// this.bipedHead.addChild(beard = new ModelBeard(this));
|
|
||||||
// this.bipedHead.addChild(snout = new ModelSnout(this));
|
|
||||||
// this.bipedHead.addChild(horns = new ModelHorns(this));
|
|
||||||
//
|
|
||||||
// tail = new ModelTail(this);
|
|
||||||
//
|
|
||||||
// this.bipedBody.addChild(wings = new ModelWings(this));
|
|
||||||
// this.bipedBody.addChild(skirt = new ModelSkirt(this));
|
|
||||||
// this.bipedBody.addChild(fin = new ModelFin(this));
|
|
||||||
//
|
|
||||||
// this.bipedLeftArm.addChild(clawsL = new ModelClaws(this, false));
|
|
||||||
// this.bipedRightArm.addChild(clawsR = new ModelClaws(this, true));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package luizotavio.compressor;
|
||||||
|
|
||||||
|
import com.github.luben.zstd.Zstd;
|
||||||
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
|
import net.minecraft.nbt.NBTSizeTracker;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ZstdCompressor {
|
||||||
|
|
||||||
|
public static byte[] readCompressed(DataInput inputStream) throws IOException {
|
||||||
|
int compressedLength = inputStream.readInt();
|
||||||
|
int uncompressedLength = inputStream.readInt();
|
||||||
|
|
||||||
|
if (compressedLength < 0 || uncompressedLength < 0) {
|
||||||
|
throw new IllegalArgumentException("Invalid length");
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] compressed = new byte[compressedLength];
|
||||||
|
|
||||||
|
inputStream.readFully(compressed);
|
||||||
|
|
||||||
|
return Zstd.decompress(compressed, uncompressedLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagCompound readCompressCompound(DataInput inputStream) throws IOException {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
|
||||||
|
byte[] compressed = readCompressed(inputStream);
|
||||||
|
|
||||||
|
try (DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(compressed))) {
|
||||||
|
compound = CompressedStreamTools.func_152456_a(dataInputStream, NBTSizeTracker.field_152451_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] writeCompound(NBTTagCompound compound) throws IOException {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(),
|
||||||
|
copy = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try (DataOutputStream dataOutputStream = new DataOutputStream(outputStream)) {
|
||||||
|
CompressedStreamTools.write(compound, dataOutputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] uncompressed = outputStream.toByteArray();
|
||||||
|
|
||||||
|
byte[] compress = Zstd.compress(uncompressed);
|
||||||
|
|
||||||
|
try (DataOutputStream dataOutputStream = new DataOutputStream(copy)) {
|
||||||
|
dataOutputStream.writeInt(compress.length);
|
||||||
|
dataOutputStream.writeInt(uncompressed.length);
|
||||||
|
|
||||||
|
dataOutputStream.write(compress);
|
||||||
|
|
||||||
|
return copy.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package luizotavio.compressor.executor;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
public class IOExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please, do not change this value unless you know what you are doing.
|
||||||
|
* This value is used to define the number of threads that will be used to
|
||||||
|
* compress the files.
|
||||||
|
*
|
||||||
|
* If you want to change this value, please, do it with care.
|
||||||
|
*/
|
||||||
|
public static ExecutorService IO_EXECUTOR;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.minecraft.block.properties;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/** This code is owned by Minecraft */
|
||||||
|
|
||||||
|
public interface IProperty<T extends Comparable<T>>
|
||||||
|
{
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
Collection<T> getAllowedValues();
|
||||||
|
|
||||||
|
Class<T> getValueClass();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name for the given value.
|
||||||
|
*/
|
||||||
|
String getName(T value);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package net.minecraft.block.state;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import java.util.Collection;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
|
||||||
|
/** This code is owned by Minecraft */
|
||||||
|
|
||||||
|
public interface IBlockState
|
||||||
|
{
|
||||||
|
Collection<IProperty> getPropertyNames();
|
||||||
|
|
||||||
|
<T extends Comparable<T>> T getValue(IProperty<T> property);
|
||||||
|
|
||||||
|
<T extends Comparable<T>, V extends T> IBlockState withProperty(IProperty<T> property, V value);
|
||||||
|
|
||||||
|
<T extends Comparable<T>> IBlockState cycleProperty(IProperty<T> property);
|
||||||
|
|
||||||
|
ImmutableMap<IProperty, Comparable> getProperties();
|
||||||
|
|
||||||
|
Block getBlock();
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
package net.minecraft.util;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
/** This code is owned by Minecraft */
|
||||||
|
|
||||||
|
public class Vec3i implements Comparable<Vec3i>
|
||||||
|
{
|
||||||
|
/** The Null vector constant (0, 0, 0) */
|
||||||
|
public static final Vec3i NULL_VECTOR = new Vec3i(0, 0, 0);
|
||||||
|
/** X coordinate */
|
||||||
|
private final int x;
|
||||||
|
/** Y coordinate */
|
||||||
|
private final int y;
|
||||||
|
/** Z coordinate */
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
public Vec3i(int xIn, int yIn, int zIn)
|
||||||
|
{
|
||||||
|
this.x = xIn;
|
||||||
|
this.y = yIn;
|
||||||
|
this.z = zIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i(double xIn, double yIn, double zIn)
|
||||||
|
{
|
||||||
|
this(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object p_equals_1_)
|
||||||
|
{
|
||||||
|
if (this == p_equals_1_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!(p_equals_1_ instanceof Vec3i))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vec3i vec3i = (Vec3i)p_equals_1_;
|
||||||
|
return this.getX() != vec3i.getX() ? false : (this.getY() != vec3i.getY() ? false : this.getZ() == vec3i.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Vec3i p_compareTo_1_)
|
||||||
|
{
|
||||||
|
return this.getY() == p_compareTo_1_.getY() ? (this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX() : this.getZ() - p_compareTo_1_.getZ()) : this.getY() - p_compareTo_1_.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the X coordinate
|
||||||
|
*/
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Y coordinate
|
||||||
|
*/
|
||||||
|
public int getY()
|
||||||
|
{
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Z coordinate
|
||||||
|
*/
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the cross product of this and the given Vector
|
||||||
|
*/
|
||||||
|
public Vec3i crossProduct(Vec3i vec)
|
||||||
|
{
|
||||||
|
return new Vec3i(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate squared distance to the given coordinates
|
||||||
|
*/
|
||||||
|
public double distanceSq(double toX, double toY, double toZ)
|
||||||
|
{
|
||||||
|
double d0 = (double)this.getX() - toX;
|
||||||
|
double d1 = (double)this.getY() - toY;
|
||||||
|
double d2 = (double)this.getZ() - toZ;
|
||||||
|
return d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute square of distance from point x, y, z to center of this Block
|
||||||
|
*/
|
||||||
|
public double distanceSqToCenter(double xIn, double yIn, double zIn)
|
||||||
|
{
|
||||||
|
double d0 = (double)this.getX() + 0.5D - xIn;
|
||||||
|
double d1 = (double)this.getY() + 0.5D - yIn;
|
||||||
|
double d2 = (double)this.getZ() + 0.5D - zIn;
|
||||||
|
return d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate squared distance to the given Vector
|
||||||
|
*/
|
||||||
|
public double distanceSq(Vec3i to)
|
||||||
|
{
|
||||||
|
return this.distanceSq((double)to.getX(), (double)to.getY(), (double)to.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,406 @@
|
|||||||
|
package net.minecraft.util.math;
|
||||||
|
|
||||||
|
import com.google.common.collect.AbstractIterator;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.util.Vec3i;
|
||||||
|
|
||||||
|
/** This code is owned by Minecraft */
|
||||||
|
|
||||||
|
public class BlockPos extends Vec3i{
|
||||||
|
/** The BlockPos with all coordinates 0 */
|
||||||
|
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
||||||
|
private static final int NUM_X_BITS = 1 + 25;//MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
|
||||||
|
private static final int NUM_Z_BITS = NUM_X_BITS;
|
||||||
|
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
||||||
|
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
|
||||||
|
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
|
||||||
|
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
|
||||||
|
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
|
||||||
|
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
|
||||||
|
|
||||||
|
public BlockPos(int x, int y, int z)
|
||||||
|
{
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos(double x, double y, double z)
|
||||||
|
{
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos(Entity source)
|
||||||
|
{
|
||||||
|
this(source.posX, source.posY, source.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos(Vec3 source)
|
||||||
|
{
|
||||||
|
this(source.xCoord, source.yCoord, source.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos(Vec3i source)
|
||||||
|
{
|
||||||
|
this(source.getX(), source.getY(), source.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given coordinates to the coordinates of this BlockPos
|
||||||
|
*/
|
||||||
|
public BlockPos add(double x, double y, double z)
|
||||||
|
{
|
||||||
|
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double)this.getX() + x, (double)this.getY() + y, (double)this.getZ() + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given coordinates to the coordinates of this BlockPos
|
||||||
|
*/
|
||||||
|
public BlockPos add(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given Vector to this BlockPos
|
||||||
|
*/
|
||||||
|
public BlockPos add(Vec3i vec)
|
||||||
|
{
|
||||||
|
return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() + vec.getX(), this.getY() + vec.getY(), this.getZ() + vec.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtract the given Vector from this BlockPos
|
||||||
|
*/
|
||||||
|
public BlockPos subtract(Vec3i vec)
|
||||||
|
{
|
||||||
|
return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() - vec.getX(), this.getY() - vec.getY(), this.getZ() - vec.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block up
|
||||||
|
*/
|
||||||
|
public BlockPos up()
|
||||||
|
{
|
||||||
|
return this.up(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks up
|
||||||
|
*/
|
||||||
|
public BlockPos up(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.UP, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block down
|
||||||
|
*/
|
||||||
|
public BlockPos down()
|
||||||
|
{
|
||||||
|
return this.down(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks down
|
||||||
|
*/
|
||||||
|
public BlockPos down(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.DOWN, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block in northern direction
|
||||||
|
*/
|
||||||
|
public BlockPos north()
|
||||||
|
{
|
||||||
|
return this.north(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks in northern direction
|
||||||
|
*/
|
||||||
|
public BlockPos north(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.NORTH, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block in southern direction
|
||||||
|
*/
|
||||||
|
public BlockPos south()
|
||||||
|
{
|
||||||
|
return this.south(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks in southern direction
|
||||||
|
*/
|
||||||
|
public BlockPos south(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.SOUTH, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block in western direction
|
||||||
|
*/
|
||||||
|
public BlockPos west()
|
||||||
|
{
|
||||||
|
return this.west(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks in western direction
|
||||||
|
*/
|
||||||
|
public BlockPos west(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.WEST, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block in eastern direction
|
||||||
|
*/
|
||||||
|
public BlockPos east()
|
||||||
|
{
|
||||||
|
return this.east(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos n blocks in eastern direction
|
||||||
|
*/
|
||||||
|
public BlockPos east(int n)
|
||||||
|
{
|
||||||
|
return this.offset(EnumFacing.EAST, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offset this BlockPos 1 block in the given direction
|
||||||
|
*/
|
||||||
|
public BlockPos offset(EnumFacing facing)
|
||||||
|
{
|
||||||
|
return this.offset(facing, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offsets this BlockPos n blocks in the given direction
|
||||||
|
*/
|
||||||
|
public BlockPos offset(EnumFacing facing, int n)
|
||||||
|
{
|
||||||
|
return n == 0 ? this : new BlockPos(this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the cross product of this and the given Vector
|
||||||
|
*/
|
||||||
|
public BlockPos crossProduct(Vec3i vec)
|
||||||
|
{
|
||||||
|
return new BlockPos(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize this BlockPos into a long value
|
||||||
|
*/
|
||||||
|
public long toLong()
|
||||||
|
{
|
||||||
|
return ((long)this.getX() & X_MASK) << X_SHIFT | ((long)this.getY() & Y_MASK) << Y_SHIFT | ((long)this.getZ() & Z_MASK) << 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a BlockPos from a serialized long value (created by toLong)
|
||||||
|
*/
|
||||||
|
public static BlockPos fromLong(long serialized)
|
||||||
|
{
|
||||||
|
int i = (int)(serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
|
||||||
|
int j = (int)(serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
|
||||||
|
int k = (int)(serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
|
||||||
|
return new BlockPos(i, j, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Iterable<BlockPos> getAllInBox(BlockPos from, BlockPos to)
|
||||||
|
{
|
||||||
|
final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
|
||||||
|
final BlockPos blockpos1 = new BlockPos(Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
|
||||||
|
return new Iterable<BlockPos>()
|
||||||
|
{
|
||||||
|
public Iterator<BlockPos> iterator()
|
||||||
|
{
|
||||||
|
return new AbstractIterator<BlockPos>()
|
||||||
|
{
|
||||||
|
private BlockPos lastReturned = null;
|
||||||
|
protected BlockPos computeNext()
|
||||||
|
{
|
||||||
|
if (this.lastReturned == null)
|
||||||
|
{
|
||||||
|
this.lastReturned = blockpos;
|
||||||
|
return this.lastReturned;
|
||||||
|
}
|
||||||
|
else if (this.lastReturned.equals(blockpos1))
|
||||||
|
{
|
||||||
|
return (BlockPos)this.endOfData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = this.lastReturned.getX();
|
||||||
|
int j = this.lastReturned.getY();
|
||||||
|
int k = this.lastReturned.getZ();
|
||||||
|
|
||||||
|
if (i < blockpos1.getX())
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
else if (j < blockpos1.getY())
|
||||||
|
{
|
||||||
|
i = blockpos.getX();
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
else if (k < blockpos1.getZ())
|
||||||
|
{
|
||||||
|
i = blockpos.getX();
|
||||||
|
j = blockpos.getY();
|
||||||
|
++k;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastReturned = new BlockPos(i, j, k);
|
||||||
|
return this.lastReturned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(BlockPos from, BlockPos to)
|
||||||
|
{
|
||||||
|
final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
|
||||||
|
final BlockPos blockpos1 = new BlockPos(Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
|
||||||
|
return new Iterable<BlockPos.MutableBlockPos>()
|
||||||
|
{
|
||||||
|
public Iterator<BlockPos.MutableBlockPos> iterator()
|
||||||
|
{
|
||||||
|
return new AbstractIterator<BlockPos.MutableBlockPos>()
|
||||||
|
{
|
||||||
|
private BlockPos.MutableBlockPos theBlockPos = null;
|
||||||
|
protected BlockPos.MutableBlockPos computeNext()
|
||||||
|
{
|
||||||
|
if (this.theBlockPos == null)
|
||||||
|
{
|
||||||
|
this.theBlockPos = new BlockPos.MutableBlockPos(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||||
|
return this.theBlockPos;
|
||||||
|
}
|
||||||
|
else if (this.theBlockPos.equals(blockpos1))
|
||||||
|
{
|
||||||
|
return (BlockPos.MutableBlockPos)this.endOfData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = this.theBlockPos.getX();
|
||||||
|
int j = this.theBlockPos.getY();
|
||||||
|
int k = this.theBlockPos.getZ();
|
||||||
|
|
||||||
|
if (i < blockpos1.getX())
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
else if (j < blockpos1.getY())
|
||||||
|
{
|
||||||
|
i = blockpos.getX();
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
else if (k < blockpos1.getZ())
|
||||||
|
{
|
||||||
|
i = blockpos.getX();
|
||||||
|
j = blockpos.getY();
|
||||||
|
++k;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.theBlockPos.x = i;
|
||||||
|
this.theBlockPos.y = j;
|
||||||
|
this.theBlockPos.z = k;
|
||||||
|
return this.theBlockPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a version of this BlockPos that is guaranteed to be Immutable.
|
||||||
|
* In most cases this will return 'this', but if 'this' is an instance of
|
||||||
|
* MutableBlockPos it will return a new instance of BlockPos with the same values.
|
||||||
|
*
|
||||||
|
* When storing a parameter given to you for an extended period of time, make sure you
|
||||||
|
* use this in case the value is changed internally.
|
||||||
|
*
|
||||||
|
* @return An immutable BlockPos.
|
||||||
|
*/
|
||||||
|
public BlockPos getImmutable()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class MutableBlockPos extends BlockPos
|
||||||
|
{
|
||||||
|
/** Mutable X Coordinate */
|
||||||
|
private int x;
|
||||||
|
/** Mutable Y Coordinate */
|
||||||
|
private int y;
|
||||||
|
/** Mutable Z Coordinate */
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public MutableBlockPos()
|
||||||
|
{
|
||||||
|
this(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableBlockPos(int x_, int y_, int z_)
|
||||||
|
{
|
||||||
|
super(0, 0, 0);
|
||||||
|
this.x = x_;
|
||||||
|
this.y = y_;
|
||||||
|
this.z = z_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the X coordinate
|
||||||
|
*/
|
||||||
|
public int getX()
|
||||||
|
{
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Y coordinate
|
||||||
|
*/
|
||||||
|
public int getY()
|
||||||
|
{
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Z coordinate
|
||||||
|
*/
|
||||||
|
public int getZ()
|
||||||
|
{
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the values
|
||||||
|
*
|
||||||
|
* @param xIn The X value
|
||||||
|
* @param yIn The Y value
|
||||||
|
* @param zIn The Z value
|
||||||
|
*/
|
||||||
|
public BlockPos.MutableBlockPos set(int xIn, int yIn, int zIn)
|
||||||
|
{
|
||||||
|
this.x = xIn;
|
||||||
|
this.y = yIn;
|
||||||
|
this.z = zIn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public BlockPos getImmutable() { return new BlockPos(this); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package nikedemos.markovnames;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HashMap2D<T1, T2, T3> {
|
||||||
|
|
||||||
|
public final Map<T1, Map<T2, T3>> mMap;
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://stackoverflow.com/a/10299689/9355344
|
||||||
|
*/
|
||||||
|
|
||||||
|
public HashMap2D() {
|
||||||
|
mMap = new HashMap<T1, Map<T2, T3>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associates the specified value with the specified keys in this map (optional operation). If the map previously
|
||||||
|
* contained a mapping for the key, the old value is replaced by the specified value.
|
||||||
|
*
|
||||||
|
* @param key1
|
||||||
|
* the first key
|
||||||
|
* @param key2
|
||||||
|
* the second key
|
||||||
|
* @param value
|
||||||
|
* the value to be set
|
||||||
|
* @return the value previously associated with (key1,key2), or <code>null</code> if none
|
||||||
|
* @see Map#put(Object, Object)
|
||||||
|
*/
|
||||||
|
public T3 put(T1 key1, T2 key2, T3 value) {
|
||||||
|
Map<T2, T3> map;
|
||||||
|
if (mMap.containsKey(key1)) {
|
||||||
|
map = mMap.get(key1);
|
||||||
|
} else {
|
||||||
|
map = new HashMap<T2, T3>();
|
||||||
|
mMap.put(key1, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map.put(key2, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value to which the specified key is mapped, or <code>null</code> if this map contains no mapping for
|
||||||
|
* the key.
|
||||||
|
*
|
||||||
|
* @param key1
|
||||||
|
* the first key whose associated value is to be returned
|
||||||
|
* @param key2
|
||||||
|
* the second key whose associated value is to be returned
|
||||||
|
* @return the value to which the specified key is mapped, or <code>null</code> if this map contains no mapping for
|
||||||
|
* the key
|
||||||
|
* @see Map#get(Object)
|
||||||
|
*/
|
||||||
|
public T3 get(T1 key1, T2 key2) {
|
||||||
|
if (mMap.containsKey(key1)) {
|
||||||
|
return mMap.get(key1).get(key2);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> if this map contains a mapping for the specified key
|
||||||
|
*
|
||||||
|
* @param key1
|
||||||
|
* the first key whose presence in this map is to be tested
|
||||||
|
* @param key2
|
||||||
|
* the second key whose presence in this map is to be tested
|
||||||
|
* @return Returns true if this map contains a mapping for the specified key
|
||||||
|
* @see Map#containsKey(Object)
|
||||||
|
*/
|
||||||
|
public boolean containsKeys(T1 key1, T2 key2) {
|
||||||
|
return mMap.containsKey(key1) && mMap.get(key1).containsKey(key2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
mMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package nikedemos.markovnames;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.generators.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static final int GENDER_RANDOM=0;
|
||||||
|
public static final int GENDER_MALE=1;
|
||||||
|
public static final int GENDER_FEMALE=2;
|
||||||
|
|
||||||
|
public static HashMap<String, MarkovGenerator> GENERATORS = new HashMap<String, MarkovGenerator>();
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
//all the generators neatly in one HashMap, so you can iterate or w/e
|
||||||
|
|
||||||
|
GENERATORS.put("ROMAN", new MarkovRoman(3));
|
||||||
|
GENERATORS.put("JAPANESE", new MarkovJapanese(4));
|
||||||
|
GENERATORS.put("SLAVIC", new MarkovSlavic(3));
|
||||||
|
GENERATORS.put("WELSH", new MarkovWelsh(3));
|
||||||
|
GENERATORS.put("SAAMI", new MarkovSaami(3));
|
||||||
|
GENERATORS.put("OLDNORSE", new MarkovOldNorse(4));
|
||||||
|
GENERATORS.put("ANCIENTGREEK", new MarkovAncientGreek(3));
|
||||||
|
GENERATORS.put("AZTEC", new MarkovAztec(3));
|
||||||
|
|
||||||
|
//iterate through generators, generate 5 male and 5 female names, move on to the next
|
||||||
|
Iterator<Entry<String, MarkovGenerator>> g = GENERATORS.entrySet().iterator();
|
||||||
|
|
||||||
|
while (g.hasNext()) {
|
||||||
|
Entry<String, MarkovGenerator> pair = (Entry<String, MarkovGenerator>) g.next();
|
||||||
|
|
||||||
|
System.out.println("==="+pair.getKey()+"===");
|
||||||
|
|
||||||
|
for (int i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
if (i==0)
|
||||||
|
System.out.println("GENTLEMEN-----------");
|
||||||
|
int gender = i<8 ? 1 : 2;
|
||||||
|
String random_name = pair.getValue().fetch(gender);
|
||||||
|
System.out.println(random_name);
|
||||||
|
|
||||||
|
if (i==15) //extra padding
|
||||||
|
System.out.println("\n");
|
||||||
|
else if (i==7) //separate genders
|
||||||
|
System.out.println("LADIES--------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
package nikedemos.markovnames;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovDictionary {
|
||||||
|
private Random rng;
|
||||||
|
private int sequenceLen = 3;
|
||||||
|
|
||||||
|
private HashMap2D<String, String, Integer> occurrences = new HashMap2D<String, String, Integer>();
|
||||||
|
|
||||||
|
public MarkovDictionary(String dictionary, int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
|
||||||
|
try {
|
||||||
|
applyDictionary(dictionary, seqlen);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovDictionary(String dictionary, int seqlen) {
|
||||||
|
this(dictionary, seqlen, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovDictionary(String dictionary) {
|
||||||
|
this(dictionary, 3, new Random()); // 3 is the default, anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovDictionary(String dictionary, Random rng) {
|
||||||
|
this(dictionary, 3, rng); // 3 is the default, anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blatantly copied from EnderIO:
|
||||||
|
// https://github.com/SleepyTrousers/EnderIO/blob/master/enderio-base/src/main/java/crazypants/enderio/base/config/recipes/RecipeFactory.java#L44-L57
|
||||||
|
// Thanks again for your help, Henry Loenwind!
|
||||||
|
|
||||||
|
private InputStream getResource(ResourceLocation resourceLocation) {
|
||||||
|
final ModContainer container = Loader.instance().activeModContainer();
|
||||||
|
if (container != null) {
|
||||||
|
final String resourcePath = String.format("/%s/%s/%s", "assets", resourceLocation.getResourceDomain(),
|
||||||
|
resourceLocation.getResourcePath());
|
||||||
|
InputStream resourceAsStream = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
resourceAsStream = container.getMod().getClass().getResourceAsStream(resourcePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resourceAsStream != null) {
|
||||||
|
return resourceAsStream;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Could not find resource " + resourceLocation);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Failed to find current mod while looking for resource " + resourceLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCapitalized(String str) {
|
||||||
|
if (str == null || str.isEmpty())
|
||||||
|
return str;
|
||||||
|
char[] chars = str.toCharArray();
|
||||||
|
chars[0] = Character.toUpperCase(chars[0]);
|
||||||
|
return new String(chars);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String readFile(String path) throws IOException {
|
||||||
|
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||||
|
return new String(encoded, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementSafe(String str1, String str2) {
|
||||||
|
// so for instance, "_DUP_AUX", "_TOTAL" will count how many "DUP" seqCurrs we have
|
||||||
|
if (occurrences.containsKeys(str1, str2))
|
||||||
|
{
|
||||||
|
int curr = occurrences.get(str1, str2).intValue();
|
||||||
|
occurrences.put(str1, str2, Integer.valueOf(curr + 1));
|
||||||
|
} else {
|
||||||
|
occurrences.put(str1, str2, Integer.valueOf(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateWord() {
|
||||||
|
|
||||||
|
// let's pick the first element, from which further picking shall proceed.
|
||||||
|
// first, we need to know how many top-level sequences (sequenceLen length)
|
||||||
|
// strings
|
||||||
|
// we have. So just take into account those surrounded by "_" - and count them.
|
||||||
|
// From that we'll get the weights.
|
||||||
|
|
||||||
|
int allEntries = 0;
|
||||||
|
|
||||||
|
// first iteration: we count top level entries. There's just no other way.
|
||||||
|
Iterator<Entry<String, Map<String, Integer>>> i = occurrences.mMap.entrySet().iterator();
|
||||||
|
|
||||||
|
while (i.hasNext()) {
|
||||||
|
Entry<String, Map<String, Integer>> pair = (Entry<String, Map<String, Integer>>) i.next();
|
||||||
|
|
||||||
|
String k = pair.getKey();
|
||||||
|
if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here
|
||||||
|
{
|
||||||
|
allEntries += occurrences.get(k, "_TOTAL_");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(allEntries == 0) {
|
||||||
|
return "Kamkeel"; //shouldnt happen
|
||||||
|
}
|
||||||
|
int topLevelEntries;
|
||||||
|
int randomNumber = rng.nextInt(allEntries);
|
||||||
|
|
||||||
|
// ok, so how does this weighted random work?
|
||||||
|
// easy. Check if the randomNumber is LESS than
|
||||||
|
// topLevelEntries variable for that entry (see below).
|
||||||
|
// If it is, break the while loop - we got our first element,
|
||||||
|
// from which we will go further. Just remember to
|
||||||
|
// remove the underscores at both ends!
|
||||||
|
|
||||||
|
Iterator<Entry<String, Map<String, Integer>>> it = occurrences.mMap.entrySet().iterator();
|
||||||
|
|
||||||
|
StringBuilder sequence = new StringBuilder("");
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Entry<String, Map<String, Integer>> pair = (Entry<String, Map<String, Integer>>) it.next();
|
||||||
|
|
||||||
|
String k = pair.getKey();
|
||||||
|
|
||||||
|
if (k.startsWith("_[") && k.endsWith("_")) // dealing with meta entry here
|
||||||
|
{
|
||||||
|
topLevelEntries = occurrences.get(k, "_TOTAL_");
|
||||||
|
|
||||||
|
if (randomNumber < topLevelEntries) {
|
||||||
|
sequence.append(k.substring(1, sequenceLen + 1)); // removing the underscores
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// keep going
|
||||||
|
randomNumber -= topLevelEntries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// great! now that we have the first element, time for some generic iterations.
|
||||||
|
// in a very similar manner. Basically - perform this loop till you encounter
|
||||||
|
// "]" at the end
|
||||||
|
StringBuilder word = new StringBuilder("");
|
||||||
|
|
||||||
|
word.append(sequence); // now we're gonna use firstElement to keep the sequence
|
||||||
|
while (sequence.charAt(sequence.length() - 1) != ']') {
|
||||||
|
// sequence is now your HashMap key for the 1st dimension.
|
||||||
|
// for that sequence:
|
||||||
|
// - get total elements that are not meta (not surrounded by underscores)
|
||||||
|
// and count their total occurrences
|
||||||
|
int subSize = 0;
|
||||||
|
|
||||||
|
Iterator<Entry<String, Integer>> j = occurrences.mMap.get(sequence.toString()).entrySet().iterator();
|
||||||
|
|
||||||
|
while (j.hasNext()) {
|
||||||
|
Entry<String, Integer> entry = j.next();
|
||||||
|
subSize += entry.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// and now, the last iterator, with a random, just like before
|
||||||
|
randomNumber = rng.nextInt(subSize);
|
||||||
|
|
||||||
|
Iterator<Entry<String, Integer>> k = occurrences.mMap.get(sequence.toString()).entrySet().iterator();
|
||||||
|
|
||||||
|
String chosen = "";
|
||||||
|
|
||||||
|
while (k.hasNext()) {
|
||||||
|
Entry<String, Integer> entry = k.next();
|
||||||
|
int occu = occurrences.get(sequence.toString(), entry.getKey());
|
||||||
|
|
||||||
|
if (randomNumber < occu) {
|
||||||
|
chosen = entry.getKey();
|
||||||
|
break;
|
||||||
|
} else { // keep going!
|
||||||
|
randomNumber -= occu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now, append the word...
|
||||||
|
word.append(chosen);
|
||||||
|
|
||||||
|
// delete the first character of the sequence,
|
||||||
|
// and also append it with chosen character.
|
||||||
|
// So if the Sequence is ABC, and chosen is D,
|
||||||
|
// it now becomes BCD.
|
||||||
|
sequence.delete(0, 1);
|
||||||
|
sequence.append(chosen);
|
||||||
|
// System.out.println("FINAL: "+sequence);
|
||||||
|
// System.out.println("CHOSEN: "+chosen);
|
||||||
|
|
||||||
|
}
|
||||||
|
// and now remove the square brackets surrounding it.
|
||||||
|
return this.getPost(word.substring(1, word.length() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPost(String str) {
|
||||||
|
return getCapitalized(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyDictionary(String dictionaryFile, int seqLen) throws IOException {
|
||||||
|
StringBuilder input = new StringBuilder();
|
||||||
|
|
||||||
|
ResourceLocation resource = new ResourceLocation("customnpcs:markovnames/" + dictionaryFile);
|
||||||
|
|
||||||
|
BufferedReader readIn = new BufferedReader(new InputStreamReader(getResource(resource), "UTF-8"));
|
||||||
|
// Thread.currentThread().getContextClassLoader().getResourceAsStream("path/to/resource/file.ext");
|
||||||
|
|
||||||
|
for (String line = readIn.readLine(); line != null; line = readIn.readLine()) {
|
||||||
|
input.append(line).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
readIn.close();
|
||||||
|
|
||||||
|
if (input.length() == 0) {
|
||||||
|
throw new RuntimeException("Resource was empty: + " + resource);
|
||||||
|
}
|
||||||
|
// if seqLen != this.sequenceLen, we must clear occurrences
|
||||||
|
|
||||||
|
if (this.sequenceLen != seqLen) {
|
||||||
|
sequenceLen = seqLen;
|
||||||
|
this.occurrences.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
String input_str = '[' + input.toString().toLowerCase().replaceAll("[\\t\\n\\r\\s]+", "][") + ']';
|
||||||
|
|
||||||
|
int maxCursorPos = input_str.length() - 1 - sequenceLen;
|
||||||
|
|
||||||
|
for (int i = 0; i <= maxCursorPos; i++) {
|
||||||
|
String seqCurr = input_str.substring(i, i + (sequenceLen)); // i plus 2 characters next to it
|
||||||
|
String seqNext = input_str.substring(i + sequenceLen, i + sequenceLen + 1); // next character after that
|
||||||
|
incrementSafe(seqCurr, seqNext);
|
||||||
|
// aux counters
|
||||||
|
|
||||||
|
StringBuilder meta = new StringBuilder("_").append(seqCurr).append("_");
|
||||||
|
|
||||||
|
// String aux1="_"+seqCurr+"_";
|
||||||
|
incrementSafe(meta.toString(), "_TOTAL_");
|
||||||
|
// String aux2="_"+seqNext+"_";
|
||||||
|
// incrementSafe(aux1, aux2);
|
||||||
|
|
||||||
|
// debug, feel free to uncomment
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System.out.println("<"+seqCurr+"><"+seqNext+"> => "+occurrences.get(seqCurr,
|
||||||
|
* seqNext));
|
||||||
|
* System.out.println("<"+aux1+"><"+"_TOTAL_"+"> => "+occurrences.get(aux1,
|
||||||
|
* "_TOTAL_"));
|
||||||
|
* System.out.println("<"+aux1+"><"+aux2+"> => "+occurrences.get(aux1, aux2));
|
||||||
|
* System.out.println("");
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
// by now, we should have
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package nikedemos.markovnames;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
//used exclusively by the Spanish surname dictionary - because the capitalization is a little bit different
|
||||||
|
public class MarkovDictionarySPA extends MarkovDictionary {
|
||||||
|
|
||||||
|
public MarkovDictionarySPA(String dictionary, int seqlen, Random rng) {
|
||||||
|
super(dictionary, seqlen, rng);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPost(String str) {
|
||||||
|
return getCapitalizedSPA(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCapitalizedSPA(String str) {
|
||||||
|
// for spanish capitalization
|
||||||
|
|
||||||
|
String[] parts = str.split("#");
|
||||||
|
|
||||||
|
StringBuilder build = new StringBuilder("");
|
||||||
|
|
||||||
|
for (int p = 0; p < parts.length; p++) {
|
||||||
|
// capitalize this part, but only if it's not "de", "del", "la" or "los"
|
||||||
|
if (!parts[p].equals("de") && !parts[p].equals("del") && !parts[p].equals("la")
|
||||||
|
&& !parts[p].equals("los")) {
|
||||||
|
parts[p] = getCapitalized(parts[p]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p > 0) // don't add spaces before the first part
|
||||||
|
build.append(" ");
|
||||||
|
|
||||||
|
build.append(parts[p]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return build.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovAncientGreek extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
|
||||||
|
public MarkovAncientGreek(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("ancient_greek_male.txt",seqlen,rng);
|
||||||
|
this.markov2 = new MarkovDictionary("ancient_greek_female.txt",seqlen,rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovAncientGreek(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen,new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovAncientGreek()
|
||||||
|
{
|
||||||
|
this(3, new Random()); //3 seems best-suited for Welsh
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender)
|
||||||
|
{
|
||||||
|
|
||||||
|
String seq1;
|
||||||
|
|
||||||
|
//check the gender.
|
||||||
|
//0 = random gender, 1 = male, 2 = female
|
||||||
|
//if there's no gender specified (0),
|
||||||
|
//now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender==0)
|
||||||
|
{
|
||||||
|
gender = rng.nextBoolean()==true? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//now if it's 2 - a lady - feminize the 3 sequences
|
||||||
|
if (gender==2)
|
||||||
|
{
|
||||||
|
seq1 = markov2.generateWord();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
seq1 = markov.generateWord();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return seq1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovAztec extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovAztec(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("aztec_given.txt",seqlen,rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovAztec(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen,new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovAztec()
|
||||||
|
{
|
||||||
|
this(3, new Random()); //3 seems best-suited for Aztec
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) //Aztec names are genderless
|
||||||
|
{
|
||||||
|
return markov.generateWord();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/* This implementation is made specifically for
|
||||||
|
* CustomNPCs, one of the best Minecraft mods ever...
|
||||||
|
* I'm a huge fan and would recommend it to anyone.
|
||||||
|
* Check it out if you haven't yet, at
|
||||||
|
* http://www.kodevelopment.nl/minecraft/category/customnpcs/
|
||||||
|
* Minecraft 1.12.2 Java Edition + Forge required.
|
||||||
|
* Also, you have to like cats, it's in CNPCs EULA, I'm quite sure
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MarkovCustomNPCsClassic extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovCustomNPCsClassic(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("customnpcs_classic.txt",seqlen,rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovCustomNPCsClassic(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen,new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovCustomNPCsClassic()
|
||||||
|
{
|
||||||
|
this(3, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender)
|
||||||
|
{
|
||||||
|
return markov.generateWord();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovDictionary markov;
|
||||||
|
public Random rng;
|
||||||
|
public String name;
|
||||||
|
public String symbol;
|
||||||
|
|
||||||
|
public MarkovGenerator(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovGenerator(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovGenerator()
|
||||||
|
{
|
||||||
|
this(3, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String fetch(int gender) {
|
||||||
|
return stylize(markov.generateWord());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String fetch()
|
||||||
|
{
|
||||||
|
return fetch(0); //0 = random gender, 1 = male, 2 = female
|
||||||
|
}
|
||||||
|
|
||||||
|
public String stylize(String str)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String feminize(String element, boolean flag) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovJapanese extends MarkovGenerator {
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
public MarkovDictionary markov3;
|
||||||
|
|
||||||
|
public MarkovJapanese(int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("japanese_surnames.txt", seqlen, rng);
|
||||||
|
this.markov2 = new MarkovDictionary("japanese_given_male.txt", seqlen, rng);
|
||||||
|
this.markov3 = new MarkovDictionary("japanese_given_female.txt", seqlen, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovJapanese(int seqlen) {
|
||||||
|
this(seqlen, new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovJapanese() {
|
||||||
|
this(4, new Random()); // 4 seems best suited for Japanese
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) {
|
||||||
|
|
||||||
|
StringBuilder name = new StringBuilder(markov.generateWord());
|
||||||
|
name.append(" ");
|
||||||
|
|
||||||
|
// check the gender.
|
||||||
|
// 0 = random gender, 1 = male, 2 = female
|
||||||
|
// if there's no gender specified (0),
|
||||||
|
// now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender == 0) {
|
||||||
|
gender = rng.nextBoolean() == true ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gender == 2) {
|
||||||
|
name.append(markov3.generateWord());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name.append(markov2.generateWord());
|
||||||
|
}
|
||||||
|
|
||||||
|
return name.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovOldNorse extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
|
||||||
|
public MarkovOldNorse(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("old_norse_bothgenders.txt",seqlen,rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovOldNorse(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen,new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovOldNorse()
|
||||||
|
{
|
||||||
|
this(4, new Random()); //4 seems best-suited for Old Norse
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) //Old Norse names are genderless
|
||||||
|
{
|
||||||
|
return markov.generateWord();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovRoman extends MarkovGenerator {
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
public MarkovDictionary markov3;
|
||||||
|
|
||||||
|
public MarkovRoman(int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("roman_praenomina.txt", seqlen, rng);
|
||||||
|
this.markov2 = new MarkovDictionary("roman_nomina.txt", seqlen, rng);
|
||||||
|
this.markov3 = new MarkovDictionary("roman_cognomina.txt", seqlen, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovRoman(int seqlen) {
|
||||||
|
this(seqlen, new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovRoman() {
|
||||||
|
this(3, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String feminize(String element, boolean flag) {
|
||||||
|
// change "us" into "a" and "o" at the end into "a"
|
||||||
|
if (element.endsWith("us")) {
|
||||||
|
element = element.substring(0, element.length() - 2) + "a";
|
||||||
|
}
|
||||||
|
else if (element.endsWith("o")) {
|
||||||
|
element = element.substring(0, element.length() - 2) + "a";
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) {
|
||||||
|
|
||||||
|
String seq1 = markov.generateWord();
|
||||||
|
String seq2 = markov2.generateWord();
|
||||||
|
String seq3 = markov3.generateWord();
|
||||||
|
|
||||||
|
// check the gender.
|
||||||
|
// 0 = random gender, 1 = male, 2 = female
|
||||||
|
// if there's no gender specified (0),
|
||||||
|
// now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender == 0) {
|
||||||
|
gender = rng.nextBoolean() == true ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now if it's 2 - a lady - feminize the 3 sequences
|
||||||
|
if (gender == 2) {
|
||||||
|
seq1 = feminize(seq1, false);
|
||||||
|
seq2 = feminize(seq2, false);
|
||||||
|
seq3 = feminize(seq3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new StringBuilder(seq1).append(" ").append(seq2).append(" ").append(seq3).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovSaami extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
|
||||||
|
public MarkovSaami(int seqlen, Random rng)
|
||||||
|
{
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("saami_bothgenders.txt",seqlen,rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSaami(int seqlen)
|
||||||
|
{
|
||||||
|
this(seqlen,new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSaami()
|
||||||
|
{
|
||||||
|
this(3, new Random()); //3 seems best-suited for Saami
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) //Saami names are genderless
|
||||||
|
{
|
||||||
|
return markov.generateWord();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovSlavic extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovSlavic(int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("slavic_given.txt", seqlen, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSlavic(int seqlen) {
|
||||||
|
this(seqlen, new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSlavic() {
|
||||||
|
this(3, new Random()); // 3 seems best-suited for Slavic
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String feminize(String element, boolean flag) {
|
||||||
|
// add "a" at the end, if there isn't one
|
||||||
|
String lastChar = element.substring(element.length() - 1);
|
||||||
|
|
||||||
|
if (element.endsWith("o")) {
|
||||||
|
element = element.substring(0, element.length() - 1) + "a";
|
||||||
|
}
|
||||||
|
else if (!lastChar.endsWith("a")) {
|
||||||
|
element += "a";
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) {
|
||||||
|
|
||||||
|
String seq1 = markov.generateWord();
|
||||||
|
|
||||||
|
// check the gender.
|
||||||
|
// 0 = random gender, 1 = male, 2 = female
|
||||||
|
// if there's no gender specified (0),
|
||||||
|
// now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender == 0) {
|
||||||
|
gender = rng.nextBoolean() == true ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now if it's 2 - a lady - feminize the 3 sequences
|
||||||
|
if (gender == 2) {
|
||||||
|
seq1 = feminize(seq1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return seq1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
import nikedemos.markovnames.MarkovDictionarySPA;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovSpanish extends MarkovGenerator {
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
public MarkovDictionary markov3;
|
||||||
|
|
||||||
|
public MarkovSpanish(int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("spanish_given_male.txt", seqlen, rng);
|
||||||
|
this.markov2 = new MarkovDictionary("spanish_given_female.txt", seqlen, rng);
|
||||||
|
this.markov3 = new MarkovDictionarySPA("spanish_surnames.txt", seqlen, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSpanish(int seqlen) {
|
||||||
|
this(seqlen, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovSpanish() {
|
||||||
|
this(3, new Random());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) {
|
||||||
|
String giv = "";
|
||||||
|
|
||||||
|
String sur = markov3.generateWord();
|
||||||
|
|
||||||
|
// check the gender.
|
||||||
|
// 0 = random gender, 1 = male, 2 = female
|
||||||
|
// if there's no gender specified (0),
|
||||||
|
// now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender == 0) {
|
||||||
|
gender = rng.nextBoolean() == true ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gender == 1) {
|
||||||
|
giv = markov.generateWord();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
giv = markov2.generateWord();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StringBuilder(giv).append(" ").append(sur).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package nikedemos.markovnames.generators;
|
||||||
|
|
||||||
|
import nikedemos.markovnames.MarkovDictionary;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MarkovWelsh extends MarkovGenerator {
|
||||||
|
|
||||||
|
public MarkovDictionary markov2;
|
||||||
|
|
||||||
|
public MarkovWelsh(int seqlen, Random rng) {
|
||||||
|
this.rng = rng;
|
||||||
|
this.markov = new MarkovDictionary("welsh_male.txt", seqlen, rng);
|
||||||
|
this.markov2 = new MarkovDictionary("welsh_female.txt", seqlen, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovWelsh(int seqlen) {
|
||||||
|
this(seqlen, new Random());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkovWelsh() {
|
||||||
|
this(3, new Random()); // 3 seems best-suited for Welsh
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fetch(int gender) {
|
||||||
|
|
||||||
|
String seq1;
|
||||||
|
|
||||||
|
// check the gender.
|
||||||
|
// 0 = random gender, 1 = male, 2 = female
|
||||||
|
// if there's no gender specified (0),
|
||||||
|
// now it's time to pick it at random
|
||||||
|
//
|
||||||
|
if (gender == 0) {
|
||||||
|
gender = rng.nextBoolean() == true ? 1 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now if it's 2 - a lady - feminize the 3 sequences
|
||||||
|
if (gender == 2) {
|
||||||
|
seq1 = markov2.generateWord();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
seq1 = markov.generateWord();
|
||||||
|
}
|
||||||
|
|
||||||
|
return seq1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,32 +4,19 @@ import net.minecraft.client.model.ModelBiped;
|
|||||||
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.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.InventoryBasic;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.stats.Achievement;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.containers.ContainerCarpentryBench;
|
import noppes.npcs.containers.*;
|
||||||
import noppes.npcs.containers.ContainerCrate;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.containers.ContainerMail;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.containers.ContainerManageBanks;
|
|
||||||
import noppes.npcs.containers.ContainerManageRecipes;
|
|
||||||
import noppes.npcs.containers.ContainerMerchantAdd;
|
|
||||||
import noppes.npcs.containers.ContainerNPCBankLarge;
|
|
||||||
import noppes.npcs.containers.ContainerNPCBankSmall;
|
|
||||||
import noppes.npcs.containers.ContainerNPCBankUnlock;
|
|
||||||
import noppes.npcs.containers.ContainerNPCBankUpgrade;
|
|
||||||
import noppes.npcs.containers.ContainerNPCCompanion;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollower;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollowerHire;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollowerSetup;
|
|
||||||
import noppes.npcs.containers.ContainerNPCInv;
|
|
||||||
import noppes.npcs.containers.ContainerNPCTrader;
|
|
||||||
import noppes.npcs.containers.ContainerNPCTraderSetup;
|
|
||||||
import noppes.npcs.containers.ContainerNpcItemGiver;
|
|
||||||
import noppes.npcs.containers.ContainerNpcQuestReward;
|
|
||||||
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
|
||||||
public class CommonProxy implements IGuiHandler {
|
public class CommonProxy implements IGuiHandler {
|
||||||
|
|
||||||
@@ -41,6 +28,10 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerData getPlayerData(EntityPlayer player) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
if(ID > EnumGuiType.values().length)
|
if(ID > EnumGuiType.values().length)
|
||||||
@@ -50,6 +41,9 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
return getContainer(gui, player, x, y, z, npc);
|
return getContainer(gui, player, x, y, z, npc);
|
||||||
}
|
}
|
||||||
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
|
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
|
||||||
|
if(gui == EnumGuiType.CustomGui)
|
||||||
|
return new ContainerCustomGui(new InventoryBasic("", false, x));
|
||||||
|
|
||||||
if(gui == EnumGuiType.MainMenuInv)
|
if(gui == EnumGuiType.MainMenuInv)
|
||||||
return new ContainerNPCInv(npc, player);
|
return new ContainerNPCInv(npc, player);
|
||||||
|
|
||||||
@@ -142,6 +136,8 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FakePlayer getCommandPlayer(IWorld world) { return null; }
|
||||||
|
|
||||||
public boolean hasClient() {
|
public boolean hasClient() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -160,8 +156,15 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawnParticle(String particle, double x, double y, double z,
|
public void spawnParticle(String particle, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float scale) {
|
double motionX, double motionY, double motionZ, float scale) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAchievementDesc(Achievement achievement) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGUIOpen(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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,21 +1,16 @@
|
|||||||
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;
|
||||||
import cpw.mods.fml.common.SidedProxy;
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.*;
|
||||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
|
||||||
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
|
||||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|
||||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
|
||||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||||
import foxz.command.CommandNoppes;
|
import foxz.command.CommandNoppes;
|
||||||
|
import luizotavio.compressor.executor.IOExecutor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockIce;
|
import net.minecraft.block.BlockIce;
|
||||||
import net.minecraft.block.BlockLeavesBase;
|
import net.minecraft.block.BlockLeavesBase;
|
||||||
@@ -26,57 +21,56 @@ import net.minecraft.entity.EntityList;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
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.scripted.wrapper.WrapperNpcAPI;
|
||||||
import noppes.npcs.entity.old.EntityNPCElfFemale;
|
import java.io.File;
|
||||||
import noppes.npcs.entity.old.EntityNPCElfMale;
|
import java.util.Set;
|
||||||
import noppes.npcs.entity.old.EntityNPCEnderman;
|
import java.util.concurrent.Executors;
|
||||||
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;
|
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.7.10f")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.3")
|
||||||
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 = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server")
|
@ConfigProp(info = "*BACKUP BEFORE CHANGING* File Type used with PlayerData. Converting files may reduce lag. To convert existing files: /noppes compressor update [<filename>|all] [json|zstd]")
|
||||||
|
public static String CompressorType = "json";
|
||||||
|
|
||||||
|
@ConfigProp(info = "The size of IO executors used for compression and decompression. This is the number of threads used for compression and decompression. If you are experiencing issues with the server lagging/crashing, try changing this to a higher number.")
|
||||||
|
public static int CompressorThreads = 2;
|
||||||
|
|
||||||
|
@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.")
|
||||||
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;
|
||||||
|
|
||||||
@@ -142,6 +136,8 @@ public class CustomNpcs {
|
|||||||
|
|
||||||
public static ConfigLoader Config;
|
public static ConfigLoader Config;
|
||||||
|
|
||||||
|
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
||||||
|
|
||||||
public CustomNpcs() {
|
public CustomNpcs() {
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
@@ -167,6 +163,16 @@ public class CustomNpcs {
|
|||||||
if (NpcNavRange < 16) {
|
if (NpcNavRange < 16) {
|
||||||
NpcNavRange = 16;
|
NpcNavRange = 16;
|
||||||
}
|
}
|
||||||
|
if (NpcNavRange > 96) {
|
||||||
|
NpcNavRange = 96;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NpcSizeLimit < 1)
|
||||||
|
NpcSizeLimit = 1;
|
||||||
|
|
||||||
|
if(PlayerQuestCheck < 1)
|
||||||
|
PlayerQuestCheck = 1;
|
||||||
|
|
||||||
EnchantInterface.load();
|
EnchantInterface.load();
|
||||||
CustomItems.load();
|
CustomItems.load();
|
||||||
|
|
||||||
@@ -176,6 +182,14 @@ public class CustomNpcs {
|
|||||||
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
|
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new ScriptController());
|
MinecraftForge.EVENT_BUS.register(new ScriptController());
|
||||||
|
|
||||||
|
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
|
||||||
|
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
|
||||||
|
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler);
|
||||||
|
|
||||||
|
ScriptForgeEventHandler forgeEventHandler = (new ScriptForgeEventHandler()).registerForgeEvents();
|
||||||
|
MinecraftForge.EVENT_BUS.register(forgeEventHandler);
|
||||||
|
FMLCommonHandler.instance().bus().register(forgeEventHandler);
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
|
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
|
||||||
|
|
||||||
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
|
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
|
||||||
@@ -203,7 +217,12 @@ public class CustomNpcs {
|
|||||||
registerNpc(EntityNPCGolem.class, "npcGolem");
|
registerNpc(EntityNPCGolem.class, "npcGolem");
|
||||||
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
||||||
|
|
||||||
|
IOExecutor.IO_EXECUTOR = Executors.newFixedThreadPool(
|
||||||
|
CompressorThreads,
|
||||||
|
new ThreadFactoryBuilder()
|
||||||
|
.setNameFormat("CustomNpcs-IO-%d")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
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);
|
||||||
@@ -218,6 +237,22 @@ public class CustomNpcs {
|
|||||||
PixelmonHelper.load();
|
PixelmonHelper.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void load(FMLInitializationEvent ev) {
|
||||||
|
|
||||||
|
MARKOV_GENERATOR[0] = new MarkovRoman(3);
|
||||||
|
MARKOV_GENERATOR[1] = new MarkovJapanese(4);
|
||||||
|
MARKOV_GENERATOR[2] = new MarkovSlavic(3);
|
||||||
|
MARKOV_GENERATOR[3] = new MarkovWelsh(3);
|
||||||
|
MARKOV_GENERATOR[4] = new MarkovSaami(3);
|
||||||
|
MARKOV_GENERATOR[5] = new MarkovOldNorse(4);
|
||||||
|
MARKOV_GENERATOR[6] = new MarkovAncientGreek(3);
|
||||||
|
MARKOV_GENERATOR[7] = new MarkovAztec(3);
|
||||||
|
MARKOV_GENERATOR[8] = new MarkovCustomNPCsClassic(3);
|
||||||
|
MARKOV_GENERATOR[9] = new MarkovSpanish(3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void setAboutToStart(FMLServerAboutToStartEvent event) {
|
public void setAboutToStart(FMLServerAboutToStartEvent event) {
|
||||||
ChunkController.instance.clear();
|
ChunkController.instance.clear();
|
||||||
@@ -229,7 +264,11 @@ public class CustomNpcs {
|
|||||||
new SpawnController();
|
new SpawnController();
|
||||||
new LinkedNpcController();
|
new LinkedNpcController();
|
||||||
ScriptController.Instance.loadStoredData();
|
ScriptController.Instance.loadStoredData();
|
||||||
|
ScriptController.Instance.loadForgeScripts();
|
||||||
|
ScriptController.Instance.loadNPCScripts();
|
||||||
|
ScriptController.Instance.loadPlayerScripts();
|
||||||
ScriptController.HasStart = false;
|
ScriptController.HasStart = false;
|
||||||
|
WrapperNpcAPI.clearCache();
|
||||||
|
|
||||||
Set<String> names = Block.blockRegistry.getKeys();
|
Set<String> names = Block.blockRegistry.getKeys();
|
||||||
for(String name : names){
|
for(String name : names){
|
||||||
@@ -293,4 +332,33 @@ public class CustomNpcs {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getWorldSaveDirectory(String s) {
|
||||||
|
try {
|
||||||
|
File dir = new File(".");
|
||||||
|
if (getServer() != null) {
|
||||||
|
if (!getServer().isDedicatedServer()) {
|
||||||
|
dir = new File(Minecraft.getMinecraft().mcDataDir, "saves");
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = new File(new File(dir, getServer().getFolderName()), "customnpcs");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s != null) {
|
||||||
|
dir = new File(dir, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
} catch (Exception var2) {
|
||||||
|
LogWriter.error("Error getting worldsave", var2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MinecraftServer getServer(){
|
||||||
|
return MinecraftServer.getServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ import noppes.npcs.constants.EnumStandingType;
|
|||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class DataAI {
|
public class DataAI {
|
||||||
private EntityNPCInterface npc;
|
private EntityNPCInterface npc;
|
||||||
|
|
||||||
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
|
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
|
||||||
public int doorInteract = 2;
|
public int doorInteract = 2;
|
||||||
@@ -33,6 +33,13 @@ public class DataAI {
|
|||||||
public int useRangeMelee = 0;
|
public int useRangeMelee = 0;
|
||||||
public int tacticalRadius = 8;
|
public int tacticalRadius = 8;
|
||||||
|
|
||||||
|
// Fly Change
|
||||||
|
public int movementType = 0;
|
||||||
|
public double flySpeed = 1.0D;
|
||||||
|
public double flyGravity = 0.0D;
|
||||||
|
public boolean hasFlyLimit = true;
|
||||||
|
public int flyHeightLimit = 2;
|
||||||
|
|
||||||
public EnumAnimation animationType = EnumAnimation.NONE;
|
public EnumAnimation animationType = EnumAnimation.NONE;
|
||||||
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
||||||
public EnumMovingType movingType = EnumMovingType.Standing;
|
public EnumMovingType movingType = EnumMovingType.Standing;
|
||||||
@@ -94,6 +101,27 @@ public class DataAI {
|
|||||||
movingPos = compound.getInteger("MovingPos");
|
movingPos = compound.getInteger("MovingPos");
|
||||||
movingPattern = compound.getInteger("MovingPatern");
|
movingPattern = compound.getInteger("MovingPatern");
|
||||||
|
|
||||||
|
movementType = compound.getInteger("MovingType");
|
||||||
|
if(!compound.hasKey("FlySpeed"))
|
||||||
|
flySpeed = 1.0D;
|
||||||
|
else
|
||||||
|
flySpeed = compound.getDouble("FlySpeed");
|
||||||
|
|
||||||
|
if(!compound.hasKey("FlyGravity"))
|
||||||
|
flyGravity = 0.0D;
|
||||||
|
else
|
||||||
|
flyGravity = compound.getDouble("FlyGravity");
|
||||||
|
|
||||||
|
if(!compound.hasKey("HasFlyLimit"))
|
||||||
|
hasFlyLimit = false;
|
||||||
|
else
|
||||||
|
hasFlyLimit = compound.getBoolean("HasFlyLimit");
|
||||||
|
|
||||||
|
if(!compound.hasKey("FlyHeightLimit"))
|
||||||
|
flyHeightLimit = 5;
|
||||||
|
else
|
||||||
|
flyHeightLimit = compound.getInteger("FlyHeightLimit");
|
||||||
|
|
||||||
startPos = compound.getIntArray("StartPosNew");
|
startPos = compound.getIntArray("StartPosNew");
|
||||||
if (startPos == null || startPos.length != 3){
|
if (startPos == null || startPos.length != 3){
|
||||||
startPos = new int[] {
|
startPos = new int[] {
|
||||||
@@ -140,6 +168,12 @@ public class DataAI {
|
|||||||
compound.setInteger("MovingPos", movingPos);
|
compound.setInteger("MovingPos", movingPos);
|
||||||
compound.setInteger("MovingPatern", movingPattern);
|
compound.setInteger("MovingPatern", movingPattern);
|
||||||
|
|
||||||
|
compound.setInteger("MovingType", movementType);
|
||||||
|
compound.setDouble("FlySpeed",flySpeed);
|
||||||
|
compound.setDouble("FlyGravity",flyGravity);
|
||||||
|
compound.setBoolean("HasFlyLimit",hasFlyLimit);
|
||||||
|
compound.setInteger("FlyHeightLimit", flyHeightLimit);
|
||||||
|
|
||||||
npc.setAvoidWater(avoidsWater);
|
npc.setAvoidWater(avoidsWater);
|
||||||
|
|
||||||
compound.setIntArray("StartPosNew", npc.getStartPos());
|
compound.setIntArray("StartPosNew", npc.getStartPos());
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
@@ -19,12 +26,15 @@ public class DataDisplay {
|
|||||||
public String name;
|
public String name;
|
||||||
public String title = "";
|
public String title = "";
|
||||||
|
|
||||||
|
private int markovGeneratorId = 8; //roman,japanese,slavic,welsh,sami,oldnorse,ancientgreek,aztec,classic,spanish (0 - 9 inclusively)
|
||||||
|
private int markovGender = 0; //0:random, 1:male, 2:female
|
||||||
|
|
||||||
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
|
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
|
||||||
|
|
||||||
public String url = "";
|
public String url = "";
|
||||||
|
|
||||||
public GameProfile playerProfile;
|
public GameProfile playerProfile;
|
||||||
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";;
|
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";
|
||||||
public String cloakTexture = "";
|
public String cloakTexture = "";
|
||||||
public String glowTexture = "";
|
public String glowTexture = "";
|
||||||
|
|
||||||
@@ -40,35 +50,25 @@ public class DataDisplay {
|
|||||||
|
|
||||||
public byte showBossBar = 0;
|
public byte showBossBar = 0;
|
||||||
|
|
||||||
|
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
||||||
|
|
||||||
|
//0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
|
||||||
|
public int collidesWith = 1;
|
||||||
|
|
||||||
public DataDisplay(EntityNPCInterface npc){
|
public DataDisplay(EntityNPCInterface npc){
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
String[] names = { "Noppes", "Noppes", "Noppes", "Noppes", "Atesson",
|
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||||
"Rothcersul", "Achdranys", "Pegato", "Chald", "Gareld",
|
name = getRandomName();
|
||||||
"Nalworche", "Ineald", "Tia'kim", "Torerod", "Turturdar",
|
}
|
||||||
"Ranler", "Dyntan", "Oldrake", "Gharis", "Elmn", "Tanal",
|
|
||||||
"Waran-ess", "Ach-aldhat", "Athi", "Itageray", "Tasr",
|
public String getRandomName() {
|
||||||
"Ightech", "Gakih", "Adkal", "Qua'an", "Sieq", "Urnp", "Rods",
|
return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender);
|
||||||
"Vorbani", "Smaik", "Fian", "Hir", "Ristai", "Kineth", "Naif",
|
|
||||||
"Issraya", "Arisotura", "Honf", "Rilfom", "Estz", "Ghatroth",
|
|
||||||
"Yosil", "Darage", "Aldny", "Tyltran", "Armos", "Loxiku",
|
|
||||||
"Burhat", "Tinlt", "Ightyd", "Mia",
|
|
||||||
"Ken", "Karla", "Lily", "Carina", "Daniel", "Slater", "Zidane", "Valentine", "Eirina",
|
|
||||||
"Carnow", "Grave", "Shadow", "Drakken", "Kaoz", "Silk", "Drake", "Oldam", "Lynxx", "Lenyx",
|
|
||||||
"Winter", "Seth", "Apolitho", "Amethyst", "Ankin", "Seinkan", "Ayumu", "Sakamoto", "Divina",
|
|
||||||
"Div", "Magia", "Magnus", "Tiakono", "Ruin", "Hailinx", "Ethan", "Wate", "Carter", "William",
|
|
||||||
"Brion", "Sparrow", "Basrrelen", "Gyaku", "Claire", "Crowfeather", "Blackwell", "Raven", "Farcri",
|
|
||||||
"Lucas", "Bangheart", "Kamoku", "Kyoukan", "Blaze", "Benjamin", "Larianne", "Kakaragon",
|
|
||||||
"Melancholy", "Epodyno", "Thanato", "Mika", "Dacks", "Ylander", "Neve", "Meadow", "Cuero",
|
|
||||||
"Embrera", "Eldamore", "Faolan", "Chim", "Nasu", "Kathrine", "Ariel", "Arei", "Demytrix",
|
|
||||||
"Kora", "Ava", "Larson", "Leonardo", "Wyrl", "Sakiama", "Lambton", "Kederath", "Malus", "Riplette",
|
|
||||||
"Andern", "Ezall", "Lucien", "Droco", "Cray", "Tymen", "Zenix", "Entranger",
|
|
||||||
"Saenorath", "Chris", "Christine", "Marble", "Mable", "Ross", "Rose", "Xalgan ", "Kennet", "Kamkeel"
|
|
||||||
};
|
|
||||||
name = names[new Random().nextInt(names.length)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
nbttagcompound.setString("Name", name);
|
nbttagcompound.setString("Name", name);
|
||||||
|
nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId);
|
||||||
|
nbttagcompound.setInteger("MarkovGender", markovGender);
|
||||||
nbttagcompound.setString("Title", title);
|
nbttagcompound.setString("Title", title);
|
||||||
nbttagcompound.setString("SkinUrl", url);
|
nbttagcompound.setString("SkinUrl", url);
|
||||||
nbttagcompound.setString("Texture", texture);
|
nbttagcompound.setString("Texture", texture);
|
||||||
@@ -92,10 +92,22 @@ public class DataDisplay {
|
|||||||
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
||||||
nbttagcompound.setByte("BossBar", showBossBar);
|
nbttagcompound.setByte("BossBar", showBossBar);
|
||||||
|
|
||||||
|
nbttagcompound.setInteger("CollidesWith",collidesWith);
|
||||||
|
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
for(UUID uuid : invisibleToList){
|
||||||
|
list.appendTag(new NBTTagString(uuid.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
nbttagcompound.setTag("InvisibleToList", list);
|
||||||
|
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
public void readToNBT(NBTTagCompound nbttagcompound) {
|
public void readToNBT(NBTTagCompound nbttagcompound) {
|
||||||
name = nbttagcompound.getString("Name");
|
setName(nbttagcompound.getString("Name"));
|
||||||
|
setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId"));
|
||||||
|
setMarkovGender(nbttagcompound.getInteger("MarkovGender"));
|
||||||
|
|
||||||
title = nbttagcompound.getString("Title");
|
title = nbttagcompound.getString("Title");
|
||||||
|
|
||||||
url = nbttagcompound.getString("SkinUrl");
|
url = nbttagcompound.getString("SkinUrl");
|
||||||
@@ -120,7 +132,10 @@ public class DataDisplay {
|
|||||||
cloakTexture = nbttagcompound.getString("CloakTexture");
|
cloakTexture = nbttagcompound.getString("CloakTexture");
|
||||||
glowTexture = nbttagcompound.getString("GlowTexture");
|
glowTexture = nbttagcompound.getString("GlowTexture");
|
||||||
|
|
||||||
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, 40);
|
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");
|
||||||
@@ -129,6 +144,23 @@ public class DataDisplay {
|
|||||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||||
showBossBar = nbttagcompound.getByte("BossBar");
|
showBossBar = nbttagcompound.getByte("BossBar");
|
||||||
|
|
||||||
|
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
||||||
|
if(tagList != null) {
|
||||||
|
invisibleToList.clear();
|
||||||
|
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||||
|
String nbtTagString = tagList.getStringTagAt(i);
|
||||||
|
invisibleToList.add(UUID.fromString(nbtTagString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
invisibleToList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nbttagcompound.hasKey("CollidesWith"))
|
||||||
|
collidesWith = nbttagcompound.getInteger("CollidesWith");
|
||||||
|
else
|
||||||
|
collidesWith = 1;
|
||||||
|
|
||||||
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
||||||
npc.textureLocation = null;
|
npc.textureLocation = null;
|
||||||
npc.textureGlowLocation = null;
|
npc.textureGlowLocation = null;
|
||||||
@@ -173,4 +205,35 @@ public class DataDisplay {
|
|||||||
npc.updateClient = true;
|
npc.updateClient = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name){
|
||||||
|
if(this.name.equals(name))
|
||||||
|
return;
|
||||||
|
this.name = name;
|
||||||
|
npc.updateClient = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarkovGender(){
|
||||||
|
return markovGender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkovGender(int gender) {
|
||||||
|
if(markovGender == gender)
|
||||||
|
return;
|
||||||
|
this.markovGender = ValueUtil.CorrectInt(gender, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMarkovGeneratorId(){
|
||||||
|
return markovGeneratorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkovGeneratorId(int id) {
|
||||||
|
if(markovGeneratorId == id)
|
||||||
|
return;
|
||||||
|
this.markovGeneratorId = ValueUtil.CorrectInt(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
@@ -12,18 +12,23 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.ScriptEvent;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.ScriptNpc;
|
import noppes.npcs.scripted.event.ScriptEvent;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
import noppes.npcs.scripted.ScriptWorld;
|
import noppes.npcs.scripted.ScriptWorld;
|
||||||
import noppes.npcs.scripted.constants.EntityType;
|
import noppes.npcs.scripted.constants.EntityType;
|
||||||
import noppes.npcs.scripted.constants.JobType;
|
import noppes.npcs.scripted.constants.JobType;
|
||||||
import noppes.npcs.scripted.constants.RoleType;
|
import noppes.npcs.scripted.constants.RoleType;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
public class DataScript {
|
public class DataScript implements IScriptHandler {
|
||||||
public Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
|
public List<ScriptContainer> scripts = new ArrayList();
|
||||||
private final static EntityType entities = new EntityType();
|
private final static EntityType entities = new EntityType();
|
||||||
private final static JobType jobs = new JobType();
|
private final static JobType jobs = new JobType();
|
||||||
private final static RoleType roles = new RoleType();
|
private final static RoleType roles = new RoleType();
|
||||||
@@ -32,18 +37,22 @@ public class DataScript {
|
|||||||
private EntityNPCInterface npc;
|
private EntityNPCInterface npc;
|
||||||
public boolean enabled = false;
|
public boolean enabled = false;
|
||||||
|
|
||||||
public ScriptNpc dummyNpc;
|
public ICustomNpc dummyNpc;
|
||||||
public ScriptWorld dummyWorld;
|
public IWorld dummyWorld;
|
||||||
public boolean clientNeedsUpdate = false;
|
public boolean clientNeedsUpdate = false;
|
||||||
public boolean aiNeedsUpdate = false;
|
public boolean aiNeedsUpdate = false;
|
||||||
public boolean hasInited = false;
|
public boolean hasInited = false;
|
||||||
|
|
||||||
public DataScript(EntityNPCInterface npc) {
|
public DataScript(EntityNPCInterface npc) {
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
scripts.add(new ScriptContainer(this));
|
||||||
|
}
|
||||||
|
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
if(npc instanceof EntityCustomNpc)
|
dummyNpc = new ScriptNpc<>(npc);
|
||||||
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
|
|
||||||
if(npc.worldObj instanceof WorldServer)
|
if(npc.worldObj instanceof WorldServer)
|
||||||
dummyWorld = new ScriptWorld((WorldServer) npc.worldObj);
|
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
@@ -59,21 +68,25 @@ public class DataScript {
|
|||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer,ScriptContainer> readScript(NBTTagList list){
|
private List<ScriptContainer> readScript(NBTTagList list){
|
||||||
Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
|
List<ScriptContainer> scripts = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
scripts.add(new ScriptContainer(this));
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < list.tagCount(); i++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||||
ScriptContainer script = new ScriptContainer();
|
ScriptContainer script = new ScriptContainer(this);
|
||||||
script.readFromNBT(compoundd);
|
script.readFromNBT(compoundd);
|
||||||
if(script.hasCode() || npc.isRemote())
|
if(script.hasCode() || npc.isRemote())
|
||||||
scripts.put(compoundd.getInteger("Type"), script);
|
scripts.set(compoundd.getInteger("Type"), script);
|
||||||
}
|
}
|
||||||
return scripts;
|
return scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NBTTagList writeScript(Map<Integer,ScriptContainer> scripts){
|
private NBTTagList writeScript(List<ScriptContainer> scripts){
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
for(Integer type : scripts.keySet()){
|
for(int type = 0; type < scripts.size(); type++){
|
||||||
NBTTagCompound compoundd = new NBTTagCompound();
|
NBTTagCompound compoundd = new NBTTagCompound();
|
||||||
compoundd.setInteger("Type", type);
|
compoundd.setInteger("Type", type);
|
||||||
ScriptContainer script = scripts.get(type);
|
ScriptContainer script = scripts.get(type);
|
||||||
@@ -96,6 +109,7 @@ public class DataScript {
|
|||||||
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());
|
||||||
@@ -114,10 +128,6 @@ public class DataScript {
|
|||||||
return callScript(script);
|
return callScript(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled(){
|
|
||||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean callScript(ScriptContainer script){
|
private boolean callScript(ScriptContainer script){
|
||||||
ScriptEngine engine = script.engine;
|
ScriptEngine engine = script.engine;
|
||||||
engine.put("npc", dummyNpc);
|
engine.put("npc", dummyNpc);
|
||||||
@@ -125,6 +135,7 @@ public class DataScript {
|
|||||||
ScriptEvent result = (ScriptEvent) engine.get("event");
|
ScriptEvent result = (ScriptEvent) engine.get("event");
|
||||||
if(result == null)
|
if(result == null)
|
||||||
engine.put("event", result = new ScriptEvent());
|
engine.put("event", result = new ScriptEvent());
|
||||||
|
engine.put("API", new WrapperNpcAPI());
|
||||||
engine.put("EntityType", entities);
|
engine.put("EntityType", entities);
|
||||||
engine.put("RoleType", roles);
|
engine.put("RoleType", roles);
|
||||||
engine.put("JobType", jobs);
|
engine.put("JobType", jobs);
|
||||||
@@ -141,6 +152,78 @@ public class DataScript {
|
|||||||
return result.isCancelled();
|
return result.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled(){
|
||||||
|
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
Map<Long, String> map = new TreeMap();
|
||||||
|
int tab = 0;
|
||||||
|
Iterator var3 = this.getScripts().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var3.next();
|
||||||
|
++tab;
|
||||||
|
Iterator var5 = script.console.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var5.hasNext()) {
|
||||||
|
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
|
||||||
|
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearConsole() {
|
||||||
|
Iterator var1 = this.getScripts().iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var1.next();
|
||||||
|
script.console.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callScript(EnumScriptType var1, Event var2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClient() {
|
||||||
|
return this.npc.isRemote();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean bo) {
|
||||||
|
this.enabled = bo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return this.scriptLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLanguage(String lang) {
|
||||||
|
this.scriptLanguage = lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ScriptContainer> getScripts() {
|
||||||
|
return this.scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String noticeString() {
|
||||||
|
//BlockPos pos = this.npc.func_180425_c();
|
||||||
|
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public void setWorld(World world) {
|
public void setWorld(World world) {
|
||||||
if(world instanceof WorldServer)
|
if(world instanceof WorldServer)
|
||||||
dummyWorld = new ScriptWorld((WorldServer) world);
|
dummyWorld = new ScriptWorld((WorldServer) world);
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ import noppes.npcs.constants.EnumPotionType;
|
|||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.util.ValueUtil;
|
import noppes.npcs.util.ValueUtil;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class DataStats {
|
public class DataStats {
|
||||||
|
|
||||||
private int attackStrength = 5;
|
private float attackStrength = 5;
|
||||||
public int attackSpeed = 20, attackRange = 2, knockback = 0;
|
public int attackSpeed = 20, attackRange = 2, knockback = 0;
|
||||||
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
|
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
|
||||||
public int aggroRange = 16;
|
public int aggroRange = 16;
|
||||||
@@ -19,7 +22,7 @@ public class DataStats {
|
|||||||
public int potionDuration = 5; //20 = 1 second
|
public int potionDuration = 5; //20 = 1 second
|
||||||
public int potionAmp = 0;
|
public int potionAmp = 0;
|
||||||
|
|
||||||
public int maxHealth = 20;
|
public double maxHealth = 20;
|
||||||
public int respawnTime = 20;
|
public int respawnTime = 20;
|
||||||
public int spawnCycle = 0;
|
public int spawnCycle = 0;
|
||||||
public boolean hideKilledBody = false;
|
public boolean hideKilledBody = false;
|
||||||
@@ -32,10 +35,11 @@ public class DataStats {
|
|||||||
public boolean canDrown = true;
|
public boolean canDrown = true;
|
||||||
public boolean burnInSun = false;
|
public boolean burnInSun = false;
|
||||||
public boolean noFallDamage = false;
|
public boolean noFallDamage = false;
|
||||||
public int healthRegen = 1;
|
public float healthRegen = 1;
|
||||||
public int combatRegen = 0;
|
public float combatRegen = 0;
|
||||||
|
|
||||||
public int pDamage = 4, pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
|
public float pDamage = 4;
|
||||||
|
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
|
||||||
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
||||||
public boolean pRender3D = false, pSpin = false, pStick = false;
|
public boolean pRender3D = false, pSpin = false, pStick = false;
|
||||||
public EnumPotionType pEffect = EnumPotionType.None;
|
public EnumPotionType pEffect = EnumPotionType.None;
|
||||||
@@ -55,16 +59,16 @@ public class DataStats {
|
|||||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
compound.setTag("Resistances", resistances.writeToNBT());
|
compound.setTag("Resistances", resistances.writeToNBT());
|
||||||
compound.setInteger("MaxHealth", maxHealth);
|
compound.setDouble("MaxHealth", maxHealth);
|
||||||
compound.setInteger("AggroRange", aggroRange);
|
compound.setInteger("AggroRange", aggroRange);
|
||||||
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
|
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
|
||||||
compound.setInteger("RespawnTime", respawnTime);
|
compound.setInteger("RespawnTime", respawnTime);
|
||||||
compound.setInteger("SpawnCycle", spawnCycle);
|
compound.setInteger("SpawnCycle", spawnCycle);
|
||||||
compound.setInteger("CreatureType", creatureType.ordinal());
|
compound.setInteger("CreatureType", creatureType.ordinal());
|
||||||
compound.setInteger("HealthRegen", healthRegen);
|
compound.setFloat("HealthRegen", healthRegen);
|
||||||
compound.setInteger("CombatRegen", combatRegen);
|
compound.setFloat("CombatRegen", combatRegen);
|
||||||
|
|
||||||
compound.setInteger("AttackStrenght", attackStrength);
|
compound.setFloat("AttackStrenght", attackStrength);
|
||||||
compound.setInteger("AttackRange", attackRange);
|
compound.setInteger("AttackRange", attackRange);
|
||||||
compound.setInteger("AttackSpeed", attackSpeed);
|
compound.setInteger("AttackSpeed", attackSpeed);
|
||||||
compound.setInteger("KnockBack", knockback);
|
compound.setInteger("KnockBack", knockback);
|
||||||
@@ -80,7 +84,7 @@ public class DataStats {
|
|||||||
compound.setInteger("ShotCount", shotCount);
|
compound.setInteger("ShotCount", shotCount);
|
||||||
compound.setInteger("Accuracy", accuracy);
|
compound.setInteger("Accuracy", accuracy);
|
||||||
|
|
||||||
compound.setInteger("pDamage", pDamage);
|
compound.setFloat("pDamage", pDamage);
|
||||||
compound.setInteger("pImpact", pImpact);
|
compound.setInteger("pImpact", pImpact);
|
||||||
compound.setInteger("pSize", pSize);
|
compound.setInteger("pSize", pSize);
|
||||||
compound.setInteger("pSpeed", pSpeed);
|
compound.setInteger("pSpeed", pSpeed);
|
||||||
@@ -113,16 +117,16 @@ public class DataStats {
|
|||||||
public void readToNBT(NBTTagCompound compound)
|
public void readToNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
resistances.readToNBT(compound.getCompoundTag("Resistances"));
|
resistances.readToNBT(compound.getCompoundTag("Resistances"));
|
||||||
setMaxHealth(compound.getInteger("MaxHealth"));
|
setMaxHealth(compound.getDouble("MaxHealth"));
|
||||||
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
|
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
|
||||||
aggroRange = compound.getInteger("AggroRange");
|
aggroRange = compound.getInteger("AggroRange");
|
||||||
respawnTime = compound.getInteger("RespawnTime");
|
respawnTime = compound.getInteger("RespawnTime");
|
||||||
spawnCycle = compound.getInteger("SpawnCycle");
|
spawnCycle = compound.getInteger("SpawnCycle");
|
||||||
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
||||||
healthRegen = compound.getInteger("HealthRegen");
|
healthRegen = compound.getFloat("HealthRegen");
|
||||||
combatRegen = compound.getInteger("CombatRegen");
|
combatRegen = compound.getFloat("CombatRegen");
|
||||||
|
|
||||||
setAttackStrength(compound.getInteger("AttackStrenght"));
|
setAttackStrength(compound.getFloat("AttackStrenght"));
|
||||||
attackSpeed = compound.getInteger("AttackSpeed");
|
attackSpeed = compound.getInteger("AttackSpeed");
|
||||||
attackRange = compound.getInteger("AttackRange");
|
attackRange = compound.getInteger("AttackRange");
|
||||||
knockback = compound.getInteger("KnockBack");
|
knockback = compound.getInteger("KnockBack");
|
||||||
@@ -138,7 +142,7 @@ public class DataStats {
|
|||||||
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
|
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
|
||||||
accuracy = compound.getInteger("Accuracy");
|
accuracy = compound.getInteger("Accuracy");
|
||||||
|
|
||||||
pDamage = compound.getInteger("pDamage");
|
pDamage = compound.getFloat("pDamage");
|
||||||
pImpact = compound.getInteger("pImpact");
|
pImpact = compound.getInteger("pImpact");
|
||||||
pSize = compound.getInteger("pSize");
|
pSize = compound.getInteger("pSize");
|
||||||
pSpeed = compound.getInteger("pSpeed");
|
pSpeed = compound.getInteger("pSpeed");
|
||||||
@@ -168,16 +172,16 @@ public class DataStats {
|
|||||||
npc.setImmuneToFire(immuneToFire);
|
npc.setImmuneToFire(immuneToFire);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAttackStrength(){
|
public float getAttackStrength(){
|
||||||
return attackStrength;
|
return attackStrength;
|
||||||
}
|
}
|
||||||
public void setAttackStrength(int strength){
|
public void setAttackStrength(float strength){
|
||||||
attackStrength = strength;
|
attackStrength = (float)(Math.floor(strength));
|
||||||
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHealth(int maxHealth) {
|
public void setMaxHealth(double maxHealth) {
|
||||||
this.maxHealth = maxHealth;
|
this.maxHealth = Math.floor(maxHealth);
|
||||||
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
|
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,516 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import noppes.npcs.controllers.*;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.*;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.*;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.KeyPressedEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.LoginEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGui;
|
||||||
|
import noppes.npcs.scripted.interfaces.IEntity;
|
||||||
|
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class 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);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
|
||||||
|
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);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
|
||||||
|
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) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||||
|
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||||
|
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.INIT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.TICK, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.INTERACT, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.START_USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
|
||||||
|
IItemStack[] items = new IItemStack[entityItems.size()];
|
||||||
|
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
|
||||||
|
|
||||||
|
DropEvent event = new DropEvent(player, items);
|
||||||
|
handler.callScript(EnumScriptType.DROP, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
|
||||||
|
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
|
||||||
|
handler.callScript(EnumScriptType.PICKUP_XP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
|
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
|
handler.callScript(EnumScriptType.TOSS, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
|
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
|
handler.callScript(EnumScriptType.PICKUP, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
|
||||||
|
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
|
||||||
|
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
|
||||||
|
handler.callScript(EnumScriptType.USE_HOE, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
|
||||||
|
handler.callScript(EnumScriptType.SLEEP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
|
||||||
|
handler.callScript(EnumScriptType.WAKE_UP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
|
||||||
|
handler.callScript(EnumScriptType.KILLED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
|
||||||
|
handler.callScript(EnumScriptType.KILLS, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.DAMAGED, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LIGHTNING, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
|
||||||
|
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
|
||||||
|
handler.callScript(EnumScriptType.PLAYSOUND, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
|
||||||
|
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
|
||||||
|
handler.callScript(EnumScriptType.FALL, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.JUMP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
LoginEvent event = new LoginEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LOGIN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
|
||||||
|
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
|
||||||
|
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
|
||||||
|
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
|
||||||
|
handler.callScript(EnumScriptType.FILL_BUCKET, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
|
||||||
|
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
|
||||||
|
handler.callScript(EnumScriptType.BONEMEAL, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.RESPAWN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
LogoutEvent event = new LogoutEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LOGOUT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.CHAT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
|
||||||
|
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
|
||||||
|
handler.callScript(EnumScriptType.CHANGED_DIM, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
|
||||||
|
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
|
||||||
|
handler.callScript(EnumScriptType.KEY_PRESSED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerTimer(PlayerData data, int id) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
|
||||||
|
handler.callScript(EnumScriptType.TIMER, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeEntityEvent(EntityEvent event) {
|
||||||
|
IEntity e = NpcAPI.Instance().getIEntity(event.entity);
|
||||||
|
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeWorldEvent(WorldEvent event) {
|
||||||
|
if(ScriptController.Instance.forgeScripts.isEnabled()) {
|
||||||
|
IWorld e = NpcAPI.Instance().getIWorld((WorldServer)event.world);
|
||||||
|
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeInit(ForgeDataScript handler) {
|
||||||
|
noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent();
|
||||||
|
handler.callScript("init", event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeEvent(ForgeEvent ev, Event event) {
|
||||||
|
ForgeDataScript handler = ScriptController.Instance.forgeScripts;
|
||||||
|
if(handler.isEnabled()) {
|
||||||
|
String eventName = event.getClass().getName();
|
||||||
|
int i = eventName.lastIndexOf(".");
|
||||||
|
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
||||||
|
if(event.isCancelable()) {
|
||||||
|
ev.setCanceled(event.isCanceled());
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.callScript(eventName, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(ev);
|
||||||
|
if(event.isCancelable()) {
|
||||||
|
event.setCanceled(ev.isCanceled());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiButton(ScriptPlayer player, ICustomGui gui, int buttonId) {
|
||||||
|
CustomGuiEvent.ButtonEvent event = new CustomGuiEvent.ButtonEvent(player, gui, buttonId);
|
||||||
|
CustomGuiController.onButton(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiSlot(ScriptPlayer player, ICustomGui gui, int slotId) {
|
||||||
|
CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId));
|
||||||
|
CustomGuiController.onSlotChange(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiUnfocused(ScriptPlayer player, ICustomGui gui, int textfieldId) {
|
||||||
|
CustomGuiEvent.UnfocusedEvent event = new CustomGuiEvent.UnfocusedEvent(player, gui, textfieldId);
|
||||||
|
CustomGuiController.onCustomGuiUnfocused(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiScrollClick(ScriptPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
|
||||||
|
CustomGuiEvent.ScrollEvent event = new CustomGuiEvent.ScrollEvent(player, gui, scrollId, scrollIndex, selection, doubleClick);
|
||||||
|
CustomGuiController.onScrollClick(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiClose(ScriptPlayer player, ICustomGui gui) {
|
||||||
|
noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui);
|
||||||
|
CustomGuiController.onClose(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onQuestFinished(EntityPlayer player, Quest quest){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
|
||||||
|
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onQuestStarted(EntityPlayer player, Quest quest){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest);
|
||||||
|
handler.callScript(EnumScriptType.QUEST_START, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
handler.callScript(EnumScriptType.QUEST_TURNIN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onFactionPoints(FactionEvent.FactionPoints event){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
handler.callScript(EnumScriptType.FACTION_POINTS, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onDialogOpen(DialogEvent.DialogOpen event){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
handler.callScript(EnumScriptType.DIALOG_OPEN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onDialogOption(DialogEvent.DialogOption event){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
handler.callScript(EnumScriptType.DIALOG_OPTION, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onDialogClosed(DialogEvent.DialogClosed event){
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
handler.callScript(EnumScriptType.DIALOG_CLOSE, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,13 +28,22 @@ public class ModelDataShared{
|
|||||||
private HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
|
private HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
|
||||||
public byte breasts = 0;
|
public byte breasts = 0;
|
||||||
|
|
||||||
|
// Enabled vs Disabled
|
||||||
public byte headwear = 2;
|
public byte headwear = 2;
|
||||||
|
|
||||||
public byte bodywear = 0;
|
public byte bodywear = 0;
|
||||||
|
|
||||||
public byte armwear = 0;
|
public byte armwear = 0;
|
||||||
public byte legwear = 0;
|
public byte legwear = 0;
|
||||||
|
|
||||||
|
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
|
||||||
|
public byte solidArmwear = 0;
|
||||||
|
public byte solidLegwear = 0;
|
||||||
|
|
||||||
|
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
|
||||||
|
public byte hideHead = 0;
|
||||||
|
public byte hideBody = 0;
|
||||||
|
public byte hideArms = 0;
|
||||||
|
public byte hideLegs = 0;
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT(){
|
public NBTTagCompound writeToNBT(){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
|
||||||
@@ -50,10 +59,17 @@ public class ModelDataShared{
|
|||||||
|
|
||||||
compound.setByte("Headwear", headwear);
|
compound.setByte("Headwear", headwear);
|
||||||
compound.setByte("Bodywear", bodywear);
|
compound.setByte("Bodywear", bodywear);
|
||||||
|
|
||||||
compound.setByte("Armwear", armwear);
|
compound.setByte("Armwear", armwear);
|
||||||
compound.setByte("Legwear", legwear);
|
compound.setByte("Legwear", legwear);
|
||||||
|
|
||||||
|
compound.setByte("SolidArmwear", solidArmwear);
|
||||||
|
compound.setByte("SolidLegwear", solidLegwear);
|
||||||
|
|
||||||
|
compound.setByte("hideHead", hideHead);
|
||||||
|
compound.setByte("hideBody", hideBody);
|
||||||
|
compound.setByte("hideArms", hideArms);
|
||||||
|
compound.setByte("hideLegs", hideLegs);
|
||||||
|
|
||||||
compound.setByte("Breasts", breasts);
|
compound.setByte("Breasts", breasts);
|
||||||
compound.setTag("ExtraData", extra);
|
compound.setTag("ExtraData", extra);
|
||||||
|
|
||||||
@@ -80,10 +96,17 @@ public class ModelDataShared{
|
|||||||
|
|
||||||
headwear = compound.getByte("Headwear");
|
headwear = compound.getByte("Headwear");
|
||||||
bodywear = compound.getByte("Bodywear");
|
bodywear = compound.getByte("Bodywear");
|
||||||
|
|
||||||
armwear = compound.getByte("Armwear");
|
armwear = compound.getByte("Armwear");
|
||||||
legwear = compound.getByte("Legwear");
|
legwear = compound.getByte("Legwear");
|
||||||
|
|
||||||
|
solidArmwear = compound.getByte("SolidArmwear");
|
||||||
|
solidLegwear = compound.getByte("SolidLegwear");
|
||||||
|
|
||||||
|
hideHead = compound.getByte("hideHead");
|
||||||
|
hideBody = compound.getByte("hideBody");
|
||||||
|
hideArms = compound.getByte("hideArms");
|
||||||
|
hideLegs = compound.getByte("hideLegs");
|
||||||
|
|
||||||
breasts = compound.getByte("Breasts");
|
breasts = compound.getByte("Breasts");
|
||||||
extra = compound.getCompoundTag("ExtraData");
|
extra = compound.getCompoundTag("ExtraData");
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -67,9 +68,9 @@ public class ModelPartData {
|
|||||||
public String getColor() {
|
public String getColor() {
|
||||||
String str = Integer.toHexString(color);
|
String str = Integer.toHexString(color);
|
||||||
|
|
||||||
while(str.length() < 6)
|
while(str.length() < 6)
|
||||||
str = "0" + str;
|
str = "0" + str;
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagDouble;
|
import net.minecraft.nbt.NBTTagDouble;
|
||||||
import net.minecraft.nbt.NBTTagInt;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
|
||||||
public class NBTTags {
|
public class NBTTags {
|
||||||
|
|
||||||
@@ -74,6 +70,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) {
|
||||||
HashMap<Integer, Long> list = new HashMap<Integer, Long>();
|
HashMap<Integer, Long> list = new HashMap<Integer, Long>();
|
||||||
@@ -243,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)
|
||||||
@@ -383,4 +403,60 @@ public class NBTTags {
|
|||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TreeMap<Long, String> GetLongStringMap(NBTTagList tagList) {
|
||||||
|
TreeMap list = new TreeMap();
|
||||||
|
|
||||||
|
for(int i = 0; i < tagList.tagCount(); ++i) {
|
||||||
|
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||||
|
list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagList NBTLongStringMap(Map<Long, String> map) {
|
||||||
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
|
if(map == null) {
|
||||||
|
return nbttaglist;
|
||||||
|
} else {
|
||||||
|
Iterator var2 = map.keySet().iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
long slot = ((Long)var2.next()).longValue();
|
||||||
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||||
|
nbttagcompound.setLong("Long", slot);
|
||||||
|
nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot)));
|
||||||
|
nbttaglist.appendTag(nbttagcompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nbttaglist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
|
||||||
|
ArrayList scripts = new ArrayList();
|
||||||
|
|
||||||
|
for(int i = 0; i < list.tagCount(); ++i) {
|
||||||
|
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||||
|
ScriptContainer script = new ScriptContainer(handler);
|
||||||
|
script.readFromNBT(compoundd);
|
||||||
|
scripts.add(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
return scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
Iterator var2 = scripts.iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var2.next();
|
||||||
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
script.writeToNBT(compound);
|
||||||
|
list.appendTag(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -25,24 +26,15 @@ 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;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.DialogEvent;
|
||||||
|
import noppes.npcs.scripted.event.QuestEvent;
|
||||||
|
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||||
|
|
||||||
public class NoppesUtilPlayer {
|
public class NoppesUtilPlayer {
|
||||||
|
|
||||||
@@ -111,6 +103,28 @@ public class NoppesUtilPlayer {
|
|||||||
player.worldObj.updateEntityWithOptionalForce(player, false);
|
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, float yaw, float pitch, int dimension){
|
||||||
|
if(player.dimension != dimension){
|
||||||
|
int dim = player.dimension;
|
||||||
|
MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
WorldServer wor = server.worldServerForDimension(dimension);
|
||||||
|
if(wor == null){
|
||||||
|
player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.setLocationAndAngles(posX, posY, posZ, yaw, pitch);
|
||||||
|
server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor));
|
||||||
|
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
|
||||||
|
|
||||||
|
if(!wor.playerEntities.contains(player))
|
||||||
|
wor.spawnEntityInWorld(player);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
|
||||||
|
}
|
||||||
|
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||||
|
}
|
||||||
|
|
||||||
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
||||||
ItemStack currency = currencyInv.getStackInSlot(0);
|
ItemStack currency = currencyInv.getStackInSlot(0);
|
||||||
if(currency == null)
|
if(currency == null)
|
||||||
@@ -237,13 +251,19 @@ public class NoppesUtilPlayer {
|
|||||||
Dialog dialog = DialogController.instance.dialogs.get(dialogId);
|
Dialog dialog = DialogController.instance.dialogs.get(dialogId);
|
||||||
if(dialog == null)
|
if(dialog == null)
|
||||||
return;
|
return;
|
||||||
npc.script.callScript(EnumScriptType.DIALOG_OPTION, "player", player, "dialog", dialogId, "option", optionId + 1);
|
|
||||||
|
|
||||||
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions())
|
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
|
EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
|
||||||
|
|
||||||
|
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
||||||
|
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
DialogOption option = dialog.options.get(optionId);
|
DialogOption option = dialog.options.get(optionId);
|
||||||
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption)
|
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) {
|
||||||
return;
|
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(option.optionType == EnumOptionType.RoleOption){
|
if(option.optionType == EnumOptionType.RoleOption){
|
||||||
if(npc.roleInterface != null)
|
if(npc.roleInterface != null)
|
||||||
npc.roleInterface.interact(player);
|
npc.roleInterface.interact(player);
|
||||||
@@ -251,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);
|
||||||
@@ -269,43 +289,61 @@ 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);
|
||||||
|
event.expReward = data.quest.rewardExp;
|
||||||
|
|
||||||
|
List<IItemStack> list = new ArrayList();
|
||||||
|
Iterator var8 = data.quest.rewardItems.items.values().iterator();
|
||||||
|
|
||||||
|
while(var8.hasNext()) {
|
||||||
|
ItemStack item = (ItemStack)var8.next();
|
||||||
|
if (item.stackSize > 0) {
|
||||||
|
list.add(NpcAPI.Instance().getIItemStack(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.quest.randomReward) {
|
||||||
|
event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]);
|
||||||
|
} else if (!list.isEmpty()) {
|
||||||
|
event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))};
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onQuestTurnedIn(event);
|
||||||
|
IItemStack[] var12 = event.itemRewards;
|
||||||
|
int var14 = var12.length;
|
||||||
|
|
||||||
|
for(int var10 = 0; var10 < var14; ++var10) {
|
||||||
|
IItemStack item = var12[var10];
|
||||||
|
if (item != null) {
|
||||||
|
NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.quest.questInterface.handleComplete(player);
|
data.quest.questInterface.handleComplete(player);
|
||||||
if(data.quest.rewardExp > 0){
|
if(data.quest.rewardExp > 0){
|
||||||
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
|
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
|
||||||
|
|
||||||
player.addExperience(data.quest.rewardExp);
|
player.addExperience(data.quest.rewardExp);
|
||||||
}
|
}
|
||||||
data.quest.factionOptions.addPoints(player);
|
data.quest.factionOptions.addPoints(player);
|
||||||
if(data.quest.mail.isValid()){
|
if(data.quest.mail.isValid()){
|
||||||
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
||||||
}
|
}
|
||||||
if(!data.quest.randomReward){
|
|
||||||
for(ItemStack item : data.quest.rewardItems.items.values()){
|
|
||||||
NoppesUtilServer.GivePlayerItem(player, player, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
|
||||||
for(ItemStack item : data.quest.rewardItems.items.values()){
|
|
||||||
if(item != null && item.getItem() != null)
|
|
||||||
list.add(item);
|
|
||||||
}
|
|
||||||
if(!list.isEmpty()){
|
|
||||||
NoppesUtilServer.GivePlayerItem(player, player, list.get(player.getRNG().nextInt(list.size())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!data.quest.command.isEmpty()){
|
if(!data.quest.command.isEmpty()){
|
||||||
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
|
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerQuestController.setQuestFinished(data.quest, player);
|
PlayerQuestController.setQuestFinished(data.quest, player);
|
||||||
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player);
|
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player);
|
||||||
}
|
}
|
||||||
@@ -375,5 +413,34 @@ public class NoppesUtilPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void isGUIOpen(EntityPlayerMP player){
|
||||||
|
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemStack> countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) {
|
||||||
|
List<ItemStack> list = new ArrayList();
|
||||||
|
|
||||||
|
for(int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||||
|
ItemStack item = inv.getStackInSlot(i);
|
||||||
|
if (!NoppesUtilServer.IsItemStackNull(item)) {
|
||||||
|
boolean found = false;
|
||||||
|
Iterator var7 = list.iterator();
|
||||||
|
|
||||||
|
while(var7.hasNext()) {
|
||||||
|
ItemStack is = (ItemStack)var7.next();
|
||||||
|
if (compareItems(item, is, ignoreDamage, ignoreNBT)) {
|
||||||
|
is.stackSize = is.stackSize + item.stackSize;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
list.add(item.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.command.server.CommandBlockLogic;
|
import net.minecraft.command.server.CommandBlockLogic;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
@@ -21,6 +22,8 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
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.projectile.EntityArrow;
|
||||||
|
import net.minecraft.entity.projectile.EntityThrowable;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -31,8 +34,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
@@ -69,7 +72,9 @@ import noppes.npcs.controllers.TransportLocation;
|
|||||||
import noppes.npcs.entity.EntityDialogNpc;
|
import noppes.npcs.entity.EntityDialogNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.RoleTransporter;
|
import noppes.npcs.roles.RoleTransporter;
|
||||||
import noppes.npcs.scripted.ScriptEventDialog;
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.DialogEvent;
|
||||||
|
import noppes.npcs.scripted.event.ScriptEventDialog;
|
||||||
|
|
||||||
public class NoppesUtilServer {
|
public class NoppesUtilServer {
|
||||||
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
||||||
@@ -175,8 +180,11 @@ 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));
|
||||||
|
|
||||||
if(npc instanceof EntityDialogNpc){
|
if(npc instanceof EntityDialogNpc){
|
||||||
dialog.hideNPC = true;
|
dialog.hideNPC = true;
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||||
@@ -195,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);
|
||||||
@@ -217,6 +225,19 @@ public class NoppesUtilServer {
|
|||||||
logic.func_145755_a(executer.worldObj);
|
logic.func_145755_a(executer.worldObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runCommand(World world, String name, String command) {
|
||||||
|
TileEntityCommandBlock tile = new TileEntityCommandBlock();
|
||||||
|
tile.setWorldObj(world.provider.worldObj);
|
||||||
|
tile.xCoord = 0;
|
||||||
|
tile.yCoord = 0;
|
||||||
|
tile.zCoord = 0;
|
||||||
|
|
||||||
|
CommandBlockLogic logic = tile.func_145993_a();
|
||||||
|
logic.func_145752_a(command);
|
||||||
|
logic.func_145754_b("@"+name);
|
||||||
|
logic.func_145755_a(world);
|
||||||
|
}
|
||||||
|
|
||||||
public static void consumeItemStack(int i, EntityPlayer player){
|
public static void consumeItemStack(int i, EntityPlayer player){
|
||||||
ItemStack item = player.inventory.getCurrentItem();
|
ItemStack item = player.inventory.getCurrentItem();
|
||||||
if(player.capabilities.isCreativeMode || item == null)
|
if(player.capabilities.isCreativeMode || item == null)
|
||||||
@@ -291,6 +312,28 @@ 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(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,
|
||||||
|
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
|
||||||
|
){
|
||||||
|
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||||
|
directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
||||||
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
||||||
@@ -658,4 +701,29 @@ public class NoppesUtilServer {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Entity GetDamageSourcee(DamageSource damagesource) {
|
||||||
|
Object entity = damagesource.getEntity();
|
||||||
|
if(entity == null) {
|
||||||
|
entity = damagesource.getSourceOfDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase) {
|
||||||
|
entity = ((EntityArrow)entity).shootingEntity;
|
||||||
|
} else if(entity instanceof EntityThrowable) {
|
||||||
|
entity = ((EntityThrowable)entity).getThrower();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Entity)entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException {
|
||||||
|
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||||
|
boolean isGUIOpen = buffer.readBoolean();
|
||||||
|
playerdata.setGUIOpen(isGUIOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean IsItemStackNull(ItemStack is) {
|
||||||
|
return is == null || is.stackSize == 0 || is.getItem() == null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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,19 +18,9 @@ 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.BankData;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.PlayerFactionData;
|
|
||||||
import noppes.npcs.controllers.PlayerMail;
|
|
||||||
import noppes.npcs.controllers.PlayerMailData;
|
|
||||||
import noppes.npcs.controllers.PlayerQuestController;
|
|
||||||
import noppes.npcs.controllers.PlayerQuestData;
|
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.RoleCompanion;
|
import noppes.npcs.roles.RoleCompanion;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -67,17 +59,55 @@ public class PacketHandlerPlayer{
|
|||||||
return;
|
return;
|
||||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPlayerPacket.KeyPressed) {
|
||||||
|
if(ScriptController.Instance.languages.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int button = buffer.readInt();
|
||||||
|
boolean isCtrlPressed = buffer.readBoolean();
|
||||||
|
boolean isShiftPressed = buffer.readBoolean();
|
||||||
|
boolean isAltPressed = buffer.readBoolean();
|
||||||
|
boolean isMetaPressed = buffer.readBoolean();
|
||||||
|
boolean buttonDown = buffer.readBoolean();
|
||||||
|
|
||||||
|
String ints = Server.readString(buffer);
|
||||||
|
String[] split = ints.split(",");
|
||||||
|
int[] keysDown;
|
||||||
|
|
||||||
|
if(ints.length() > 0) {
|
||||||
|
keysDown = new int[split.length];
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
keysDown[i] = Integer.parseInt(split[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ignored){
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keysDown = new int[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
|
||||||
|
}
|
||||||
|
else if(type == EnumPlayerPacket.MouseClicked) {
|
||||||
|
if(ScriptController.Instance.languages.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onPlayerMouseClicked(player, buffer.readInt(), buffer.readInt(), buffer.readBoolean());
|
||||||
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerHire){
|
else if(type == EnumPlayerPacket.FollowerHire){
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||||
return;
|
return;
|
||||||
NoppesUtilPlayer.hireFollower(player,npc);
|
NoppesUtilPlayer.hireFollower(player, npc);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerExtend){
|
else if(type == EnumPlayerPacket.FollowerExtend){
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||||
return;
|
return;
|
||||||
NoppesUtilPlayer.extendFollower(player,npc);
|
NoppesUtilPlayer.extendFollower(player, npc);
|
||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerState){
|
else if(type == EnumPlayerPacket.FollowerState){
|
||||||
@@ -124,17 +154,18 @@ public class PacketHandlerPlayer{
|
|||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null)
|
if(npc == null)
|
||||||
return;
|
return;
|
||||||
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);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.QuestCompletion){
|
else if(type == EnumPlayerPacket.QuestCompletion){
|
||||||
NoppesUtilPlayer.questCompletion(player,buffer.readInt());
|
NoppesUtilPlayer.questCompletion(player, buffer.readInt());
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FactionsGet){
|
else if(type == EnumPlayerPacket.FactionsGet){
|
||||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
import net.minecraft.entity.passive.EntityVillager;
|
||||||
@@ -37,31 +36,13 @@ import noppes.npcs.constants.EnumPacketClient;
|
|||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
import noppes.npcs.constants.EnumPlayerData;
|
import noppes.npcs.constants.EnumPlayerData;
|
||||||
import noppes.npcs.constants.EnumRoleType;
|
import noppes.npcs.constants.EnumRoleType;
|
||||||
|
import noppes.npcs.containers.ContainerCustomGui;
|
||||||
import noppes.npcs.containers.ContainerMail;
|
import noppes.npcs.containers.ContainerMail;
|
||||||
import noppes.npcs.controllers.Bank;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.BankController;
|
|
||||||
import noppes.npcs.controllers.Dialog;
|
|
||||||
import noppes.npcs.controllers.DialogCategory;
|
|
||||||
import noppes.npcs.controllers.DialogController;
|
|
||||||
import noppes.npcs.controllers.DialogOption;
|
|
||||||
import noppes.npcs.controllers.Faction;
|
|
||||||
import noppes.npcs.controllers.FactionController;
|
|
||||||
import noppes.npcs.controllers.LinkedNpcController;
|
|
||||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.PlayerMail;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.controllers.Quest;
|
|
||||||
import noppes.npcs.controllers.QuestCategory;
|
|
||||||
import noppes.npcs.controllers.QuestController;
|
|
||||||
import noppes.npcs.controllers.RecipeCarpentry;
|
|
||||||
import noppes.npcs.controllers.RecipeController;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
import noppes.npcs.controllers.ServerCloneController;
|
|
||||||
import noppes.npcs.controllers.SpawnController;
|
|
||||||
import noppes.npcs.controllers.SpawnData;
|
|
||||||
import noppes.npcs.controllers.TransportController;
|
|
||||||
import noppes.npcs.controllers.TransportLocation;
|
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.JobSpawner;
|
import noppes.npcs.roles.JobSpawner;
|
||||||
@@ -70,6 +51,9 @@ import noppes.npcs.roles.RoleTrader;
|
|||||||
import noppes.npcs.roles.RoleTransporter;
|
import noppes.npcs.roles.RoleTransporter;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGui;
|
||||||
|
|
||||||
public class PacketHandlerServer{
|
public class PacketHandlerServer{
|
||||||
|
|
||||||
@@ -88,33 +72,72 @@ public class PacketHandlerServer{
|
|||||||
ItemStack item = player.inventory.getCurrentItem();
|
ItemStack item = player.inventory.getCurrentItem();
|
||||||
|
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
|
|
||||||
|
if(type == EnumPacketServer.IsGuiOpen) {
|
||||||
|
isGuiOpenPacket(buffer, player);
|
||||||
|
return;
|
||||||
|
} else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) {
|
||||||
|
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
|
||||||
|
EventHooks.onCustomGuiButton((ScriptPlayer)NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
|
||||||
|
return;
|
||||||
|
} else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) {
|
||||||
|
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
|
||||||
|
EventHooks.onCustomGuiSlot((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt());
|
||||||
|
return;
|
||||||
|
} else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) {
|
||||||
|
((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
|
||||||
|
EventHooks.onCustomGuiUnfocused((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt());
|
||||||
|
return;
|
||||||
|
} else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) {
|
||||||
|
((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer));
|
||||||
|
EventHooks.onCustomGuiScrollClick((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean());
|
||||||
|
return;
|
||||||
|
} else if (type == EnumPacketServer.CustomGuiClose) {
|
||||||
|
EventHooks.onCustomGuiClose((ScriptPlayer)NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(type.needsNpc && npc == null){
|
if(type.needsNpc && npc == null){
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||||
//player doesnt have permission todo this
|
//player doesnt have permission to do this
|
||||||
}
|
}
|
||||||
else if(item == null )
|
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 if(item.getItem() == CustomItems.wand)
|
else {
|
||||||
wandPackets(type, buffer, player, npc);
|
if (item != null) {
|
||||||
else if(item.getItem() == CustomItems.moving)
|
if (item.getItem() == CustomItems.wand)
|
||||||
movingPackets(type, buffer, player, npc);
|
wandPackets(type, buffer, player, npc);
|
||||||
else if(item.getItem() == CustomItems.mount)
|
else if (item.getItem() == CustomItems.moving)
|
||||||
mountPackets(type, buffer, player);
|
movingPackets(type, buffer, player, npc);
|
||||||
else if(item.getItem() == CustomItems.cloner)
|
else if (item.getItem() == CustomItems.mount)
|
||||||
clonePackets(type, buffer, player);
|
mountPackets(type, buffer, player);
|
||||||
else if(item.getItem() == CustomItems.teleporter)
|
else if (item.getItem() == CustomItems.cloner)
|
||||||
featherPackets(type, buffer, player);
|
clonePackets(type, buffer, player);
|
||||||
else if(item.getItem() == CustomItems.scripter)
|
else if (item.getItem() == CustomItems.teleporter)
|
||||||
scriptPackets(type, buffer, player, npc);
|
featherPackets(type, buffer, player);
|
||||||
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||||
blockPackets(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)
|
||||||
|
forgeScriptPackets(type, buffer, player);
|
||||||
|
else if (item.getItem() == CustomItems.scripter)
|
||||||
|
scriptPackets(type, buffer, player, npc);
|
||||||
|
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
||||||
|
blockPackets(type, buffer, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.error("Error with EnumPacketServer." + type, e);
|
LogWriter.error("Error with EnumPacketServer." + type, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
|
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||||
|
}
|
||||||
|
|
||||||
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
||||||
if(type == EnumPacketServer.ScriptDataSave){
|
if(type == EnumPacketServer.ScriptDataSave){
|
||||||
npc.script.readFromNBT(Server.readNBT(buffer));
|
npc.script.readFromNBT(Server.readNBT(buffer));
|
||||||
@@ -128,6 +151,42 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if(type == EnumPacketServer.ScriptPlayerGet) {
|
||||||
|
PlayerDataScript data = ScriptController.Instance.playerScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
|
} else if(type == EnumPacketServer.ScriptPlayerSave) {
|
||||||
|
ScriptController.Instance.setPlayerScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if (type == EnumPacketServer.ScriptForgeGet) {
|
||||||
|
ForgeDataScript data = ScriptController.Instance.forgeScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||||
|
} else if (type == EnumPacketServer.ScriptForgeSave) {
|
||||||
|
ScriptController.Instance.setForgeScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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>();
|
||||||
@@ -225,7 +284,7 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
else if(type == EnumPacketServer.FactionGet){
|
else if(type == EnumPacketServer.FactionGet){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
Faction faction = FactionController.getInstance().getFaction(buffer.readInt());
|
Faction faction = FactionController.getInstance().get(buffer.readInt());
|
||||||
faction.writeNBT(compound);
|
faction.writeNBT(compound);
|
||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
}
|
}
|
||||||
@@ -341,7 +400,7 @@ public class PacketHandlerServer{
|
|||||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||||
}
|
}
|
||||||
else if(type == EnumPacketServer.RecipeRemove){
|
else if(type == EnumPacketServer.RecipeRemove){
|
||||||
RecipeCarpentry recipe = RecipeController.instance.removeRecipe(buffer.readInt());
|
RecipeCarpentry recipe = RecipeController.instance.delete(buffer.readInt());
|
||||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||||
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
|
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
|
||||||
}
|
}
|
||||||
@@ -523,7 +582,7 @@ public class PacketHandlerServer{
|
|||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
}
|
}
|
||||||
else if(type == EnumPacketServer.FactionRemove){
|
else if(type == EnumPacketServer.FactionRemove){
|
||||||
FactionController.getInstance().removeFaction(buffer.readInt());
|
FactionController.getInstance().delete(buffer.readInt());
|
||||||
NoppesUtilServer.sendFactionDataAll(player);
|
NoppesUtilServer.sendFactionDataAll(player);
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
(new Faction()).writeNBT(compound);
|
(new Faction()).writeNBT(compound);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,15 @@ public class Resistances {
|
|||||||
public float playermelee = 1f;
|
public float playermelee = 1f;
|
||||||
public float explosion = 1f;
|
public float explosion = 1f;
|
||||||
|
|
||||||
|
public boolean disableDamage = false;
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT() {
|
public NBTTagCompound writeToNBT() {
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setFloat("Knockback", knockback);
|
compound.setFloat("Knockback", knockback);
|
||||||
compound.setFloat("Arrow", arrow);
|
compound.setFloat("Arrow", arrow);
|
||||||
compound.setFloat("Melee", playermelee);
|
compound.setFloat("Melee", playermelee);
|
||||||
compound.setFloat("Explosion", explosion);
|
compound.setFloat("Explosion", explosion);
|
||||||
|
compound.setBoolean("disableDamage", disableDamage);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +27,14 @@ public class Resistances {
|
|||||||
arrow = compound.getFloat("Arrow");
|
arrow = compound.getFloat("Arrow");
|
||||||
playermelee = compound.getFloat("Melee");
|
playermelee = compound.getFloat("Melee");
|
||||||
explosion = compound.getFloat("Explosion");
|
explosion = compound.getFloat("Explosion");
|
||||||
|
disableDamage = compound.getBoolean("disableDamage");
|
||||||
}
|
}
|
||||||
|
|
||||||
public float applyResistance(DamageSource source, float damage) {
|
public float applyResistance(DamageSource source, float damage) {
|
||||||
|
if(disableDamage){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
|
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
|
||||||
damage *= (2 - arrow);
|
damage *= (2 - arrow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import noppes.npcs.controllers.PixelmonHelper;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class ScriptForgeEventHandler {
|
||||||
|
public ScriptForgeEventHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void forgeEntity(Event event) {
|
||||||
|
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
|
||||||
|
if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event instanceof EntityEvent) {
|
||||||
|
EntityEvent ev2 = (EntityEvent)event;
|
||||||
|
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
|
||||||
|
EventHooks.onForgeEntityEvent(ev2);
|
||||||
|
}
|
||||||
|
} else if(event instanceof WorldEvent) {
|
||||||
|
WorldEvent ev1 = (WorldEvent)event;
|
||||||
|
if(ev1.world instanceof WorldServer) {
|
||||||
|
EventHooks.onForgeWorldEvent(ev1);
|
||||||
|
}
|
||||||
|
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
|
||||||
|
if (event instanceof PlayerEvent) {
|
||||||
|
PlayerEvent ev = (PlayerEvent) event;
|
||||||
|
if (ev.player == null || !(ev.player.worldObj instanceof WorldServer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptForgeEventHandler registerForgeEvents() {
|
||||||
|
try {
|
||||||
|
Method e = this.getClass().getMethod("forgeEntity", new Class[]{Event.class});
|
||||||
|
Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class});
|
||||||
|
register.setAccessible(true);
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
|
||||||
|
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
|
||||||
|
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
|
||||||
|
Iterator e1 = list.iterator();
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
ClassPath.ClassInfo classLoader;
|
||||||
|
String classes;
|
||||||
|
do {
|
||||||
|
if(!e1.hasNext()) {
|
||||||
|
if(PixelmonHelper.Enabled) {
|
||||||
|
try {
|
||||||
|
Field e2 = ClassLoader.class.getDeclaredField("classes");
|
||||||
|
e2.setAccessible(true);
|
||||||
|
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
|
||||||
|
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
|
||||||
|
Iterator infoClass1 = classes1.iterator();
|
||||||
|
|
||||||
|
while(infoClass1.hasNext()) {
|
||||||
|
Class c2 = (Class)infoClass1.next();
|
||||||
|
}
|
||||||
|
} catch (Exception var12) {
|
||||||
|
var12.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
classLoader = (ClassPath.ClassInfo)e1.next();
|
||||||
|
classes = classLoader.getName();
|
||||||
|
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
|
||||||
|
|
||||||
|
Class infoClass = classLoader.load();
|
||||||
|
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
c.add(infoClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var10 = c.iterator();
|
||||||
|
while(var10.hasNext()) {
|
||||||
|
Class c1 = (Class)var10.next();
|
||||||
|
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
|
||||||
|
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception var13) {
|
||||||
|
var13.printStackTrace();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,488 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ContainerPlayer;
|
||||||
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
|
||||||
|
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||||
|
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.*;
|
||||||
|
import net.minecraftforge.event.world.*;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
|
||||||
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
|
import noppes.npcs.controllers.*;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
public class ScriptPlayerEventHandler {
|
||||||
|
public ScriptPlayerEventHandler() {
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
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) {
|
||||||
|
EntityPlayer player = event.player;
|
||||||
|
|
||||||
|
if(player.ticksExisted%10 == 0) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
|
||||||
|
EventHooks.onPlayerTick(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||||
|
if(PlayerDataController.instance != null) {
|
||||||
|
if(playerData.timers.size() > 0)
|
||||||
|
playerData.timers.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.ticksExisted%(20*CustomNpcs.PlayerQuestCheck) == 0){
|
||||||
|
PlayerQuestData questData = playerData.questData;
|
||||||
|
for(EnumQuestType e : EnumQuestType.values())
|
||||||
|
questData.checkQuestCompletion(playerData, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(EntityInteractEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
|
||||||
|
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ArrowNockEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
|
||||||
|
EventHooks.onPlayerBowCharge(handler, ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ArrowLooseEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
|
||||||
|
EventHooks.onPlayerRanged(handler, ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(BlockEvent.BreakEvent event) {
|
||||||
|
if(event.getPlayer() == null || event.getPlayer().worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
|
||||||
|
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
|
||||||
|
event.setExpToDrop(ev.exp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Start event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Tick event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Stop event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Finish event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerDropsEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerPickupXpEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.ItemPickupEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
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)) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(UseHoeEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerSleepInBedEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerWakeUpEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(FillBucketEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(BonemealEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(AchievementEvent event) {
|
||||||
|
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ItemTossEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingFallEvent event) {
|
||||||
|
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingEvent.LivingJumpEvent event) {
|
||||||
|
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerJump(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(EntityStruckByLightningEvent event) {
|
||||||
|
if(event.entity == null || event.entity.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entity instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerLightning(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlaySoundAtEntityEvent event) {
|
||||||
|
if(event.entity == null || event.entity.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entity instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingDeathEvent event) {
|
||||||
|
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source instanceof EntityPlayer) {
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
|
||||||
|
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingHurtEvent event) {
|
||||||
|
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
|
||||||
|
event.ammount = pevent.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source instanceof EntityPlayer) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
|
||||||
|
event.ammount = pevent1.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerRespawn(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||||
|
if(event.player == null || event.player.worldObj == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogout(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent(
|
||||||
|
priority = EventPriority.HIGHEST
|
||||||
|
)
|
||||||
|
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)) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
String message = event.message;
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
|
||||||
|
EventHooks.onPlayerChat(handler, ev);
|
||||||
|
event.setCanceled(ev.isCanceled());
|
||||||
|
if(!message.equals(ev.message)) {
|
||||||
|
ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]);
|
||||||
|
chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message));
|
||||||
|
event.component = chat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,14 +35,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
|||||||
import noppes.npcs.constants.EnumQuestType;
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.constants.EnumRoleType;
|
import noppes.npcs.constants.EnumRoleType;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.controllers.Line;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.PlayerQuestData;
|
|
||||||
import noppes.npcs.controllers.QuestData;
|
|
||||||
import noppes.npcs.controllers.RecipeCarpentry;
|
|
||||||
import noppes.npcs.controllers.RecipeController;
|
|
||||||
import noppes.npcs.controllers.ServerCloneController;
|
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.items.ItemExcalibur;
|
import noppes.npcs.items.ItemExcalibur;
|
||||||
import noppes.npcs.items.ItemShield;
|
import noppes.npcs.items.ItemShield;
|
||||||
@@ -111,17 +104,17 @@ public class ServerEventsHandler {
|
|||||||
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
|
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
|
||||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
|
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
|
||||||
return;
|
return;
|
||||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
|
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
|
||||||
}
|
}
|
||||||
else if(item.getItem() == CustomItems.mount){
|
else if(item.getItem() == CustomItems.mount){
|
||||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
|
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
|
||||||
return;
|
return;
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
mounted = event.target;
|
mounted = event.target;
|
||||||
if(isRemote)
|
if(isRemote)
|
||||||
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
|
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
|
||||||
}
|
}
|
||||||
else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){
|
else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){
|
||||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
|
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
|
||||||
@@ -132,12 +125,12 @@ public class ServerEventsHandler {
|
|||||||
if(!isRemote){
|
if(!isRemote){
|
||||||
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
|
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
|
||||||
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
|
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
|
||||||
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
|
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
|
||||||
|
|
||||||
if (merchantrecipelist != null)
|
if (merchantrecipelist != null)
|
||||||
{
|
{
|
||||||
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,47 +173,47 @@ public class ServerEventsHandler {
|
|||||||
|
|
||||||
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||||
RecipeController controller = RecipeController.instance;
|
RecipeController controller = RecipeController.instance;
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
||||||
list.appendTag(recipe.writeNBT());
|
list.appendTag(recipe.writeNBT());
|
||||||
i++;
|
i++;
|
||||||
if(i % 10 == 0){
|
if(i % 10 == 0){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("recipes", list);
|
compound.setTag("recipes", list);
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||||
list = new NBTTagList();
|
list = new NBTTagList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i % 10 != 0){
|
if(i % 10 != 0){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("recipes", list);
|
compound.setTag("recipes", list);
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||||
}
|
}
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
|
||||||
}
|
}
|
||||||
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||||
RecipeController controller = RecipeController.instance;
|
RecipeController controller = RecipeController.instance;
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
|
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
|
||||||
list.appendTag(recipe.writeNBT());
|
list.appendTag(recipe.writeNBT());
|
||||||
i++;
|
i++;
|
||||||
if(i % 10 == 0){
|
if(i % 10 == 0){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("recipes", list);
|
compound.setTag("recipes", list);
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||||
list = new NBTTagList();
|
list = new NBTTagList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i % 10 != 0){
|
if(i % 10 != 0){
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
compound.setTag("recipes", list);
|
compound.setTag("recipes", list);
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||||
}
|
}
|
||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
|
||||||
}
|
}
|
||||||
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
|
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
|
||||||
ItemStack item = player.inventory.getCurrentItem();
|
ItemStack item = player.inventory.getCurrentItem();
|
||||||
@@ -232,19 +225,19 @@ public class ServerEventsHandler {
|
|||||||
y--;
|
y--;
|
||||||
TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z);
|
TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z);
|
||||||
if(!tile.canEdit()){
|
if(!tile.canEdit()){
|
||||||
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
|
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
|
||||||
tile.time = System.currentTimeMillis();
|
tile.time = System.currentTimeMillis();
|
||||||
if(player.worldObj.isRemote)
|
if(player.worldObj.isRemote)
|
||||||
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
|
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!player.worldObj.isRemote){
|
if(!player.worldObj.isRemote){
|
||||||
tile.icon = item.copy();
|
tile.icon = item.copy();
|
||||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,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;
|
||||||
@@ -298,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){
|
||||||
@@ -314,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))
|
||||||
@@ -331,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,21 @@ 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 = 17;
|
||||||
|
|
||||||
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 < 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()));
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package noppes.npcs.ai;
|
package noppes.npcs.ai;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
import net.minecraft.pathfinding.PathEntity;
|
import net.minecraft.pathfinding.PathEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.constants.AiMutex;
|
import noppes.npcs.constants.AiMutex;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
@@ -55,7 +57,9 @@ public class EntityAIAttackTarget extends EntityAIBase
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.entityTarget = entitylivingbase;
|
this.entityTarget = entitylivingbase;
|
||||||
|
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.attacker).stats.aggroRange);
|
||||||
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
|
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
|
||||||
|
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
|
||||||
return this.entityPathEntity != null;
|
return this.entityPathEntity != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public class EntityAIWander extends EntityAIBase
|
|||||||
else{
|
else{
|
||||||
this.xPosition = vec.xCoord;
|
this.xPosition = vec.xCoord;
|
||||||
this.yPosition = vec.yCoord;
|
this.yPosition = vec.yCoord;
|
||||||
|
// FLY CHANGE
|
||||||
|
if(entity.canFly())
|
||||||
|
this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ai.walkingRange;
|
||||||
this.zPosition = vec.zCoord;
|
this.zPosition = vec.zCoord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
|
public class FlyNodeProcessor extends NodeProcessor{
|
||||||
|
|
||||||
|
public PathPoint getPathPointTo(Entity p_176161_1_)
|
||||||
|
{
|
||||||
|
return this.openPoint(MathHelper.floor_double(p_176161_1_.boundingBox.minX), MathHelper.floor_double(p_176161_1_.boundingBox.minY + 0.5D), MathHelper.floor_double(p_176161_1_.boundingBox.minZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PathPoint getPathPointToCoords(Entity p_176160_1_, double p_176160_2_, double p_176160_4_, double p_176160_6_)
|
||||||
|
{
|
||||||
|
return this.openPoint(MathHelper.floor_double(p_176160_2_ - (double)(p_176160_1_.width / 2.0F)), MathHelper.floor_double(p_176160_4_ + 0.5D), MathHelper.floor_double(p_176160_6_ - (double)(p_176160_1_.width / 2.0F)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findPathOptions(PathPoint[] p_176164_1_, Entity p_176164_2_, PathPoint p_176164_3_, PathPoint p_176164_4_, float p_176164_5_)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
EnumFacing[] aenumfacing = EnumFacing.values();
|
||||||
|
int j = aenumfacing.length;
|
||||||
|
|
||||||
|
for (int k = 0; k < j; ++k)
|
||||||
|
{
|
||||||
|
EnumFacing enumfacing = aenumfacing[k];
|
||||||
|
PathPoint pathpoint2 = this.getSafePoint(p_176164_2_, p_176164_3_.xCoord + enumfacing.getFrontOffsetX(), p_176164_3_.yCoord + enumfacing.getFrontOffsetY(), p_176164_3_.zCoord + enumfacing.getFrontOffsetZ());
|
||||||
|
|
||||||
|
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(p_176164_4_) < p_176164_5_)
|
||||||
|
{
|
||||||
|
p_176164_1_[i++] = pathpoint2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PathPoint getSafePoint(Entity p_176185_1_, int p_176185_2_, int p_176185_3_, int p_176185_4_)
|
||||||
|
{
|
||||||
|
int l = this.func_176186_b(p_176185_1_, p_176185_2_, p_176185_3_, p_176185_4_);
|
||||||
|
return l == -1 ? this.openPoint(p_176185_2_, p_176185_3_, p_176185_4_) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int func_176186_b(Entity entityIn, int x, int y, int z)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = x; i < x + this.entitySizeX; ++i)
|
||||||
|
{
|
||||||
|
for (int j = y; j < y + this.entitySizeY; ++j)
|
||||||
|
{
|
||||||
|
for (int k = z; k < z + this.entitySizeZ; ++k)
|
||||||
|
{
|
||||||
|
Block block = this.blockaccess.getBlock(i, j, k);
|
||||||
|
if(block.getMaterial() == Material.water && entityIn instanceof EntityNPCInterface && ((EntityNPCInterface)entityIn).ai.canSwim)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (block.getMaterial() != Material.air)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
public class FlyPath {
|
||||||
|
private FlyPathPoint[] pathPoints = new FlyPathPoint[1024];
|
||||||
|
/** The number of points in this path */
|
||||||
|
private int count;
|
||||||
|
private static final String __OBFID = "CL_00000573";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a point to the path
|
||||||
|
*/
|
||||||
|
public FlyPathPoint addPoint(FlyPathPoint p_75849_1_)
|
||||||
|
{
|
||||||
|
if (p_75849_1_.index >= 0)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("OW KNOWS!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.count == this.pathPoints.length)
|
||||||
|
{
|
||||||
|
FlyPathPoint[] apathpoint = new FlyPathPoint[this.count << 1];
|
||||||
|
System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count);
|
||||||
|
this.pathPoints = apathpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[this.count] = p_75849_1_;
|
||||||
|
p_75849_1_.index = this.count;
|
||||||
|
this.sortBack(this.count++);
|
||||||
|
return p_75849_1_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the path
|
||||||
|
*/
|
||||||
|
public void clearPath()
|
||||||
|
{
|
||||||
|
this.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns and removes the first point in the path
|
||||||
|
*/
|
||||||
|
public FlyPathPoint dequeue()
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint = this.pathPoints[0];
|
||||||
|
this.pathPoints[0] = this.pathPoints[--this.count];
|
||||||
|
this.pathPoints[this.count] = null;
|
||||||
|
|
||||||
|
if (this.count > 0)
|
||||||
|
{
|
||||||
|
this.sortForward(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pathpoint.index = -1;
|
||||||
|
return pathpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the provided point's distance to target
|
||||||
|
*/
|
||||||
|
public void changeDistance(FlyPathPoint p_75850_1_, float p_75850_2_)
|
||||||
|
{
|
||||||
|
float f1 = p_75850_1_.distanceToTarget;
|
||||||
|
p_75850_1_.distanceToTarget = p_75850_2_;
|
||||||
|
|
||||||
|
if (p_75850_2_ < f1)
|
||||||
|
{
|
||||||
|
this.sortBack(p_75850_1_.index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.sortForward(p_75850_1_.index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts a point to the left
|
||||||
|
*/
|
||||||
|
private void sortBack(int p_75847_1_)
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint = this.pathPoints[p_75847_1_];
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (float f = pathpoint.distanceToTarget; p_75847_1_ > 0; p_75847_1_ = j)
|
||||||
|
{
|
||||||
|
j = p_75847_1_ - 1 >> 1;
|
||||||
|
FlyPathPoint pathpoint1 = this.pathPoints[j];
|
||||||
|
|
||||||
|
if (f >= pathpoint1.distanceToTarget)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[p_75847_1_] = pathpoint1;
|
||||||
|
pathpoint1.index = p_75847_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[p_75847_1_] = pathpoint;
|
||||||
|
pathpoint.index = p_75847_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts a point to the right
|
||||||
|
*/
|
||||||
|
private void sortForward(int p_75846_1_)
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint = this.pathPoints[p_75846_1_];
|
||||||
|
float f = pathpoint.distanceToTarget;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int j = 1 + (p_75846_1_ << 1);
|
||||||
|
int k = j + 1;
|
||||||
|
|
||||||
|
if (j >= this.count)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlyPathPoint pathpoint1 = this.pathPoints[j];
|
||||||
|
float f1 = pathpoint1.distanceToTarget;
|
||||||
|
FlyPathPoint pathpoint2;
|
||||||
|
float f2;
|
||||||
|
|
||||||
|
if (k >= this.count)
|
||||||
|
{
|
||||||
|
pathpoint2 = null;
|
||||||
|
f2 = Float.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathpoint2 = this.pathPoints[k];
|
||||||
|
f2 = pathpoint2.distanceToTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f1 < f2)
|
||||||
|
{
|
||||||
|
if (f1 >= f)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[p_75846_1_] = pathpoint1;
|
||||||
|
pathpoint1.index = p_75846_1_;
|
||||||
|
p_75846_1_ = j;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (f2 >= f)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[p_75846_1_] = pathpoint2;
|
||||||
|
pathpoint2.index = p_75846_1_;
|
||||||
|
p_75846_1_ = k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pathPoints[p_75846_1_] = pathpoint;
|
||||||
|
pathpoint.index = p_75846_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this path contains no points
|
||||||
|
*/
|
||||||
|
public boolean isPathEmpty()
|
||||||
|
{
|
||||||
|
return this.count == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.pathfinding.PathEntity;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
|
public class FlyPathEntity extends PathEntity{
|
||||||
|
public final PathPoint[] points;
|
||||||
|
/** PathEntity Array Index the Entity is currently targeting */
|
||||||
|
public int currentPathIndex;
|
||||||
|
/** The total length of the path */
|
||||||
|
public int pathLength;
|
||||||
|
private static final String __OBFID = "CL_00000575";
|
||||||
|
|
||||||
|
public FlyPathEntity(PathPoint[] p_i2136_1_)
|
||||||
|
{
|
||||||
|
super(p_i2136_1_);
|
||||||
|
this.points = p_i2136_1_;
|
||||||
|
this.pathLength = p_i2136_1_.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Directs this path to the next point in its array
|
||||||
|
*/
|
||||||
|
public void incrementPathIndex()
|
||||||
|
{
|
||||||
|
++this.currentPathIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this path has reached the end
|
||||||
|
*/
|
||||||
|
public boolean isFinished()
|
||||||
|
{
|
||||||
|
return this.currentPathIndex >= this.pathLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the last PathPoint of the Array
|
||||||
|
*/
|
||||||
|
public PathPoint getFinalPathPoint()
|
||||||
|
{
|
||||||
|
return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the PathPoint located at the specified PathIndex, usually the current one
|
||||||
|
*/
|
||||||
|
public PathPoint getPathPointFromIndex(int p_75877_1_)
|
||||||
|
{
|
||||||
|
return this.points[p_75877_1_];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrentPathLength()
|
||||||
|
{
|
||||||
|
return this.pathLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPathLength(int p_75871_1_)
|
||||||
|
{
|
||||||
|
this.pathLength = p_75871_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrentPathIndex()
|
||||||
|
{
|
||||||
|
return this.currentPathIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPathIndex(int p_75872_1_)
|
||||||
|
{
|
||||||
|
this.currentPathIndex = p_75872_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the vector of the PathPoint associated with the given index.
|
||||||
|
*/
|
||||||
|
public Vec3 getVectorFromIndex(Entity p_75881_1_, int p_75881_2_)
|
||||||
|
{
|
||||||
|
double d0 = (double)this.points[p_75881_2_].xCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
|
||||||
|
double d1 = (double)this.points[p_75881_2_].yCoord;
|
||||||
|
double d2 = (double)this.points[p_75881_2_].zCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
|
||||||
|
return Vec3.createVectorHelper(d0, d1, d2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the current PathEntity target node as Vec3D
|
||||||
|
*/
|
||||||
|
public Vec3 getPosition(Entity p_75878_1_)
|
||||||
|
{
|
||||||
|
return this.getVectorFromIndex(p_75878_1_, this.currentPathIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the EntityPath are the same. Non instance related equals.
|
||||||
|
*/
|
||||||
|
public boolean isSamePath(PathEntity pathEntity)
|
||||||
|
{
|
||||||
|
FlyPathEntity p_75876_1_ = (FlyPathEntity) pathEntity;
|
||||||
|
if (p_75876_1_ == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (p_75876_1_.points.length != this.points.length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.points.length; ++i)
|
||||||
|
{
|
||||||
|
if (this.points[i].xCoord != p_75876_1_.points[i].xCoord || this.points[i].yCoord != p_75876_1_.points[i].yCoord || this.points[i].zCoord != p_75876_1_.points[i].zCoord)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
|
||||||
|
*/
|
||||||
|
public boolean isDestinationSame(Vec3 p_75880_1_)
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = this.getFinalPathPoint();
|
||||||
|
return pathpoint == null ? false : pathpoint.xCoord == (int)p_75880_1_.xCoord && pathpoint.zCoord == (int)p_75880_1_.zCoord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.PathFinder;
|
||||||
|
import net.minecraft.util.IntHashMap;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class FlyPathFinder extends PathFinder
|
||||||
|
{
|
||||||
|
/** Used to find obstacles */
|
||||||
|
private IBlockAccess worldMap;
|
||||||
|
/** The path being generated */
|
||||||
|
private FlyPath path = new FlyPath();
|
||||||
|
/** The points in the path */
|
||||||
|
private IntHashMap pointMap = new IntHashMap();
|
||||||
|
/** Selection of path points to add to the path */
|
||||||
|
private FlyPathPoint[] pathOptions = new FlyPathPoint[32];
|
||||||
|
/** should the PathFinder go through wodden door blocks */
|
||||||
|
private boolean isWoddenDoorAllowed;
|
||||||
|
/** should the PathFinder disregard BlockMovement type materials in its path */
|
||||||
|
private boolean isMovementBlockAllowed;
|
||||||
|
private boolean isPathingInWater;
|
||||||
|
/** tells the FathFinder to not stop pathing underwater */
|
||||||
|
private boolean canEntityDrown;
|
||||||
|
private static final String __OBFID = "CL_00000576";
|
||||||
|
|
||||||
|
public FlyPathFinder(IBlockAccess p_i2137_1_, boolean p_i2137_2_, boolean p_i2137_3_, boolean p_i2137_4_, boolean p_i2137_5_)
|
||||||
|
{
|
||||||
|
super(p_i2137_1_,p_i2137_2_,p_i2137_3_,p_i2137_4_,p_i2137_5_);
|
||||||
|
this.worldMap = p_i2137_1_;
|
||||||
|
this.isWoddenDoorAllowed = p_i2137_2_;
|
||||||
|
this.isMovementBlockAllowed = p_i2137_3_;
|
||||||
|
this.isPathingInWater = p_i2137_4_;
|
||||||
|
this.canEntityDrown = p_i2137_5_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a path from one entity to another within a minimum distance
|
||||||
|
*/
|
||||||
|
public FlyPathEntity createEntityPathTo(Entity p_75856_1_, Entity p_75856_2_, float p_75856_3_)
|
||||||
|
{
|
||||||
|
return this.createEntityPathTo(p_75856_1_, p_75856_2_.posX, p_75856_2_.boundingBox.minY, p_75856_2_.posZ, p_75856_3_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a path from an entity to a specified location within a minimum distance
|
||||||
|
*/
|
||||||
|
public FlyPathEntity createEntityPathTo(Entity p_75859_1_, int p_75859_2_, int p_75859_3_, int p_75859_4_, float p_75859_5_)
|
||||||
|
{
|
||||||
|
return this.createEntityPathTo(p_75859_1_, (double)((float)p_75859_2_ + 0.5F), (double)((float)p_75859_3_ + 0.5F), (double)((float)p_75859_4_ + 0.5F), p_75859_5_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation of creating a path from an entity to a point
|
||||||
|
*/
|
||||||
|
private FlyPathEntity createEntityPathTo(Entity p_75857_1_, double p_75857_2_, double p_75857_4_, double p_75857_6_, float p_75857_8_)
|
||||||
|
{
|
||||||
|
this.path.clearPath();
|
||||||
|
this.pointMap.clearMap();
|
||||||
|
boolean flag = this.isPathingInWater;
|
||||||
|
int i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
|
||||||
|
|
||||||
|
if (this.canEntityDrown && p_75857_1_.isInWater())
|
||||||
|
{
|
||||||
|
i = (int)p_75857_1_.boundingBox.minY;
|
||||||
|
|
||||||
|
for (Block block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)))
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
flag = this.isPathingInWater;
|
||||||
|
this.isPathingInWater = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
FlyPathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(p_75857_1_.boundingBox.minX), i, MathHelper.floor_double(p_75857_1_.boundingBox.minZ));
|
||||||
|
FlyPathPoint pathpoint = this.openPoint(MathHelper.floor_double(p_75857_2_ - (double)(p_75857_1_.width / 2.0F)), MathHelper.floor_double(p_75857_4_), MathHelper.floor_double(p_75857_6_ - (double)(p_75857_1_.width / 2.0F)));
|
||||||
|
FlyPathPoint pathpoint1 = new FlyPathPoint(MathHelper.floor_float(p_75857_1_.width + 1.0F), MathHelper.floor_float(p_75857_1_.height + 1.0F), MathHelper.floor_float(p_75857_1_.width + 1.0F));
|
||||||
|
FlyPathEntity pathentity = this.addToPath(p_75857_1_, pathpoint2, pathpoint, pathpoint1, p_75857_8_);
|
||||||
|
this.isPathingInWater = flag;
|
||||||
|
return pathentity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a path from start to end and returns the whole path (args: unused, start, end, unused, maxDistance)
|
||||||
|
*/
|
||||||
|
private FlyPathEntity addToPath(Entity p_75861_1_, FlyPathPoint p_75861_2_, FlyPathPoint p_75861_3_, FlyPathPoint p_75861_4_, float p_75861_5_)
|
||||||
|
{
|
||||||
|
p_75861_2_.totalPathDistance = 0.0F;
|
||||||
|
p_75861_2_.distanceToNext = p_75861_2_.distanceToSquared(p_75861_3_);
|
||||||
|
p_75861_2_.distanceToTarget = p_75861_2_.distanceToNext;
|
||||||
|
this.path.clearPath();
|
||||||
|
this.path.addPoint(p_75861_2_);
|
||||||
|
FlyPathPoint pathpoint3 = p_75861_2_;
|
||||||
|
|
||||||
|
while (!this.path.isPathEmpty())
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint4 = this.path.dequeue();
|
||||||
|
|
||||||
|
if (pathpoint4.equals(p_75861_3_))
|
||||||
|
{
|
||||||
|
return this.createEntityPath(p_75861_2_, p_75861_3_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_))
|
||||||
|
{
|
||||||
|
pathpoint3 = pathpoint4;
|
||||||
|
}
|
||||||
|
|
||||||
|
pathpoint4.isFirst = true;
|
||||||
|
int i = this.findPathOptions(p_75861_1_, pathpoint4, p_75861_4_, p_75861_3_, p_75861_5_);
|
||||||
|
|
||||||
|
for (int j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint5 = this.pathOptions[j];
|
||||||
|
float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5);
|
||||||
|
|
||||||
|
if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
|
||||||
|
{
|
||||||
|
pathpoint5.previous = pathpoint4;
|
||||||
|
pathpoint5.totalPathDistance = f1;
|
||||||
|
pathpoint5.distanceToNext = pathpoint5.distanceToSquared(p_75861_3_);
|
||||||
|
|
||||||
|
if (pathpoint5.isAssigned())
|
||||||
|
{
|
||||||
|
this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
|
||||||
|
this.path.addPoint(pathpoint5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint3 == p_75861_2_)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.createEntityPath(p_75861_2_, pathpoint3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint,
|
||||||
|
* unused2, targetPoint, maxDistance)
|
||||||
|
*/
|
||||||
|
private int findPathOptions(Entity p_75860_1_, FlyPathPoint p_75860_2_, FlyPathPoint p_75860_3_, FlyPathPoint p_75860_4_, float p_75860_5_)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
byte b0 = 0;
|
||||||
|
|
||||||
|
if (this.getVerticalOffset(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_) == 1)
|
||||||
|
{
|
||||||
|
b0 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int y = -1; y <= 1; y ++) {
|
||||||
|
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
|
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
|
this.pathOptions[i++] = pathpoint3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a point that the entity can safely move to
|
||||||
|
*/
|
||||||
|
private FlyPathPoint getSafePoint(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, int verticalOffsetFlag)
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint1 = null;
|
||||||
|
int verticalOffset = this.getVerticalOffset(entity, blockX, blockY, blockZ, pathPoint);
|
||||||
|
|
||||||
|
if (verticalOffset == 2)
|
||||||
|
{
|
||||||
|
return this.openPoint(blockX, blockY, blockZ);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (verticalOffset == 1)
|
||||||
|
{
|
||||||
|
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint1 == null && verticalOffsetFlag > 0 && verticalOffset != -3 && verticalOffset != -4 && this.getVerticalOffset(entity, blockX, blockY + verticalOffsetFlag, blockZ, pathPoint) == 1)
|
||||||
|
{
|
||||||
|
pathpoint1 = this.openPoint(blockX, blockY + verticalOffsetFlag, blockZ);
|
||||||
|
blockY += verticalOffsetFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint1 != null)
|
||||||
|
{
|
||||||
|
int j1 = 0;
|
||||||
|
int k1 = 0;
|
||||||
|
|
||||||
|
while (blockY > 0)
|
||||||
|
{
|
||||||
|
k1 = this.getVerticalOffset(entity, blockX, blockY - 1, blockZ, pathPoint);
|
||||||
|
|
||||||
|
if (this.isPathingInWater && k1 == -1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 != 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j1++ >= entity.getMaxSafePointTries())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
--blockY;
|
||||||
|
|
||||||
|
if (blockY > 0)
|
||||||
|
{
|
||||||
|
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 == -2)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathpoint1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a mapped point or creates and adds one
|
||||||
|
*/
|
||||||
|
private final FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_)
|
||||||
|
{
|
||||||
|
int l = FlyPathPoint.makeHash(p_75854_1_, p_75854_2_, p_75854_3_);
|
||||||
|
FlyPathPoint pathpoint = (FlyPathPoint)this.pointMap.lookup(l);
|
||||||
|
|
||||||
|
if (pathpoint == null)
|
||||||
|
{
|
||||||
|
pathpoint = new FlyPathPoint(p_75854_1_, p_75854_2_, p_75854_3_);
|
||||||
|
this.pointMap.addKey(l, pathpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an entity collides with blocks at a position. Returns 1 if clear, 0 for colliding with any solid block,
|
||||||
|
* -1 for water(if avoiding water) but otherwise clear, -2 for lava, -3 for fence, -4 for closed trapdoor, 2 if
|
||||||
|
* otherwise clear except for open trapdoor or water(if not avoiding)
|
||||||
|
*/
|
||||||
|
public int getVerticalOffset(Entity p_75855_1_, int p_75855_2_, int p_75855_3_, int p_75855_4_, FlyPathPoint p_75855_5_)
|
||||||
|
{
|
||||||
|
return canEntityStandAt(p_75855_1_, p_75855_2_, p_75855_3_, p_75855_4_, p_75855_5_, this.isPathingInWater, this.isMovementBlockAllowed, this.isWoddenDoorAllowed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int canEntityStandAt(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, boolean isPathingInWater, boolean isMovementBlockAllowed, boolean isWoddenDoorAllowed)
|
||||||
|
{
|
||||||
|
boolean flag3 = false;
|
||||||
|
|
||||||
|
for (int l = blockX; l < blockX + pathPoint.xCoord; ++l)
|
||||||
|
{
|
||||||
|
for (int i1 = blockY; i1 < blockY + pathPoint.yCoord; ++i1)
|
||||||
|
{
|
||||||
|
for (int j1 = blockZ; j1 < blockZ + pathPoint.zCoord; ++j1)
|
||||||
|
{
|
||||||
|
Block block = entity.worldObj.getBlock(l, i1, j1);
|
||||||
|
|
||||||
|
if(block == Blocks.air)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block == Blocks.trapdoor)
|
||||||
|
{
|
||||||
|
flag3 = true;
|
||||||
|
}
|
||||||
|
else if (block != Blocks.flowing_water && block != Blocks.water)
|
||||||
|
{
|
||||||
|
if (!isWoddenDoorAllowed && block == Blocks.wooden_door)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isPathingInWater)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
flag3 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int k1 = block.getRenderType();
|
||||||
|
|
||||||
|
if (entity.worldObj.getBlock(l, i1, j1).getRenderType() == 9)
|
||||||
|
{
|
||||||
|
int j2 = MathHelper.floor_double(entity.posX);
|
||||||
|
int l1 = MathHelper.floor_double(entity.posY);
|
||||||
|
int i2 = MathHelper.floor_double(entity.posZ);
|
||||||
|
|
||||||
|
if (entity.worldObj.getBlock(j2, l1, i2).getRenderType() != 9 && entity.worldObj.getBlock(j2, l1 - 1, i2).getRenderType() != 9)
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!block.getBlocksMovement(entity.worldObj, l, i1, j1) && (!isMovementBlockAllowed || block != Blocks.wooden_door))
|
||||||
|
{
|
||||||
|
if (k1 == 11 || block == Blocks.fence_gate || k1 == 32)
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block == Blocks.trapdoor)
|
||||||
|
{
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
Material material = block.getMaterial();
|
||||||
|
|
||||||
|
if (material != Material.lava)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.handleLavaMovement())
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag3 ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new FlyPathEntity for a given start and end point
|
||||||
|
*/
|
||||||
|
private FlyPathEntity createEntityPath(FlyPathPoint p_75853_1_, FlyPathPoint p_75853_2_)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
FlyPathPoint pathpoint2;
|
||||||
|
|
||||||
|
for (pathpoint2 = p_75853_2_; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlyPathPoint[] apathpoint = new FlyPathPoint[i];
|
||||||
|
pathpoint2 = p_75853_2_;
|
||||||
|
--i;
|
||||||
|
|
||||||
|
for (apathpoint[i] = p_75853_2_; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
|
||||||
|
{
|
||||||
|
pathpoint2 = pathpoint2.previous;
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FlyPathEntity(apathpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
|
public class FlyPathPoint extends PathPoint
|
||||||
|
{
|
||||||
|
/** The x coordinate of this point */
|
||||||
|
public final int xCoord;
|
||||||
|
/** The y coordinate of this point */
|
||||||
|
public final int yCoord;
|
||||||
|
/** The z coordinate of this point */
|
||||||
|
public final int zCoord;
|
||||||
|
/** A hash of the coordinates used to identify this point */
|
||||||
|
public final int hash;
|
||||||
|
/** The index of this point in its assigned path */
|
||||||
|
public int index = -1;
|
||||||
|
/** The distance along the path to this point */
|
||||||
|
public float totalPathDistance;
|
||||||
|
/** The linear distance to the next point */
|
||||||
|
public float distanceToNext;
|
||||||
|
/** The distance to the target */
|
||||||
|
public float distanceToTarget;
|
||||||
|
/** The point preceding this in its assigned path */
|
||||||
|
public FlyPathPoint previous;
|
||||||
|
/** Indicates this is the origin */
|
||||||
|
public boolean isFirst;
|
||||||
|
private static final String __OBFID = "CL_00000574";
|
||||||
|
|
||||||
|
public FlyPathPoint(int p_i2135_1_, int p_i2135_2_, int p_i2135_3_)
|
||||||
|
{
|
||||||
|
super(p_i2135_1_,p_i2135_2_,p_i2135_3_);
|
||||||
|
this.xCoord = p_i2135_1_;
|
||||||
|
this.yCoord = p_i2135_2_;
|
||||||
|
this.zCoord = p_i2135_3_;
|
||||||
|
this.hash = makeHash(p_i2135_1_, p_i2135_2_, p_i2135_3_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int makeHash(int p_75830_0_, int p_75830_1_, int p_75830_2_)
|
||||||
|
{
|
||||||
|
return p_75830_1_ & 255 | (p_75830_0_ & 32767) << 8 | (p_75830_2_ & 32767) << 24 | (p_75830_0_ < 0 ? Integer.MIN_VALUE : 0) | (p_75830_2_ < 0 ? 32768 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the linear distance to another path point
|
||||||
|
*/
|
||||||
|
public float distanceTo(net.minecraft.pathfinding.PathPoint p_75829_1_)
|
||||||
|
{
|
||||||
|
float f = (float)(p_75829_1_.xCoord - this.xCoord);
|
||||||
|
float f1 = (float)(p_75829_1_.yCoord - this.yCoord);
|
||||||
|
float f2 = (float)(p_75829_1_.zCoord - this.zCoord);
|
||||||
|
return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the squared distance to another path point
|
||||||
|
*/
|
||||||
|
public float distanceToSquared(net.minecraft.pathfinding.PathPoint p_75832_1_)
|
||||||
|
{
|
||||||
|
float f = (float)(p_75832_1_.xCoord - this.xCoord);
|
||||||
|
float f1 = (float)(p_75832_1_.yCoord - this.yCoord);
|
||||||
|
float f2 = (float)(p_75832_1_.zCoord - this.zCoord);
|
||||||
|
return f * f + f1 * f1 + f2 * f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object p_equals_1_)
|
||||||
|
{
|
||||||
|
if (!(p_equals_1_ instanceof FlyPathPoint))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FlyPathPoint pathpoint = (FlyPathPoint)p_equals_1_;
|
||||||
|
return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return this.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this point has already been assigned to a path
|
||||||
|
*/
|
||||||
|
public boolean isAssigned()
|
||||||
|
{
|
||||||
|
return this.index >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.xCoord + ", " + this.yCoord + ", " + this.zCoord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.EntityMoveHelper;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
|
// Fly Change
|
||||||
|
|
||||||
|
public class FlyingMoveHelper extends EntityMoveHelper{
|
||||||
|
private final EntityNPCInterface entity;
|
||||||
|
|
||||||
|
private double posX;
|
||||||
|
private double posY;
|
||||||
|
private double posZ;
|
||||||
|
private double speed;
|
||||||
|
private boolean update;
|
||||||
|
|
||||||
|
public FlyingMoveHelper(EntityNPCInterface entity){
|
||||||
|
super(entity);
|
||||||
|
this.entity = entity;
|
||||||
|
this.posX = entity.posX;
|
||||||
|
this.posY = entity.posY;
|
||||||
|
this.posZ = entity.posZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpdateMoveHelper() {
|
||||||
|
if (this.update) {
|
||||||
|
this.update = false;
|
||||||
|
|
||||||
|
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
|
||||||
|
|
||||||
|
double d0 = this.posX - this.entity.posX;
|
||||||
|
double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D);
|
||||||
|
double d2 = this.posZ - this.entity.posZ;
|
||||||
|
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
double d5 = MathHelper.sqrt_double(d4);
|
||||||
|
|
||||||
|
double heightOffGround = 0;
|
||||||
|
if(this.entity.ai.hasFlyLimit) {
|
||||||
|
for (int 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 (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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
|
||||||
|
{
|
||||||
|
float f3 = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);
|
||||||
|
|
||||||
|
if (f3 > p_75639_3_)
|
||||||
|
{
|
||||||
|
f3 = p_75639_3_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f3 < -p_75639_3_)
|
||||||
|
{
|
||||||
|
f3 = -p_75639_3_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p_75639_1_ + f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the speed and location to move to
|
||||||
|
*/
|
||||||
|
public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_)
|
||||||
|
{
|
||||||
|
this.posX = p_75642_1_;
|
||||||
|
this.posY = p_75642_3_;
|
||||||
|
this.posZ = p_75642_5_;
|
||||||
|
this.speed = p_75642_7_;
|
||||||
|
this.update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUpdating()
|
||||||
|
{
|
||||||
|
return this.update;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSpeed()
|
||||||
|
{
|
||||||
|
return this.speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.Path;
|
||||||
|
import net.minecraft.pathfinding.PathEntity;
|
||||||
|
import net.minecraft.pathfinding.PathFinder;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class NPCPathFinder extends PathFinder
|
||||||
|
{
|
||||||
|
|
||||||
|
public IBlockAccess worldMap;
|
||||||
|
|
||||||
|
public Path path = new Path();
|
||||||
|
public NPCPathPoint[] pathOptions = new NPCPathPoint[32];
|
||||||
|
|
||||||
|
private final NodeProcessor nodeProcessor;
|
||||||
|
|
||||||
|
public NPCPathFinder(NodeProcessor nodeProcessorIn)
|
||||||
|
{
|
||||||
|
super(nodeProcessorIn.blockaccess, true, true, false, false);
|
||||||
|
this.nodeProcessor = nodeProcessorIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a path from one entity to another within a minimum distance
|
||||||
|
*/
|
||||||
|
public PathEntity createEntityPathTo(Entity p_75856_1_, Entity p_75856_2_, float p_75856_3_)
|
||||||
|
{
|
||||||
|
return this.createEntityPathTo(p_75856_1_, p_75856_2_.posX, p_75856_2_.boundingBox.minY, p_75856_2_.posZ, p_75856_3_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a path from an entity to a specified location within a minimum distance
|
||||||
|
*/
|
||||||
|
public PathEntity createEntityPathTo(Entity p_75859_1_, int p_75859_2_, int p_75859_3_, int p_75859_4_, float p_75859_5_)
|
||||||
|
{
|
||||||
|
return this.createEntityPathTo(p_75859_1_, (double)((float)p_75859_2_ + 0.5F), (double)((float)p_75859_3_ + 0.5F), (double)((float)p_75859_4_ + 0.5F), p_75859_5_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation of creating a path from an entity to a point
|
||||||
|
*/
|
||||||
|
public PathEntity createEntityPathTo(Entity p_75857_1_, double p_75857_2_, double p_75857_4_, double p_75857_6_, float p_75857_8_)
|
||||||
|
{
|
||||||
|
this.path.clearPath();
|
||||||
|
this.nodeProcessor.initProcessor(worldMap, p_75857_1_);
|
||||||
|
NPCPathPoint pathpoint = (NPCPathPoint) this.nodeProcessor.getPathPointTo(p_75857_1_);
|
||||||
|
NPCPathPoint pathpoint1 = (NPCPathPoint) this.nodeProcessor.getPathPointToCoords(p_75857_1_, p_75857_2_, p_75857_4_, p_75857_6_);
|
||||||
|
PathEntity pathentity = this.addToPath(p_75857_1_, pathpoint, pathpoint1, p_75857_8_);
|
||||||
|
this.nodeProcessor.postProcess();
|
||||||
|
return pathentity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PathEntity addToPath(Entity entityIn, NPCPathPoint pathpointStart, NPCPathPoint pathpointEnd, float maxDistance)
|
||||||
|
{
|
||||||
|
pathpointStart.totalPathDistance = 0.0F;
|
||||||
|
pathpointStart.distanceToNext = pathpointStart.distanceToSquared(pathpointEnd);
|
||||||
|
pathpointStart.distanceToTarget = pathpointStart.distanceToNext;
|
||||||
|
this.path.clearPath();
|
||||||
|
this.path.addPoint(pathpointStart);
|
||||||
|
NPCPathPoint pathpoint = pathpointStart;
|
||||||
|
|
||||||
|
while (!this.path.isPathEmpty())
|
||||||
|
{
|
||||||
|
NPCPathPoint pathpoint1 = (NPCPathPoint) this.path.dequeue();
|
||||||
|
|
||||||
|
if (pathpoint1.equals(pathpointEnd))
|
||||||
|
{
|
||||||
|
return this.createEntityPath(pathpointStart, pathpointEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint1.distanceToSquared(pathpointEnd) < pathpoint.distanceToSquared(pathpointEnd))
|
||||||
|
{
|
||||||
|
pathpoint = pathpoint1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pathpoint1.isFirst = true;
|
||||||
|
int i = this.nodeProcessor.findPathOptions(this.pathOptions, entityIn, pathpoint1, pathpointEnd, maxDistance);
|
||||||
|
|
||||||
|
for (int j = 0; j < i; ++j)
|
||||||
|
{
|
||||||
|
NPCPathPoint pathpoint2 = (NPCPathPoint) this.pathOptions[j];
|
||||||
|
float f = pathpoint1.totalPathDistance + pathpoint1.distanceToSquared(pathpoint2);
|
||||||
|
|
||||||
|
if (f < maxDistance * 2.0F && (!pathpoint2.isAssigned() || f < pathpoint2.totalPathDistance))
|
||||||
|
{
|
||||||
|
pathpoint2.previous = pathpoint1;
|
||||||
|
pathpoint2.totalPathDistance = f;
|
||||||
|
pathpoint2.distanceToNext = pathpoint2.distanceToSquared(pathpointEnd);
|
||||||
|
|
||||||
|
if (pathpoint2.isAssigned())
|
||||||
|
{
|
||||||
|
this.path.changeDistance(pathpoint2, pathpoint2.totalPathDistance + pathpoint2.distanceToNext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathpoint2.distanceToTarget = pathpoint2.totalPathDistance + pathpoint2.distanceToNext;
|
||||||
|
this.path.addPoint(pathpoint2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint == pathpointStart)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.createEntityPath(pathpointStart, pathpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new PathEntity for a given start and end point
|
||||||
|
*/
|
||||||
|
private PathEntity createEntityPath(NPCPathPoint p_75853_1_, NPCPathPoint p_75853_2_)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
NPCPathPoint pathpoint2;
|
||||||
|
|
||||||
|
for (pathpoint2 = p_75853_2_; pathpoint2.previous != null; pathpoint2 = (NPCPathPoint) pathpoint2.previous)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
NPCPathPoint[] apathpoint = new NPCPathPoint[i];
|
||||||
|
pathpoint2 = p_75853_2_;
|
||||||
|
--i;
|
||||||
|
|
||||||
|
for (apathpoint[i] = p_75853_2_; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
|
||||||
|
{
|
||||||
|
pathpoint2 = (NPCPathPoint) pathpoint2.previous;
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PathEntity(apathpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
|
public class NPCPathPoint extends PathPoint
|
||||||
|
{
|
||||||
|
/** The index of this point in its assigned path */
|
||||||
|
public int index = -1;
|
||||||
|
/** The distance along the path to this point */
|
||||||
|
public float totalPathDistance;
|
||||||
|
/** The linear distance to the next point */
|
||||||
|
public float distanceToNext;
|
||||||
|
/** The distance to the target */
|
||||||
|
public float distanceToTarget;
|
||||||
|
public PathPoint previous;
|
||||||
|
|
||||||
|
public NPCPathPoint(int p_i2135_1_, int p_i2135_2_, int p_i2135_3_)
|
||||||
|
{
|
||||||
|
super(p_i2135_1_, p_i2135_2_,p_i2135_3_);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.IntHashMap;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public abstract class NodeProcessor
|
||||||
|
{
|
||||||
|
public IBlockAccess blockaccess;
|
||||||
|
public IntHashMap pointMap = new IntHashMap();
|
||||||
|
public int entitySizeX;
|
||||||
|
public int entitySizeY;
|
||||||
|
public int entitySizeZ;
|
||||||
|
|
||||||
|
|
||||||
|
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
|
||||||
|
{
|
||||||
|
this.blockaccess = iblockaccessIn;
|
||||||
|
this.pointMap.clearMap();
|
||||||
|
this.entitySizeX = MathHelper.floor_float(entityIn.width + 1.0F);
|
||||||
|
this.entitySizeY = MathHelper.floor_float(entityIn.height + 1.0F);
|
||||||
|
this.entitySizeZ = MathHelper.floor_float(entityIn.width + 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postProcess()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PathPoint openPoint(int x, int y, int z)
|
||||||
|
{
|
||||||
|
int i = NPCPathPoint.makeHash(x, y, z);
|
||||||
|
NPCPathPoint pathpoint = (NPCPathPoint)this.pointMap.lookup(i);
|
||||||
|
|
||||||
|
if (pathpoint == null)
|
||||||
|
{
|
||||||
|
pathpoint = new NPCPathPoint(x, y, z);
|
||||||
|
this.pointMap.addKey(i, pathpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract PathPoint getPathPointTo(Entity entityIn);
|
||||||
|
|
||||||
|
public abstract PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target);
|
||||||
|
|
||||||
|
public abstract int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance);
|
||||||
|
}
|
||||||
@@ -0,0 +1,491 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.PathEntity;
|
||||||
|
import net.minecraft.pathfinding.PathNavigate;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.ChunkCache;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
|
public class PathNavigateFlying extends PathNavigate {
|
||||||
|
private EntityNPCInterface theEntity;
|
||||||
|
private World worldObj;
|
||||||
|
/** The PathEntity being followed. */
|
||||||
|
private FlyPathEntity currentPath;
|
||||||
|
private double speed;
|
||||||
|
/** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */
|
||||||
|
private IAttributeInstance pathSearchRange;
|
||||||
|
private boolean noSunPathfind;
|
||||||
|
/** Time, in number of ticks, following the current path */
|
||||||
|
private int totalTicks;
|
||||||
|
/** The time when the last position check was done (to detect successful movement) */
|
||||||
|
private int ticksAtLastPos;
|
||||||
|
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
|
||||||
|
private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||||
|
/** Specifically, if a wooden door block is even considered to be passable by the pathfinder */
|
||||||
|
private boolean canPassOpenWoodenDoors = true;
|
||||||
|
/** If door blocks are considered passable even when closed */
|
||||||
|
private boolean canPassClosedWoodenDoors;
|
||||||
|
/** If water blocks are avoided (at least by the pathfinder) */
|
||||||
|
private boolean avoidsWater;
|
||||||
|
/**
|
||||||
|
* If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
|
||||||
|
* upwards when underwater
|
||||||
|
*/
|
||||||
|
private boolean canSwim;
|
||||||
|
private static final String __OBFID = "CL_00001627";
|
||||||
|
|
||||||
|
public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) {
|
||||||
|
super(p_i45873_1_, worldIn);
|
||||||
|
this.theEntity = (EntityNPCInterface)p_i45873_1_;
|
||||||
|
this.worldObj = worldIn;
|
||||||
|
this.pathSearchRange = p_i45873_1_.getEntityAttribute(SharedMonsterAttributes.followRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvoidsWater(boolean p_75491_1_)
|
||||||
|
{
|
||||||
|
this.avoidsWater = p_75491_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAvoidsWater()
|
||||||
|
{
|
||||||
|
return this.avoidsWater;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBreakDoors(boolean p_75498_1_)
|
||||||
|
{
|
||||||
|
this.canPassClosedWoodenDoors = p_75498_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the entity can enter open doors
|
||||||
|
*/
|
||||||
|
public void setEnterDoors(boolean p_75490_1_)
|
||||||
|
{
|
||||||
|
this.canPassOpenWoodenDoors = p_75490_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the entity can break doors, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean getCanBreakDoors()
|
||||||
|
{
|
||||||
|
return this.canPassClosedWoodenDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the path should avoid sunlight
|
||||||
|
*/
|
||||||
|
public void setAvoidSun(boolean p_75504_1_)
|
||||||
|
{
|
||||||
|
this.noSunPathfind = p_75504_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the speed
|
||||||
|
*/
|
||||||
|
public void setSpeed(double p_75489_1_)
|
||||||
|
{
|
||||||
|
this.speed = p_75489_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the entity can swim
|
||||||
|
*/
|
||||||
|
public void setCanSwim(boolean p_75495_1_)
|
||||||
|
{
|
||||||
|
this.canSwim = p_75495_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum distance that the path finding will search in.
|
||||||
|
*/
|
||||||
|
public float getPathSearchRange()
|
||||||
|
{
|
||||||
|
return (float)this.pathSearchRange.getAttributeValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to the given coordinates
|
||||||
|
*/
|
||||||
|
public FlyPathEntity getPathToXYZ(double p_75488_1_, double p_75488_3_, double p_75488_5_)
|
||||||
|
{
|
||||||
|
return !this.canNavigate() ? null : this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find and set a path to XYZ. Returns true if successful.
|
||||||
|
*/
|
||||||
|
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_)
|
||||||
|
{
|
||||||
|
FlyPathEntity pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_));
|
||||||
|
return this.setPath(pathentity, p_75492_7_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to the given EntityLiving
|
||||||
|
*/
|
||||||
|
public FlyPathEntity getPathToEntityLiving(Entity p_75494_1_)
|
||||||
|
{
|
||||||
|
return !this.canNavigate() ? null : this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find and set a path to EntityLiving. Returns true if successful.
|
||||||
|
*/
|
||||||
|
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_)
|
||||||
|
{
|
||||||
|
FlyPathEntity pathentity = this.getPathToEntityLiving(p_75497_1_);
|
||||||
|
return pathentity != null && this.setPath(pathentity, p_75497_2_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
|
||||||
|
* ents and stores end coords
|
||||||
|
*/
|
||||||
|
public boolean setPath(PathEntity pathEntity, double p_75484_2_)
|
||||||
|
{
|
||||||
|
FlyPathEntity p_75484_1_ = (FlyPathEntity) pathEntity;
|
||||||
|
if (p_75484_1_ == null)
|
||||||
|
{
|
||||||
|
this.currentPath = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!p_75484_1_.isSamePath(this.currentPath))
|
||||||
|
{
|
||||||
|
this.currentPath = p_75484_1_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.noSunPathfind)
|
||||||
|
{
|
||||||
|
this.removeSunnyPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.currentPath.getCurrentPathLength() == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.speed = p_75484_2_;
|
||||||
|
Vec3 vec3 = this.getEntityPosition();
|
||||||
|
this.ticksAtLastPos = this.totalTicks;
|
||||||
|
this.lastPosCheck.xCoord = vec3.xCoord;
|
||||||
|
this.lastPosCheck.yCoord = vec3.yCoord;
|
||||||
|
this.lastPosCheck.zCoord = vec3.zCoord;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the actively used PathEntity
|
||||||
|
*/
|
||||||
|
public PathEntity getPath()
|
||||||
|
{
|
||||||
|
return this.currentPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpdateNavigation()
|
||||||
|
{
|
||||||
|
++this.totalTicks;
|
||||||
|
|
||||||
|
if (!this.noPath())
|
||||||
|
{
|
||||||
|
if (this.canNavigate())
|
||||||
|
{
|
||||||
|
this.pathFollow();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.noPath())
|
||||||
|
{
|
||||||
|
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
|
||||||
|
|
||||||
|
if (vec3 != null)
|
||||||
|
{
|
||||||
|
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pathFollow()
|
||||||
|
{
|
||||||
|
Vec3 vec3 = this.getEntityPosition();
|
||||||
|
int i = this.currentPath.getCurrentPathLength();
|
||||||
|
|
||||||
|
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
|
||||||
|
{
|
||||||
|
if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
|
||||||
|
{
|
||||||
|
i = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float f = this.theEntity.width * this.theEntity.width;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
|
||||||
|
{
|
||||||
|
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f)
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathIndex(k + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k = MathHelper.ceiling_float_int(this.theEntity.width);
|
||||||
|
int l = (int)this.theEntity.height + 1;
|
||||||
|
int i1 = k;
|
||||||
|
|
||||||
|
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
|
||||||
|
{
|
||||||
|
if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathIndex(j1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.totalTicks - this.ticksAtLastPos > 100)
|
||||||
|
{
|
||||||
|
if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
|
||||||
|
{
|
||||||
|
this.clearPathEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ticksAtLastPos = this.totalTicks;
|
||||||
|
this.lastPosCheck.xCoord = vec3.xCoord;
|
||||||
|
this.lastPosCheck.yCoord = vec3.yCoord;
|
||||||
|
this.lastPosCheck.zCoord = vec3.zCoord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If null path or reached the end
|
||||||
|
*/
|
||||||
|
public boolean noPath()
|
||||||
|
{
|
||||||
|
return this.currentPath == null || this.currentPath.isFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets active PathEntity to null
|
||||||
|
*/
|
||||||
|
public void clearPathEntity()
|
||||||
|
{
|
||||||
|
this.currentPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vec3 getEntityPosition()
|
||||||
|
{
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
private double getPathableYPos()
|
||||||
|
{
|
||||||
|
return this.theEntity.boundingBox.minY + 0.05D;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If on ground or swimming and can swim
|
||||||
|
*/
|
||||||
|
private boolean canNavigate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an entity could stand at a position, including solid blocks under the entire entity. Args:
|
||||||
|
* xOffset, yOffset, zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
|
||||||
|
*/
|
||||||
|
private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims path data from the end to the first sun covered block
|
||||||
|
*/
|
||||||
|
private void removeSunnyPath()
|
||||||
|
{
|
||||||
|
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
|
||||||
|
|
||||||
|
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathLength(i - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||||
|
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||||
|
*/
|
||||||
|
private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_)
|
||||||
|
{
|
||||||
|
int l = MathHelper.floor_double(p_75493_1_.xCoord);
|
||||||
|
int i1 = MathHelper.floor_double(p_75493_1_.zCoord);
|
||||||
|
double d0 = p_75493_2_.xCoord - p_75493_1_.xCoord;
|
||||||
|
double d1 = p_75493_2_.zCoord - p_75493_1_.zCoord;
|
||||||
|
double d2 = d0 * d0 + d1 * d1;
|
||||||
|
|
||||||
|
if (d2 < 1.0E-8D)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double d3 = 1.0D / Math.sqrt(d2);
|
||||||
|
d0 *= d3;
|
||||||
|
d1 *= d3;
|
||||||
|
p_75493_3_ += 2;
|
||||||
|
p_75493_5_ += 2;
|
||||||
|
|
||||||
|
if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p_75493_3_ -= 2;
|
||||||
|
p_75493_5_ -= 2;
|
||||||
|
double d4 = 1.0D / Math.abs(d0);
|
||||||
|
double d5 = 1.0D / Math.abs(d1);
|
||||||
|
double d6 = (double)(l * 1) - p_75493_1_.xCoord;
|
||||||
|
double d7 = (double)(i1 * 1) - p_75493_1_.zCoord;
|
||||||
|
|
||||||
|
if (d0 >= 0.0D)
|
||||||
|
{
|
||||||
|
++d6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d1 >= 0.0D)
|
||||||
|
{
|
||||||
|
++d7;
|
||||||
|
}
|
||||||
|
|
||||||
|
d6 /= d0;
|
||||||
|
d7 /= d1;
|
||||||
|
int j1 = d0 < 0.0D ? -1 : 1;
|
||||||
|
int k1 = d1 < 0.0D ? -1 : 1;
|
||||||
|
int l1 = MathHelper.floor_double(p_75493_2_.xCoord);
|
||||||
|
int i2 = MathHelper.floor_double(p_75493_2_.zCoord);
|
||||||
|
int j2 = l1 - l;
|
||||||
|
int k2 = i2 - i1;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (j2 * j1 <= 0 && k2 * k1 <= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d6 < d7)
|
||||||
|
{
|
||||||
|
d6 += d4;
|
||||||
|
l += j1;
|
||||||
|
j2 = l1 - l;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d7 += d5;
|
||||||
|
i1 += k1;
|
||||||
|
k2 = i2 - i1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if an entity does not collide with any solid blocks at the position. Args: xOffset, yOffset,
|
||||||
|
* zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
|
||||||
|
*/
|
||||||
|
private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_)
|
||||||
|
{
|
||||||
|
for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1)
|
||||||
|
{
|
||||||
|
for (int l1 = p_75496_2_; l1 < p_75496_2_ + p_75496_5_; ++l1)
|
||||||
|
{
|
||||||
|
for (int i2 = p_75496_3_; i2 < p_75496_3_ + p_75496_6_; ++i2)
|
||||||
|
{
|
||||||
|
double d2 = (double)k1 + 0.5D - p_75496_7_.xCoord;
|
||||||
|
double d3 = (double)i2 + 0.5D - p_75496_7_.zCoord;
|
||||||
|
|
||||||
|
if (d2 * p_75496_8_ + d3 * p_75496_10_ >= 0.0D)
|
||||||
|
{
|
||||||
|
Block block = this.worldObj.getBlock(k1, l1, i2);
|
||||||
|
|
||||||
|
if (!block.getBlocksMovement(this.worldObj, k1, l1, i2))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlyPathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
|
||||||
|
{
|
||||||
|
this.theEntity.worldObj.theProfiler.startSection("pathfind");
|
||||||
|
int i = MathHelper.floor_double(p_72865_1_.posX);
|
||||||
|
int j = MathHelper.floor_double(p_72865_1_.posY + 1.0D);
|
||||||
|
int k = MathHelper.floor_double(p_72865_1_.posZ);
|
||||||
|
int l = (int)(p_72865_3_ + 16.0F);
|
||||||
|
int i1 = i - l;
|
||||||
|
int j1 = j - l;
|
||||||
|
int k1 = k - l;
|
||||||
|
int l1 = i + l;
|
||||||
|
int i2 = j + l;
|
||||||
|
int j2 = k + l;
|
||||||
|
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, i1, j1, k1, l1, i2, j2, 0);
|
||||||
|
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72865_4_, p_72865_5_, p_72865_6_, p_72865_7_)).createEntityPathTo(p_72865_1_, p_72865_2_, p_72865_3_);
|
||||||
|
this.theEntity.worldObj.theProfiler.endSection();
|
||||||
|
return pathentity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlyPathEntity getEntityPathToXYZ(Entity p_72844_1_, int p_72844_2_, int p_72844_3_, int p_72844_4_, float p_72844_5_, boolean p_72844_6_, boolean p_72844_7_, boolean p_72844_8_, boolean p_72844_9_)
|
||||||
|
{
|
||||||
|
this.theEntity.worldObj.theProfiler.startSection("pathfind");
|
||||||
|
int l = MathHelper.floor_double(p_72844_1_.posX);
|
||||||
|
int i1 = MathHelper.floor_double(p_72844_1_.posY);
|
||||||
|
int j1 = MathHelper.floor_double(p_72844_1_.posZ);
|
||||||
|
int k1 = (int)(p_72844_5_ + 8.0F);
|
||||||
|
int l1 = l - k1;
|
||||||
|
int i2 = i1 - k1;
|
||||||
|
int j2 = j1 - k1;
|
||||||
|
int k2 = l + k1;
|
||||||
|
int l2 = i1 + k1;
|
||||||
|
int i3 = j1 + k1;
|
||||||
|
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, l1, i2, j2, k2, l2, i3, 0);
|
||||||
|
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72844_6_, p_72844_7_, p_72844_8_, p_72844_9_)).createEntityPathTo(p_72844_1_, p_72844_2_, p_72844_3_, p_72844_4_, p_72844_5_);
|
||||||
|
this.theEntity.worldObj.theProfiler.endSection();
|
||||||
|
return pathentity;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,299 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.monster.EntityZombie;
|
||||||
|
import net.minecraft.entity.passive.EntityChicken;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.PathFinder;
|
||||||
|
import net.minecraft.pathfinding.PathNavigate;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import noppes.npcs.util.Vec3NPC;
|
||||||
|
|
||||||
|
public class PathNavigateGround extends PathNavigateNPC
|
||||||
|
{
|
||||||
|
protected WalkNodeProcessor nodeProcessor;
|
||||||
|
private boolean shouldAvoidSun;
|
||||||
|
|
||||||
|
public PathNavigateGround(EntityLiving entitylivingIn, World worldIn)
|
||||||
|
{
|
||||||
|
super(entitylivingIn, worldIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PathFinder getPathFinder()
|
||||||
|
{
|
||||||
|
this.nodeProcessor = new WalkNodeProcessor();
|
||||||
|
this.nodeProcessor.setEnterDoors(true);
|
||||||
|
return new NPCPathFinder(this.nodeProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If on ground or swimming and can swim
|
||||||
|
*/
|
||||||
|
protected boolean canNavigate()
|
||||||
|
{
|
||||||
|
return this.theEntity.onGround || this.getCanSwim() && this.isInLiquid() || this.theEntity.isRiding() && this.theEntity instanceof EntityZombie && this.theEntity.ridingEntity instanceof EntityChicken;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Vec3 getEntityPosition()
|
||||||
|
{
|
||||||
|
return new Vec3NPC(this.theEntity.posX, (double)this.getPathablePosY(), this.theEntity.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
||||||
|
*/
|
||||||
|
private int getPathablePosY()
|
||||||
|
{
|
||||||
|
if (this.theEntity.isInWater() && this.getCanSwim())
|
||||||
|
{
|
||||||
|
int i = (int)this.theEntity.boundingBox.minY;
|
||||||
|
Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
while (block == Blocks.flowing_water || block == Blocks.water)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
|
||||||
|
++j;
|
||||||
|
|
||||||
|
if (j > 16)
|
||||||
|
{
|
||||||
|
return (int)this.theEntity.boundingBox.minY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (int)(this.theEntity.boundingBox.minY + 0.5D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims path data from the end to the first sun covered block
|
||||||
|
*/
|
||||||
|
protected void removeSunnyPath()
|
||||||
|
{
|
||||||
|
super.removeSunnyPath();
|
||||||
|
|
||||||
|
if (this.shouldAvoidSun)
|
||||||
|
{
|
||||||
|
if (this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
|
||||||
|
|
||||||
|
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathLength(i - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||||
|
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||||
|
*/
|
||||||
|
protected boolean isDirectPathBetweenPoints(Vec3 posVec31, Vec3 posVec32, int sizeX, int sizeY, int sizeZ)
|
||||||
|
{
|
||||||
|
int i = MathHelper.floor_double(posVec31.xCoord);
|
||||||
|
int j = MathHelper.floor_double(posVec31.zCoord);
|
||||||
|
double d0 = posVec32.xCoord - posVec31.xCoord;
|
||||||
|
double d1 = posVec32.zCoord - posVec31.zCoord;
|
||||||
|
double d2 = d0 * d0 + d1 * d1;
|
||||||
|
|
||||||
|
if (d2 < 1.0E-8D)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double d3 = 1.0D / Math.sqrt(d2);
|
||||||
|
d0 = d0 * d3;
|
||||||
|
d1 = d1 * d3;
|
||||||
|
sizeX = sizeX + 2;
|
||||||
|
sizeZ = sizeZ + 2;
|
||||||
|
|
||||||
|
if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sizeX = sizeX - 2;
|
||||||
|
sizeZ = sizeZ - 2;
|
||||||
|
double d4 = 1.0D / Math.abs(d0);
|
||||||
|
double d5 = 1.0D / Math.abs(d1);
|
||||||
|
double d6 = (double)(i * 1) - posVec31.xCoord;
|
||||||
|
double d7 = (double)(j * 1) - posVec31.zCoord;
|
||||||
|
|
||||||
|
if (d0 >= 0.0D)
|
||||||
|
{
|
||||||
|
++d6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d1 >= 0.0D)
|
||||||
|
{
|
||||||
|
++d7;
|
||||||
|
}
|
||||||
|
|
||||||
|
d6 = d6 / d0;
|
||||||
|
d7 = d7 / d1;
|
||||||
|
int k = d0 < 0.0D ? -1 : 1;
|
||||||
|
int l = d1 < 0.0D ? -1 : 1;
|
||||||
|
int i1 = MathHelper.floor_double(posVec32.xCoord);
|
||||||
|
int j1 = MathHelper.floor_double(posVec32.zCoord);
|
||||||
|
int k1 = i1 - i;
|
||||||
|
int l1 = j1 - j;
|
||||||
|
|
||||||
|
while (k1 * k > 0 || l1 * l > 0)
|
||||||
|
{
|
||||||
|
if (d6 < d7)
|
||||||
|
{
|
||||||
|
d6 += d4;
|
||||||
|
i += k;
|
||||||
|
k1 = i1 - i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d7 += d5;
|
||||||
|
j += l;
|
||||||
|
l1 = j1 - j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an entity could stand at a position, including solid blocks under the entire entity.
|
||||||
|
*/
|
||||||
|
private boolean isSafeToStandAt(int x, int y, int z, int sizeX, int sizeY, int sizeZ, Vec3 vec31, double p_179683_8_, double p_179683_10_)
|
||||||
|
{
|
||||||
|
int i = x - sizeX / 2;
|
||||||
|
int j = z - sizeZ / 2;
|
||||||
|
|
||||||
|
if (!this.isPositionClear(i, y, j, sizeX, sizeY, sizeZ, vec31, p_179683_8_, p_179683_10_))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int k = i; k < i + sizeX; ++k)
|
||||||
|
{
|
||||||
|
for (int l = j; l < j + sizeZ; ++l)
|
||||||
|
{
|
||||||
|
double d0 = (double)k + 0.5D - vec31.xCoord;
|
||||||
|
double d1 = (double)l + 0.5D - vec31.zCoord;
|
||||||
|
|
||||||
|
if (d0 * p_179683_8_ + d1 * p_179683_10_ >= 0.0D)
|
||||||
|
{
|
||||||
|
Block block = this.worldObj.getBlock(k, y - 1, l);
|
||||||
|
Material material = block.getMaterial();
|
||||||
|
|
||||||
|
if (material == Material.air)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (material == Material.water && !this.theEntity.isInWater())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (material == Material.lava)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if an entity does not collide with any solid blocks at the position.
|
||||||
|
*/
|
||||||
|
private boolean isPositionClear(int p_179692_1_, int p_179692_2_, int p_179692_3_, int p_179692_4_, int p_179692_5_, int p_179692_6_, Vec3 p_179692_7_, double p_179692_8_, double p_179692_10_)
|
||||||
|
{
|
||||||
|
for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(p_179692_1_, p_179692_2_, p_179692_3_), new BlockPos(p_179692_1_ + p_179692_4_ - 1, p_179692_2_ + p_179692_5_ - 1, p_179692_3_ + p_179692_6_ - 1)))
|
||||||
|
{
|
||||||
|
double d0 = (double)blockpos.getX() + 0.5D - p_179692_7_.xCoord;
|
||||||
|
double d1 = (double)blockpos.getZ() + 0.5D - p_179692_7_.zCoord;
|
||||||
|
|
||||||
|
if (d0 * p_179692_8_ + d1 * p_179692_10_ >= 0.0D)
|
||||||
|
{
|
||||||
|
Block block = this.worldObj.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||||
|
|
||||||
|
if (!block.getBlocksMovement(this.worldObj, blockpos.getX(), blockpos.getY(), blockpos.getZ()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvoidsWater(boolean avoidsWater)
|
||||||
|
{
|
||||||
|
this.nodeProcessor.setAvoidsWater(avoidsWater);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAvoidsWater()
|
||||||
|
{
|
||||||
|
return this.nodeProcessor.getAvoidsWater();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBreakDoors(boolean canBreakDoors)
|
||||||
|
{
|
||||||
|
this.nodeProcessor.setBreakDoors(canBreakDoors);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnterDoors(boolean par1)
|
||||||
|
{
|
||||||
|
this.nodeProcessor.setEnterDoors(par1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnterDoors()
|
||||||
|
{
|
||||||
|
return this.nodeProcessor.getEnterDoors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanSwim(boolean canSwim)
|
||||||
|
{
|
||||||
|
this.nodeProcessor.setCanSwim(canSwim);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCanSwim()
|
||||||
|
{
|
||||||
|
return this.nodeProcessor.getCanSwim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvoidSun(boolean par1)
|
||||||
|
{
|
||||||
|
this.shouldAvoidSun = par1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||||
|
import net.minecraft.entity.monster.EntityZombie;
|
||||||
|
import net.minecraft.entity.passive.EntityChicken;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.PathEntity;
|
||||||
|
import net.minecraft.pathfinding.PathNavigate;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class PathNavigateNPC extends PathNavigate
|
||||||
|
{
|
||||||
|
protected EntityLiving theEntity;
|
||||||
|
protected World worldObj;
|
||||||
|
/** The PathEntity being followed. */
|
||||||
|
protected PathEntity currentPath;
|
||||||
|
|
||||||
|
/** Time, in number of ticks, following the current path */
|
||||||
|
protected int totalTicks;
|
||||||
|
/** The time when the last position check was done (to detect successful movement) */
|
||||||
|
protected int ticksAtLastPos;
|
||||||
|
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
|
||||||
|
protected Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||||
|
|
||||||
|
public PathNavigateNPC(EntityLiving p_i1671_1_, World p_i1671_2_)
|
||||||
|
{
|
||||||
|
super(p_i1671_1_, p_i1671_2_);
|
||||||
|
this.theEntity = p_i1671_1_;
|
||||||
|
this.worldObj = p_i1671_2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets Current Path of NPC **/
|
||||||
|
public PathEntity getPath()
|
||||||
|
{
|
||||||
|
return this.currentPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns true if the entity is in water or lava, false otherwise **/
|
||||||
|
protected boolean isInLiquid()
|
||||||
|
{
|
||||||
|
return this.theEntity.isInWater() || this.theEntity.handleLavaMovement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Trims path data from the end to the first sun covered block **/
|
||||||
|
protected void removeSunnyPath()
|
||||||
|
{
|
||||||
|
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
|
||||||
|
|
||||||
|
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathLength(i - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if entity haven't been moved when last checked and if so, clears current {@link
|
||||||
|
* net.minecraft.pathfinding.PathEntity}
|
||||||
|
*/
|
||||||
|
protected void checkForStuck(Vec3 positionVec3)
|
||||||
|
{
|
||||||
|
if (this.totalTicks - this.ticksAtLastPos > 100)
|
||||||
|
{
|
||||||
|
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
|
||||||
|
{
|
||||||
|
this.clearPathEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ticksAtLastPos = this.totalTicks;
|
||||||
|
this.lastPosCheck = positionVec3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.pathfinding.PathFinder;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import noppes.npcs.ai.pathfinder.NPCPathFinder;
|
||||||
|
import noppes.npcs.ai.pathfinder.PathNavigateNPC;
|
||||||
|
import noppes.npcs.ai.pathfinder.SwimNodeProcessor;
|
||||||
|
import noppes.npcs.util.Vec3NPC;
|
||||||
|
|
||||||
|
public class PathNavigateSwimmer extends PathNavigateNPC
|
||||||
|
{
|
||||||
|
public PathNavigateSwimmer(EntityLiving entitylivingIn, World worldIn)
|
||||||
|
{
|
||||||
|
super(entitylivingIn, worldIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PathFinder getPathFinder()
|
||||||
|
{
|
||||||
|
return new NPCPathFinder(new SwimNodeProcessor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If on ground or swimming and can swim
|
||||||
|
*/
|
||||||
|
protected boolean canNavigate()
|
||||||
|
{
|
||||||
|
return this.isInLiquid();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Vec3 getEntityPosition()
|
||||||
|
{
|
||||||
|
return new Vec3NPC(this.theEntity.posX, this.theEntity.posY + (double)this.theEntity.height * 0.5D, this.theEntity.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void pathFollow()
|
||||||
|
{
|
||||||
|
Vec3 vec3 = this.getEntityPosition();
|
||||||
|
float f = this.theEntity.width * this.theEntity.width;
|
||||||
|
int i = 6;
|
||||||
|
|
||||||
|
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex())) < (double)f)
|
||||||
|
{
|
||||||
|
this.currentPath.incrementPathIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = Math.min(this.currentPath.getCurrentPathIndex() + i, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j)
|
||||||
|
{
|
||||||
|
Vec3 vec31 = this.currentPath.getVectorFromIndex(this.theEntity, j);
|
||||||
|
|
||||||
|
if (vec31.squareDistanceTo(vec3) <= 36.0D && this.isDirectPathBetweenPoints(vec3, vec31, 0, 0, 0))
|
||||||
|
{
|
||||||
|
this.currentPath.setCurrentPathIndex(j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.checkForStuck(vec3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims path data from the end to the first sun covered block
|
||||||
|
*/
|
||||||
|
protected void removeSunnyPath()
|
||||||
|
{
|
||||||
|
super.removeSunnyPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||||
|
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||||
|
*/
|
||||||
|
protected boolean isDirectPathBetweenPoints(Vec3 posVec31, Vec3 posVec32, int sizeX, int sizeY, int sizeZ)
|
||||||
|
{
|
||||||
|
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(posVec31, new Vec3NPC(posVec32.xCoord, posVec32.yCoord + (double)this.theEntity.height * 0.5D, posVec32.zCoord), false, true, false);
|
||||||
|
return movingobjectposition == null || movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.MISS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class SwimNodeProcessor extends NodeProcessor
|
||||||
|
{
|
||||||
|
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
|
||||||
|
{
|
||||||
|
super.initProcessor(iblockaccessIn, entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when all nodes have been processed and PathEntity is created.
|
||||||
|
* {@link net.minecraft.world.pathfinder.WalkNodeProcessor WalkNodeProcessor} uses this to change its field {@link
|
||||||
|
* net.minecraft.world.pathfinder.WalkNodeProcessor#avoidsWater avoidsWater}
|
||||||
|
*/
|
||||||
|
public void postProcess()
|
||||||
|
{
|
||||||
|
super.postProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns given entity's position as PathPoint
|
||||||
|
*/
|
||||||
|
public PathPoint getPathPointTo(Entity entityIn)
|
||||||
|
{
|
||||||
|
return this.openPoint(MathHelper.floor_double(entityIn.boundingBox.minX), MathHelper.floor_double(entityIn.boundingBox.minY + 0.5D), MathHelper.floor_double(entityIn.boundingBox.minZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns PathPoint for given coordinates
|
||||||
|
*/
|
||||||
|
public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target)
|
||||||
|
{
|
||||||
|
return this.openPoint(MathHelper.floor_double(x - (double)(entityIn.width / 2.0F)), MathHelper.floor_double(y + 0.5D), MathHelper.floor_double(target - (double)(entityIn.width / 2.0F)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (EnumFacing enumfacing : EnumFacing.values())
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = this.getSafePoint(entityIn, currentPoint.xCoord + enumfacing.getFrontOffsetX(), currentPoint.yCoord + enumfacing.getFrontOffsetY(), currentPoint.zCoord + enumfacing.getFrontOffsetZ());
|
||||||
|
|
||||||
|
if (pathpoint != null && !pathpoint.isFirst && pathpoint.distanceTo(targetPoint) < maxDistance)
|
||||||
|
{
|
||||||
|
pathOptions[i++] = pathpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a point that the entity can safely move to
|
||||||
|
*/
|
||||||
|
private PathPoint getSafePoint(Entity entityIn, int x, int y, int z)
|
||||||
|
{
|
||||||
|
int i = this.func_176186_b(entityIn, x, y, z);
|
||||||
|
return i == -1 ? this.openPoint(x, y, z) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int func_176186_b(Entity entityIn, int x, int y, int z)
|
||||||
|
{
|
||||||
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
|
for (int i = x; i < x + this.entitySizeX; ++i)
|
||||||
|
{
|
||||||
|
for (int j = y; j < y + this.entitySizeY; ++j)
|
||||||
|
{
|
||||||
|
for (int k = z; k < z + this.entitySizeZ; ++k)
|
||||||
|
{
|
||||||
|
Block block = this.blockaccess.getBlock(i, j, k);
|
||||||
|
|
||||||
|
if (block.getMaterial() != Material.water)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.pathfinding.PathPoint;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
|
public class WalkNodeProcessor extends NodeProcessor
|
||||||
|
{
|
||||||
|
private boolean canEnterDoors;
|
||||||
|
private boolean canBreakDoors;
|
||||||
|
private boolean avoidsWater;
|
||||||
|
private boolean canSwim;
|
||||||
|
private boolean shouldAvoidWater;
|
||||||
|
|
||||||
|
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
|
||||||
|
{
|
||||||
|
super.initProcessor(iblockaccessIn, entityIn);
|
||||||
|
this.shouldAvoidWater = this.avoidsWater;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when all nodes have been processed and PathEntity is created.
|
||||||
|
* {@link noppes.npcs.ai.pathfinder.WalkNodeProcessor WalkNodeProcessor} uses this to change its field {@link
|
||||||
|
* noppes.npcs.ai.pathfinder.WalkNodeProcessor#avoidsWater avoidsWater}
|
||||||
|
*/
|
||||||
|
public void postProcess()
|
||||||
|
{
|
||||||
|
super.postProcess();
|
||||||
|
this.avoidsWater = this.shouldAvoidWater;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns given entity's position as PathPoint
|
||||||
|
*/
|
||||||
|
public PathPoint getPathPointTo(Entity entityIn)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (this.canSwim && entityIn.isInWater())
|
||||||
|
{
|
||||||
|
i = (int)entityIn.boundingBox.minY;
|
||||||
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
|
||||||
|
|
||||||
|
for (Block block = this.blockaccess.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.blockaccess.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()))
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
blockpos$mutableblockpos.set(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.avoidsWater = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = MathHelper.floor_double(entityIn.boundingBox.minY + 0.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.openPoint(MathHelper.floor_double(entityIn.boundingBox.minX), i, MathHelper.floor_double(entityIn.boundingBox.minZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns PathPoint for given coordinates
|
||||||
|
*/
|
||||||
|
public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double target)
|
||||||
|
{
|
||||||
|
return this.openPoint(MathHelper.floor_double(x - (double)(entityIn.width / 2.0F)), MathHelper.floor_double(y), MathHelper.floor_double(target - (double)(entityIn.width / 2.0F)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
if (this.getVerticalOffset(entityIn, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord) == 1)
|
||||||
|
{
|
||||||
|
j = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PathPoint pathpoint = this.getSafePoint(entityIn, currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord + 1, j);
|
||||||
|
PathPoint pathpoint1 = this.getSafePoint(entityIn, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord, j);
|
||||||
|
PathPoint pathpoint2 = this.getSafePoint(entityIn, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord, j);
|
||||||
|
PathPoint pathpoint3 = this.getSafePoint(entityIn, currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord - 1, j);
|
||||||
|
|
||||||
|
if (pathpoint != null && !pathpoint.isFirst && pathpoint.distanceTo(targetPoint) < maxDistance)
|
||||||
|
{
|
||||||
|
pathOptions[i++] = pathpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance)
|
||||||
|
{
|
||||||
|
pathOptions[i++] = pathpoint1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance)
|
||||||
|
{
|
||||||
|
pathOptions[i++] = pathpoint2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance)
|
||||||
|
{
|
||||||
|
pathOptions[i++] = pathpoint3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a point that the entity can safely move to
|
||||||
|
*/
|
||||||
|
private PathPoint getSafePoint(Entity entityIn, int x, int y, int z, int p_176171_5_)
|
||||||
|
{
|
||||||
|
PathPoint pathpoint = null;
|
||||||
|
int i = this.getVerticalOffset(entityIn, x, y, z);
|
||||||
|
|
||||||
|
if (i == 2)
|
||||||
|
{
|
||||||
|
return this.openPoint(x, y, z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i == 1)
|
||||||
|
{
|
||||||
|
pathpoint = this.openPoint(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint == null && p_176171_5_ > 0 && i != -3 && i != -4 && this.getVerticalOffset(entityIn, x, y + p_176171_5_, z) == 1)
|
||||||
|
{
|
||||||
|
pathpoint = this.openPoint(x, y + p_176171_5_, z);
|
||||||
|
y += p_176171_5_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint != null)
|
||||||
|
{
|
||||||
|
int j = 0;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = 0; y > 0; pathpoint = this.openPoint(x, y, z))
|
||||||
|
{
|
||||||
|
k = this.getVerticalOffset(entityIn, x, y - 1, z);
|
||||||
|
|
||||||
|
if (this.avoidsWater && k == -1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k != 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j++ >= entityIn.getMaxSafePointTries())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
--y;
|
||||||
|
|
||||||
|
if (y <= 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k == -2)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an entity collides with blocks at a position.
|
||||||
|
* Returns 1 if clear, 0 for colliding with any solid block, -1 for water(if avoids water),
|
||||||
|
* -2 for lava, -3 for fence and wall, -4 for closed trapdoor, 2 if otherwise clear except for open trapdoor or
|
||||||
|
* water(if not avoiding)
|
||||||
|
*/
|
||||||
|
private int getVerticalOffset(Entity entityIn, int x, int y, int z)
|
||||||
|
{
|
||||||
|
return func_176170_a(this.blockaccess, entityIn, x, y, z, this.entitySizeX, this.entitySizeY, this.entitySizeZ, this.avoidsWater, this.canBreakDoors, this.canEnterDoors);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int func_176170_a(IBlockAccess blockaccessIn, Entity entityIn, int x, int y, int z, int sizeX, int sizeY, int sizeZ, boolean avoidWater, boolean breakDoors, boolean enterDoors)
|
||||||
|
{
|
||||||
|
boolean flag = false;
|
||||||
|
BlockPos blockpos = new BlockPos(entityIn);
|
||||||
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
|
for (int i = x; i < x + sizeX; ++i)
|
||||||
|
{
|
||||||
|
for (int j = y; j < y + sizeY; ++j)
|
||||||
|
{
|
||||||
|
for (int k = z; k < z + sizeZ; ++k)
|
||||||
|
{
|
||||||
|
blockpos$mutableblockpos.set(i, j, k);
|
||||||
|
Block block = blockaccessIn.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ());
|
||||||
|
|
||||||
|
if (block.getMaterial() != Material.air)
|
||||||
|
{
|
||||||
|
if (block != Blocks.trapdoor)
|
||||||
|
{
|
||||||
|
if (block != Blocks.flowing_water && block != Blocks.water)
|
||||||
|
{
|
||||||
|
if (!enterDoors && block instanceof BlockDoor && block.getMaterial() == Material.wood)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (avoidWater)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityIn.worldObj.getBlock(blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()) instanceof BlockRailBase)
|
||||||
|
{
|
||||||
|
if (!(entityIn.worldObj.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ()) instanceof BlockRailBase) && !(entityIn.worldObj.getBlock(blockpos.down().getX(), blockpos.down().getY(), blockpos.down().getZ()) instanceof BlockRailBase))
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!block.getBlocksMovement(blockaccessIn, blockpos$mutableblockpos.getX(), blockpos$mutableblockpos.getY(), blockpos$mutableblockpos.getZ()) && (!breakDoors || !(block instanceof BlockDoor) || block.getMaterial() != Material.wood))
|
||||||
|
{
|
||||||
|
if (block instanceof BlockFence || block instanceof BlockFenceGate || block instanceof BlockWall)
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block == Blocks.trapdoor)
|
||||||
|
{
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
Material material = block.getMaterial();
|
||||||
|
|
||||||
|
if (material != Material.lava)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entityIn.handleLavaMovement())
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnterDoors(boolean canEnterDoorsIn)
|
||||||
|
{
|
||||||
|
this.canEnterDoors = canEnterDoorsIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBreakDoors(boolean canBreakDoorsIn)
|
||||||
|
{
|
||||||
|
this.canBreakDoors = canBreakDoorsIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvoidsWater(boolean avoidsWaterIn)
|
||||||
|
{
|
||||||
|
this.avoidsWater = avoidsWaterIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanSwim(boolean canSwimIn)
|
||||||
|
{
|
||||||
|
this.canSwim = canSwimIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnterDoors()
|
||||||
|
{
|
||||||
|
return this.canEnterDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCanSwim()
|
||||||
|
{
|
||||||
|
return this.canSwim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAvoidsWater()
|
||||||
|
{
|
||||||
|
return this.avoidsWater;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,13 @@ import java.util.List;
|
|||||||
import net.minecraft.command.IEntitySelector;
|
import net.minecraft.command.IEntitySelector;
|
||||||
import net.minecraft.entity.EntityCreature;
|
import net.minecraft.entity.EntityCreature;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
||||||
import net.minecraft.entity.ai.EntityAITarget;
|
import net.minecraft.entity.ai.EntityAITarget;
|
||||||
import net.minecraft.entity.monster.EntityMob;
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class EntityAIClosestTarget extends EntityAITarget
|
public class EntityAIClosestTarget extends EntityAITarget
|
||||||
{
|
{
|
||||||
@@ -52,10 +55,11 @@ public class EntityAIClosestTarget extends EntityAITarget
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) taskOwner).stats.aggroRange);
|
||||||
double d0 = this.getTargetDistance();
|
double d0 = this.getTargetDistance();
|
||||||
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
|
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
|
||||||
Collections.sort(list, this.theNearestAttackableTargetSorter);
|
Collections.sort(list, this.theNearestAttackableTargetSorter);
|
||||||
|
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemSword;
|
import net.minecraft.item.ItemSword;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -41,7 +42,7 @@ public class BlockPedestal extends BlockTrigger{
|
|||||||
par1World.markBlockForUpdate(i, j, k);
|
par1World.markBlockForUpdate(i, j, k);
|
||||||
updateSurrounding(par1World, i, j, k);
|
updateSurrounding(par1World, i, j, k);
|
||||||
}
|
}
|
||||||
else if(item == null || item.getItem() == null || !(item.getItem() instanceof ItemSword))
|
else if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock)
|
||||||
return true;
|
return true;
|
||||||
else if(item != null && weapon == null){
|
else if(item != null && weapon == null){
|
||||||
tile.setInventorySlotContents(0, item);
|
tile.setInventorySlotContents(0, item);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,12 +21,14 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.stats.Achievement;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import noppes.npcs.CommonProxy;
|
import noppes.npcs.CommonProxy;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
@@ -62,16 +64,8 @@ import noppes.npcs.client.controllers.PresetController;
|
|||||||
import noppes.npcs.client.fx.EntityElementalStaffFX;
|
import noppes.npcs.client.fx.EntityElementalStaffFX;
|
||||||
import noppes.npcs.client.fx.EntityEnderFX;
|
import noppes.npcs.client.fx.EntityEnderFX;
|
||||||
import noppes.npcs.client.fx.EntityRainbowFX;
|
import noppes.npcs.client.fx.EntityRainbowFX;
|
||||||
import noppes.npcs.client.gui.GuiBorderBlock;
|
import noppes.npcs.client.gui.*;
|
||||||
import noppes.npcs.client.gui.GuiMerchantAdd;
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
import noppes.npcs.client.gui.GuiNpcDimension;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcMobSpawner;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerMounter;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcPather;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcRedstoneBlock;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcRemoteEditor;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcWaypoint;
|
|
||||||
import noppes.npcs.client.gui.GuiScript;
|
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
|
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
|
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
|
||||||
@@ -105,6 +99,7 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerSetup;
|
|||||||
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
|
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
|
||||||
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
|
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
|
||||||
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
|
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
|
||||||
|
import noppes.npcs.client.gui.script.GuiScriptGlobal;
|
||||||
import noppes.npcs.client.model.*;
|
import noppes.npcs.client.model.*;
|
||||||
import noppes.npcs.client.renderer.*;
|
import noppes.npcs.client.renderer.*;
|
||||||
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
||||||
@@ -134,24 +129,11 @@ import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
|
|||||||
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
|
import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
|
||||||
import noppes.npcs.config.StringCache;
|
import noppes.npcs.config.StringCache;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.containers.ContainerCarpentryBench;
|
import noppes.npcs.containers.*;
|
||||||
import noppes.npcs.containers.ContainerCrate;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.containers.ContainerMail;
|
|
||||||
import noppes.npcs.containers.ContainerManageBanks;
|
|
||||||
import noppes.npcs.containers.ContainerManageRecipes;
|
|
||||||
import noppes.npcs.containers.ContainerNPCBankInterface;
|
|
||||||
import noppes.npcs.containers.ContainerNPCCompanion;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollower;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollowerHire;
|
|
||||||
import noppes.npcs.containers.ContainerNPCFollowerSetup;
|
|
||||||
import noppes.npcs.containers.ContainerNPCInv;
|
|
||||||
import noppes.npcs.containers.ContainerNPCTrader;
|
|
||||||
import noppes.npcs.containers.ContainerNPCTraderSetup;
|
|
||||||
import noppes.npcs.containers.ContainerNpcItemGiver;
|
|
||||||
import noppes.npcs.containers.ContainerNpcQuestReward;
|
|
||||||
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
|
||||||
import noppes.npcs.entity.*;
|
import noppes.npcs.entity.*;
|
||||||
|
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import tconstruct.client.tabs.InventoryTabFactions;
|
import tconstruct.client.tabs.InventoryTabFactions;
|
||||||
@@ -232,17 +214,21 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
ClientCloneController.Instance = new ClientCloneController();
|
ClientCloneController.Instance = new ClientCloneController();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
||||||
|
|
||||||
if(CustomNpcs.InventoryGuiEnabled){
|
if(CustomNpcs.InventoryGuiEnabled){
|
||||||
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
||||||
|
|
||||||
if (TabRegistry.getTabList().size() < 2){
|
if (TabRegistry.getTabList().size() < 2){
|
||||||
TabRegistry.registerTab(new InventoryTabVanilla());
|
TabRegistry.registerTab(new InventoryTabVanilla());
|
||||||
}
|
}
|
||||||
TabRegistry.registerTab(new InventoryTabFactions());
|
TabRegistry.registerTab(new InventoryTabFactions());
|
||||||
TabRegistry.registerTab(new InventoryTabQuests());
|
TabRegistry.registerTab(new InventoryTabQuests());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakePlayer getCommandPlayer(IWorld world) {
|
||||||
|
return (FakePlayer)(new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createFolders() {
|
private void createFolders() {
|
||||||
@@ -275,6 +261,20 @@ public class ClientProxy extends CommonProxy {
|
|||||||
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
|
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerData playerData = new PlayerData();
|
||||||
|
@Override
|
||||||
|
public PlayerData getPlayerData(EntityPlayer player) {
|
||||||
|
if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) {
|
||||||
|
if (playerData.player != player) {
|
||||||
|
playerData.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerData;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
|
||||||
@@ -286,6 +286,8 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return getGui(npc, gui, container, x, y, z);
|
return getGui(npc, gui, container, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
|
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
|
||||||
if (gui == EnumGuiType.MainMenuDisplay){
|
if (gui == EnumGuiType.MainMenuDisplay){
|
||||||
if(npc != null)
|
if(npc != null)
|
||||||
@@ -330,7 +332,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return new GuiNPCManageQuest(npc);
|
return new GuiNPCManageQuest(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.ManageBanks)
|
else if(gui == EnumGuiType.ManageBanks)
|
||||||
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
|
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.MainMenuGlobal)
|
else if (gui == EnumGuiType.MainMenuGlobal)
|
||||||
return new GuiNPCGlobalMainMenu(npc);
|
return new GuiNPCGlobalMainMenu(npc);
|
||||||
@@ -353,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)
|
||||||
@@ -377,6 +379,9 @@ public class ClientProxy extends CommonProxy {
|
|||||||
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
||||||
return new GuiNpcRemoteEditor();
|
return new GuiNpcRemoteEditor();
|
||||||
|
|
||||||
|
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
|
||||||
|
return new GuiScriptGlobal();
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerMailman)
|
else if(gui == EnumGuiType.PlayerMailman)
|
||||||
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
|
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
|
||||||
|
|
||||||
@@ -418,6 +423,10 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
else if (gui == EnumGuiType.CompanionInv)
|
else if (gui == EnumGuiType.CompanionInv)
|
||||||
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
|
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
|
||||||
|
|
||||||
|
else if (gui == EnumGuiType.CustomGui)
|
||||||
|
return new GuiCustom((ContainerCustomGui)container);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,18 +476,18 @@ public class ClientProxy extends CommonProxy {
|
|||||||
if(string.equals("Spell")){
|
if(string.equals("Spell")){
|
||||||
int color = (Integer) ob[0];
|
int color = (Integer) ob[0];
|
||||||
int number = (Integer) ob[1];
|
int number = (Integer) ob[1];
|
||||||
for(int i = 0; i < number; i++){
|
for(int i = 0; i < number; i++){
|
||||||
Random rand = player.worldObj.rand;
|
Random rand = player.worldObj.rand;
|
||||||
double x = (rand.nextDouble() - 0.5D) * (double)player.width;
|
double x = (rand.nextDouble() - 0.5D) * (double)player.width;
|
||||||
double y = player.getEyeHeight();
|
double y = player.getEyeHeight();
|
||||||
double z = (rand.nextDouble() - 0.5D) * (double)player.width;
|
double z = (rand.nextDouble() - 0.5D) * (double)player.width;
|
||||||
|
|
||||||
double f = (rand.nextDouble() - 0.5D) * 2D;
|
double f = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
double f1 = -rand.nextDouble();
|
double f1 = -rand.nextDouble();
|
||||||
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
|
|
||||||
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
|
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(string.equals("ModelData")){
|
else if(string.equals("ModelData")){
|
||||||
ModelData data = (ModelData) ob[0];
|
ModelData data = (ModelData) ob[0];
|
||||||
@@ -495,18 +504,18 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else if(particles.type == 1){
|
else if(particles.type == 1){
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
|
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
|
||||||
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
|
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
|
||||||
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
|
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
|
||||||
|
|
||||||
|
|
||||||
double f = (rand.nextDouble() - 0.5D) * 2D;
|
double f = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
double f1 = -rand.nextDouble();
|
double f1 = -rand.nextDouble();
|
||||||
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
|
|
||||||
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
|
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -534,9 +543,9 @@ public class ClientProxy extends CommonProxy {
|
|||||||
try{
|
try{
|
||||||
if(location == null)
|
if(location == null)
|
||||||
return;
|
return;
|
||||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||||
if(location != null)
|
if(location != null)
|
||||||
texturemanager.bindTexture((ResourceLocation) location);
|
texturemanager.bindTexture((ResourceLocation) location);
|
||||||
}
|
}
|
||||||
catch(NullPointerException ex){
|
catch(NullPointerException ex){
|
||||||
|
|
||||||
@@ -548,7 +557,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnParticle(String particle, double x, double y, double z,
|
public void spawnParticle(String particle, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float scale) {
|
double motionX, double motionY, double motionZ, float scale) {
|
||||||
|
|
||||||
RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
|
RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
|
||||||
|
|
||||||
@@ -556,14 +565,23 @@ public class ClientProxy extends CommonProxy {
|
|||||||
if(fx == null)
|
if(fx == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (particle.equals("flame")){
|
if (particle.equals("flame")){
|
||||||
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0);
|
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0);
|
||||||
}
|
}
|
||||||
else if (particle.equals("smoke")){
|
else if (particle.equals("smoke")){
|
||||||
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0);
|
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAchievementDesc(Achievement achievement) {
|
||||||
|
return achievement.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGUIOpen(){
|
||||||
|
return Minecraft.getMinecraft().currentScreen != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static class FontContainer {
|
public static class FontContainer {
|
||||||
private StringCache textFont = null;
|
private StringCache textFont = null;
|
||||||
@@ -577,11 +595,11 @@ public class ClientProxy extends CommonProxy {
|
|||||||
textFont = new StringCache();
|
textFont = new StringCache();
|
||||||
textFont.setDefaultFont("Arial", fontSize, true);
|
textFont.setDefaultFont("Arial", fontSize, true);
|
||||||
useCustomFont = !fontType.equalsIgnoreCase("minecraft");
|
useCustomFont = !fontType.equalsIgnoreCase("minecraft");
|
||||||
try {
|
try {
|
||||||
if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
|
if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
|
||||||
textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true);
|
textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true);
|
||||||
else
|
else
|
||||||
textFont.setDefaultFont(fontType, fontSize, true);
|
textFont.setDefaultFont(fontType, fontSize, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.info("Failed loading font so using Arial");
|
LogWriter.info("Failed loading font so using Arial");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,15 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
public class ClientTickHandler{
|
public class ClientTickHandler{
|
||||||
|
|
||||||
private World prevWorld;
|
private World prevWorld;
|
||||||
private boolean otherContainer = false;
|
private boolean otherContainer = false;
|
||||||
|
private int buttonPressed = -1;
|
||||||
|
private long buttonTime = 0L;
|
||||||
|
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
public void onClientTick(TickEvent.ClientTickEvent event){
|
public void onClientTick(TickEvent.ClientTickEvent event){
|
||||||
@@ -41,6 +45,14 @@ public class ClientTickHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onMouse(InputEvent.MouseInputEvent event){
|
||||||
|
if(Mouse.getEventButton() == -1 && Mouse.getDWheel() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, new Object[]{Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton())});
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKey(InputEvent.KeyInputEvent event){
|
public void onKey(InputEvent.KeyInputEvent event){
|
||||||
if(ClientProxy.QuestLog.isPressed()){
|
if(ClientProxy.QuestLog.isPressed()){
|
||||||
@@ -50,6 +62,48 @@ public class ClientTickHandler{
|
|||||||
else if(mc.currentScreen instanceof GuiQuestLog)
|
else if(mc.currentScreen instanceof GuiQuestLog)
|
||||||
mc.setIngameFocus();
|
mc.setIngameFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int key = Keyboard.getEventKey();
|
||||||
|
long time = Keyboard.getEventNanoseconds();
|
||||||
|
|
||||||
|
if(Keyboard.getEventKeyState()) {
|
||||||
|
if(!this.isIgnoredKey(key)) {
|
||||||
|
this.buttonTime = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) {
|
||||||
|
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||||
|
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||||
|
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||||
|
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||||
|
boolean keyDown = Keyboard.isKeyDown(key);
|
||||||
|
|
||||||
|
StringBuilder keysDownString = new StringBuilder();
|
||||||
|
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
|
||||||
|
if(Keyboard.isKeyDown(i)){
|
||||||
|
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()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isIgnoredKey(int key) {
|
||||||
|
int[] var2 = this.ignoreKeys;
|
||||||
|
int var3 = var2.length;
|
||||||
|
|
||||||
|
for(int var4 = 0; var4 < var3; ++var4) {
|
||||||
|
int i = var2[var4];
|
||||||
|
if(i == key) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,14 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -21,6 +23,7 @@ import net.minecraft.world.World;
|
|||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.NoppesUtilPlayer;
|
import noppes.npcs.NoppesUtilPlayer;
|
||||||
import noppes.npcs.Server;
|
import noppes.npcs.Server;
|
||||||
|
import noppes.npcs.client.fx.EntityCustomFX;
|
||||||
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||||
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
||||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
||||||
@@ -67,6 +70,75 @@ public class NoppesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void spawnScriptedParticle(ByteBuf buffer){
|
||||||
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
String directory = Server.readString(buffer);
|
||||||
|
|
||||||
|
int HEXcolor = buffer.readInt();
|
||||||
|
int amount = buffer.readInt();
|
||||||
|
int maxAge = buffer.readInt();
|
||||||
|
|
||||||
|
double x = buffer.readDouble();
|
||||||
|
double y = buffer.readDouble();
|
||||||
|
double z = buffer.readDouble();
|
||||||
|
|
||||||
|
double motionX = buffer.readDouble();
|
||||||
|
double motionY = buffer.readDouble();
|
||||||
|
double motionZ = buffer.readDouble();
|
||||||
|
float gravity = buffer.readFloat();
|
||||||
|
|
||||||
|
float scale1 = buffer.readFloat();
|
||||||
|
float scale2 = buffer.readFloat();
|
||||||
|
float scaleRate = buffer.readFloat();
|
||||||
|
int scaleRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float alpha1 = buffer.readFloat();
|
||||||
|
float alpha2 = buffer.readFloat();
|
||||||
|
float alphaRate = buffer.readFloat();
|
||||||
|
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();
|
||||||
|
|
||||||
|
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||||
|
Entity entity = worldObj.getEntityByID(entityID);
|
||||||
|
|
||||||
|
if(entity == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EntityCustomFX fx = new EntityCustomFX(
|
||||||
|
entity,
|
||||||
|
directory, HEXcolor,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
|
maxAge
|
||||||
|
);
|
||||||
|
|
||||||
|
for(int i = 0; i < amount; i++){
|
||||||
|
minecraft.effectRenderer.addEffect(fx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void clickSound() {
|
public static void clickSound() {
|
||||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
}
|
}
|
||||||
@@ -237,4 +309,7 @@ public class NoppesUtil {
|
|||||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
|
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void isGUIOpen(boolean isGUIOpen) {
|
||||||
|
Client.sendData(EnumPacketServer.IsGuiOpen, isGUIOpen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -151,6 +152,9 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
|||||||
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
||||||
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
|
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketClient.SCRIPTED_PARTICLE){
|
||||||
|
NoppesUtil.spawnScriptedParticle(buffer);
|
||||||
|
}
|
||||||
else if(type == EnumPacketClient.PARTICLE){
|
else if(type == EnumPacketClient.PARTICLE){
|
||||||
NoppesUtil.spawnParticle(buffer);
|
NoppesUtil.spawnParticle(buffer);
|
||||||
}
|
}
|
||||||
@@ -251,8 +255,20 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
|||||||
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
|
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketClient.ISGUIOPEN){
|
||||||
|
boolean isGUIOpen = Minecraft.getMinecraft().currentScreen != null;
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
package noppes.npcs.client.fx;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.particle.EntityFX;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.ClientProxy;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class EntityCustomFX extends EntityFX {
|
||||||
|
private Entity entity;
|
||||||
|
private final ResourceLocation location;
|
||||||
|
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
|
||||||
|
private boolean move = true;
|
||||||
|
private float startX = 0, startY = 0, startZ = 0;
|
||||||
|
|
||||||
|
public float scale1 = 1.0F;
|
||||||
|
public float scale2 = 1.0F;
|
||||||
|
public float scaleRate = 1.0F;
|
||||||
|
public int scaleRateStart = 0;
|
||||||
|
|
||||||
|
public float alpha1 = 1.0F;
|
||||||
|
public float alpha2 = 0;
|
||||||
|
public float alphaRate = 0.0F;
|
||||||
|
public int alphaRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationX = 0;
|
||||||
|
public float rotationX1 = 0;
|
||||||
|
public float rotationX2 = 0;
|
||||||
|
public float rotationXRate = 0.0F;
|
||||||
|
public int rotationXRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationY = 0;
|
||||||
|
public float rotationY1 = 0;
|
||||||
|
public float rotationY2 = 0;
|
||||||
|
public float rotationYRate = 0.0F;
|
||||||
|
public int rotationYRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationZ = 0;
|
||||||
|
public float rotationZ1 = 0;
|
||||||
|
public float rotationZ2 = 0;
|
||||||
|
public float rotationZRate = 0.0F;
|
||||||
|
public int rotationZRateStart = 0;
|
||||||
|
|
||||||
|
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||||
|
int age) {
|
||||||
|
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||||
|
|
||||||
|
this.scale1 = scale1;
|
||||||
|
this.scale2 = scale2;
|
||||||
|
this.scaleRate = Math.abs(scaleRate);
|
||||||
|
this.scaleRateStart = scaleRateStart;
|
||||||
|
particleScale = scale1;
|
||||||
|
if(scale1 > scale2)
|
||||||
|
this.scaleRate *= -1;
|
||||||
|
|
||||||
|
this.alpha1 = alpha1;
|
||||||
|
this.alpha2 = alpha2;
|
||||||
|
this.alphaRate = Math.abs(alphaRate);
|
||||||
|
this.alphaRateStart = alphaRateStart;
|
||||||
|
particleAlpha = alpha1;
|
||||||
|
if(alpha1 > alpha2)
|
||||||
|
this.alphaRate *= -1;
|
||||||
|
|
||||||
|
this.rotationX1 = rotationX1;
|
||||||
|
this.rotationX2 = rotationX2;
|
||||||
|
this.rotationXRate = Math.abs(rotationXRate);
|
||||||
|
this.rotationXRateStart = rotationXRateStart;
|
||||||
|
rotationX = rotationX1;
|
||||||
|
if(rotationX1 > rotationX2)
|
||||||
|
this.rotationXRate *= -1;
|
||||||
|
|
||||||
|
this.rotationY1 = rotationY1;
|
||||||
|
this.rotationY2 = rotationY2;
|
||||||
|
this.rotationYRate = Math.abs(rotationYRate);
|
||||||
|
this.rotationYRateStart = rotationYRateStart;
|
||||||
|
rotationY = rotationY1;
|
||||||
|
if(rotationY1 > rotationY2)
|
||||||
|
this.rotationYRate *= -1;
|
||||||
|
|
||||||
|
this.rotationZ1 = rotationZ1;
|
||||||
|
this.rotationZ2 = rotationZ2;
|
||||||
|
this.rotationZRate = Math.abs(rotationZRate);
|
||||||
|
this.rotationZRateStart = rotationZRateStart;
|
||||||
|
rotationZ = rotationZ1;
|
||||||
|
if(rotationZ1 > rotationZ2)
|
||||||
|
this.rotationZRate *= -1;
|
||||||
|
|
||||||
|
particleGravity = gravity/0.04F;
|
||||||
|
particleMaxAge = age;
|
||||||
|
|
||||||
|
this.motionX = motionX;
|
||||||
|
this.motionY = motionY;
|
||||||
|
this.motionZ = motionZ;
|
||||||
|
|
||||||
|
this.entity = entity;
|
||||||
|
noClip = true;
|
||||||
|
|
||||||
|
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||||
|
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||||
|
particleBlue = (HEXColor & 255) / 255f;
|
||||||
|
|
||||||
|
if(Math.floor(Math.random()*3) == 1){
|
||||||
|
move = false;
|
||||||
|
this.startX = (float) entity.posX;
|
||||||
|
this.startY = (float) entity.posY;
|
||||||
|
this.startZ = (float) entity.posZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = new ResourceLocation(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
|
||||||
|
{
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
ClientProxy.bindTexture(location);
|
||||||
|
|
||||||
|
if(move){
|
||||||
|
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
|
||||||
|
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
|
||||||
|
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
|
||||||
|
}
|
||||||
|
|
||||||
|
float scaleChange = this.scaleRate / (float)particleMaxAge;
|
||||||
|
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
|
||||||
|
particleScale = this.scale2;
|
||||||
|
else if(particleAge >= this.scaleRateStart)
|
||||||
|
particleScale += scaleChange;
|
||||||
|
|
||||||
|
float alphaChange = this.alphaRate / (float)particleMaxAge;
|
||||||
|
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
|
||||||
|
particleAlpha = this.alpha2;
|
||||||
|
else if(particleAge >= this.alphaRateStart)
|
||||||
|
particleAlpha += alphaChange;
|
||||||
|
|
||||||
|
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
|
||||||
|
rotationX = this.rotationX2;
|
||||||
|
else if(particleAge >= this.rotationXRateStart)
|
||||||
|
rotationX += rotationXChange;
|
||||||
|
|
||||||
|
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
|
||||||
|
rotationY = this.rotationY2;
|
||||||
|
else if(particleAge >= this.rotationYRateStart)
|
||||||
|
rotationY += rotationYChange;
|
||||||
|
|
||||||
|
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
|
||||||
|
rotationZ = this.rotationZ2;
|
||||||
|
else if(particleAge >= this.rotationZRateStart)
|
||||||
|
rotationZ += rotationZChange;
|
||||||
|
|
||||||
|
float u1 = 0.0f;
|
||||||
|
float u2 = 1.0f;
|
||||||
|
float v1 = 0.0f;
|
||||||
|
float v2 = 1.0f;
|
||||||
|
|
||||||
|
float renderScale = 0.1F * particleScale;
|
||||||
|
|
||||||
|
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
|
||||||
|
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
|
||||||
|
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
|
||||||
|
|
||||||
|
GL11.glTranslated((double)posX, (double)posY, (double)posZ);
|
||||||
|
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
double yaw = (player.rotationYaw/180)*Math.PI;
|
||||||
|
double pitch = (player.rotationPitch/180)*Math.PI;
|
||||||
|
|
||||||
|
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
|
||||||
|
rotationX += 180*Math.signum(rotationX);
|
||||||
|
}
|
||||||
|
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
|
||||||
|
rotationY += 180*Math.signum(rotationY);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
|
||||||
|
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
|
||||||
|
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(240);
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||||
|
tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2);
|
||||||
|
tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1);
|
||||||
|
tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1);
|
||||||
|
tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2);
|
||||||
|
|
||||||
|
tessellator.draw();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||||
|
ClientProxy.bindTexture(resource);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFXLayer(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package noppes.npcs.client.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
|
|
||||||
|
public class EventGuiScriptList extends SubGuiInterface{
|
||||||
|
private GuiCustomScroll scroll1;
|
||||||
|
private GuiCustomScroll scroll2;
|
||||||
|
private ScriptContainer container;
|
||||||
|
private List<String> scripts;
|
||||||
|
|
||||||
|
public EventGuiScriptList(List<String> scripts, ScriptContainer container){
|
||||||
|
this.container = container;
|
||||||
|
setBackground("menubg.png");
|
||||||
|
xSize = 346;
|
||||||
|
ySize = 216;
|
||||||
|
if(scripts == null)
|
||||||
|
scripts = new ArrayList<String>();
|
||||||
|
this.scripts = scripts;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void initGui(){
|
||||||
|
super.initGui();
|
||||||
|
if(scroll1 == null){
|
||||||
|
scroll1 = new GuiCustomScroll(this,0);
|
||||||
|
scroll1.setSize(140, 180);
|
||||||
|
}
|
||||||
|
scroll1.guiLeft = guiLeft + 4;
|
||||||
|
scroll1.guiTop = guiTop + 14;
|
||||||
|
this.addScroll(scroll1);
|
||||||
|
addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4));
|
||||||
|
|
||||||
|
if(scroll2 == null){
|
||||||
|
scroll2 = new GuiCustomScroll(this,1);
|
||||||
|
scroll2.setSize(140, 180);
|
||||||
|
}
|
||||||
|
scroll2.guiLeft = guiLeft + 200;
|
||||||
|
scroll2.guiTop = guiTop + 14;
|
||||||
|
this.addScroll(scroll2);
|
||||||
|
addLabel(new GuiNpcLabel(2, "script.loadedScripts", guiLeft + 200, guiTop + 4));
|
||||||
|
List<String> temp = new ArrayList<String>(scripts);
|
||||||
|
temp.removeAll(container.scripts);
|
||||||
|
scroll1.setList(temp);
|
||||||
|
scroll2.setList(container.scripts);
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">"));
|
||||||
|
addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<"));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>"));
|
||||||
|
addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<"));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done"));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton guibutton){
|
||||||
|
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||||
|
if(button.id == 1){
|
||||||
|
if(scroll1.hasSelected()){
|
||||||
|
container.scripts.add(scroll1.getSelected());
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(button.id == 2){
|
||||||
|
if(scroll2.hasSelected()){
|
||||||
|
container.scripts.remove(scroll2.getSelected());
|
||||||
|
scroll2.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(button.id == 3){
|
||||||
|
container.scripts.clear();
|
||||||
|
for(String script : scripts){
|
||||||
|
container.scripts.add(script);
|
||||||
|
}
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
if(button.id == 4){
|
||||||
|
container.scripts.clear();
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
if(button.id == 66){
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.blocks.tiles.TileBorder;
|
import noppes.npcs.blocks.tiles.TileBorder;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
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 noppes.npcs.client.gui.util.GuiNpcLabel;
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
@@ -30,7 +29,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, 500, 6);
|
getTextField(0).setMinMaxDefault(0, 500, 6);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
|
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
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 noppes.npcs.client.gui.util.GuiNpcLabel;
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
@@ -33,39 +32,39 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
|||||||
if(tile.isDetailed){
|
if(tile.isDetailed){
|
||||||
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||||
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
|
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(0, 50, 6);
|
getTextField(1).setMinMaxDefault(0, 50, 6);
|
||||||
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
|
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(0, 50, 6);
|
getTextField(2).setMinMaxDefault(0, 50, 6);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
|
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||||
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
|
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
getTextField(4).setMinMaxDefault(0, 50, 10);
|
getTextField(4).setMinMaxDefault(0, 50, 10);
|
||||||
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
|
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
|
||||||
getTextField(5).numbersOnly = true;
|
getTextField(5).integersOnly = true;
|
||||||
getTextField(5).setMinMaxDefault(0, 50, 10);
|
getTextField(5).setMinMaxDefault(0, 50, 10);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
|
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||||
}
|
}
|
||||||
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
|
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
|
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(2, 60, 10);
|
getTextField(1).setMinMaxDefault(2, 60, 10);
|
||||||
|
|
||||||
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package noppes.npcs.client.gui;
|
package noppes.npcs.client.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiConfirmOpenLink;
|
import net.minecraft.client.gui.GuiConfirmOpenLink;
|
||||||
@@ -11,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;
|
||||||
@@ -43,10 +41,10 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
script = npc.script;
|
script = npc.script;
|
||||||
drawDefaultBackground = true;
|
drawDefaultBackground = true;
|
||||||
closeOnEsc = true;
|
closeOnEsc = true;
|
||||||
xSize = 420;
|
xSize = 420;
|
||||||
|
|
||||||
setBackground("menubg.png");
|
setBackground("menubg.png");
|
||||||
Client.sendData(EnumPacketServer.ScriptDataGet);
|
Client.sendData(EnumPacketServer.ScriptDataGet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
@@ -59,18 +57,19 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
top.active = !showScript;
|
top.active = !showScript;
|
||||||
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
|
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
|
||||||
|
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
list.add("script.init");
|
list.add("script.init");
|
||||||
list.add("script.update");
|
list.add("script.update");
|
||||||
list.add("script.interact");
|
list.add("script.interact");
|
||||||
list.add("dialog.dialog");
|
list.add("dialog.dialog");
|
||||||
list.add("script.damaged");
|
list.add("script.damaged");
|
||||||
list.add("script.killed");
|
list.add("script.killed");
|
||||||
list.add("script.attack");
|
list.add("script.attack");
|
||||||
list.add("script.target");
|
list.add("script.target");
|
||||||
list.add("script.collide");
|
list.add("script.collide");
|
||||||
list.add("script.kills");
|
list.add("script.kills");
|
||||||
list.add("script.dialog_closed");
|
list.add("script.dialog_closed");
|
||||||
|
list.add("script.timer");
|
||||||
|
|
||||||
if(showScript){
|
if(showScript){
|
||||||
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
|
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
|
||||||
@@ -78,9 +77,9 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
hooks.setSize(68, 198);
|
hooks.setSize(68, 198);
|
||||||
hooks.guiLeft = guiLeft + 4;
|
hooks.guiLeft = guiLeft + 4;
|
||||||
hooks.guiTop = guiTop + 14;
|
hooks.guiTop = guiTop + 14;
|
||||||
hooks.setUnsortedList(list);
|
hooks.setUnsortedList(list);
|
||||||
hooks.selected = activeTab;
|
hooks.selected = activeTab;
|
||||||
addScroll(hooks);
|
addScroll(hooks);
|
||||||
|
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.scripts.get(activeTab);
|
||||||
|
|
||||||
@@ -138,27 +137,24 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getConsoleText() {
|
private String getConsoleText() {
|
||||||
String console = "";
|
Map<Long, String> map = this.script.getConsoleText();
|
||||||
if(activeConsole == 0){
|
StringBuilder builder = new StringBuilder();
|
||||||
for(ScriptContainer container : script.scripts.values()){
|
Iterator var3 = map.entrySet().iterator();
|
||||||
if(!container.console.isEmpty())
|
|
||||||
console += container.console + '\n';
|
while(var3.hasNext()) {
|
||||||
}
|
Map.Entry<Long, String> entry = (Map.Entry)var3.next();
|
||||||
|
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
ScriptContainer container = script.scripts.get(activeConsole - 1);
|
return builder.toString();
|
||||||
if(container != null)
|
|
||||||
console = container.console;
|
|
||||||
}
|
|
||||||
return console;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void confirmClicked(boolean flag, int i){
|
public void confirmClicked(boolean flag, int i){
|
||||||
if(flag)
|
if(flag)
|
||||||
openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
|
openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
|
||||||
displayGuiScreen(this);
|
displayGuiScreen(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton guibutton) {
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
@@ -173,7 +169,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
}
|
}
|
||||||
if(guibutton.id == 15){
|
if(guibutton.id == 15){
|
||||||
GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true);
|
GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true);
|
||||||
mc.displayGuiScreen(guiyesno);
|
mc.displayGuiScreen(guiyesno);
|
||||||
}
|
}
|
||||||
if (guibutton.id == 100) {
|
if (guibutton.id == 100) {
|
||||||
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
|
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
|
||||||
@@ -185,13 +181,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
getTextField(2).setText("");
|
getTextField(2).setText("");
|
||||||
if(!showScript){
|
if(!showScript){
|
||||||
if(activeConsole == 0){
|
if(activeConsole == 0){
|
||||||
for(ScriptContainer container : script.scripts.values())
|
for(ScriptContainer container : script.scripts)
|
||||||
container.console = "";
|
container.console.clear();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ScriptContainer container = script.scripts.get(activeConsole - 1);
|
ScriptContainer container = script.scripts.get(activeConsole - 1);
|
||||||
if(container != null)
|
if(container != null)
|
||||||
container.console = "";
|
container.console.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +207,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
if (guibutton.id == 107) {
|
if (guibutton.id == 107) {
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.scripts.get(activeTab);
|
||||||
if(container == null)
|
if(container == null)
|
||||||
script.scripts.put(activeTab, container = new ScriptContainer());
|
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
|
||||||
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
|
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
|
||||||
}
|
}
|
||||||
if (guibutton.id == 108) {
|
if (guibutton.id == 108) {
|
||||||
@@ -227,7 +223,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
if(showScript){
|
if(showScript){
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.scripts.get(activeTab);
|
||||||
if(container == null)
|
if(container == null)
|
||||||
script.scripts.put(activeTab, container = new ScriptContainer());
|
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
|
||||||
String text = getTextField(2).getText();
|
String text = getTextField(2).getText();
|
||||||
text = text.replace("\r\n", "\n");
|
text = text.replace("\r\n", "\n");
|
||||||
text = text.replace("\r", "\n");
|
text = text.replace("\r", "\n");
|
||||||
@@ -256,7 +252,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
setScript();
|
setScript();
|
||||||
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
|
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -277,3 +273,4 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4,14 +4,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
|
||||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
|
||||||
|
|
||||||
public class GuiScriptList extends SubGuiInterface{
|
public class GuiScriptList extends SubGuiInterface{
|
||||||
private GuiCustomScroll scroll1;
|
private GuiCustomScroll scroll1;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package noppes.npcs.client.gui;
|
package noppes.npcs.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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.gui.global.GuiNPCQuestSelection;
|
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||||
@@ -13,15 +11,11 @@ import noppes.npcs.client.gui.util.GuiSelectionListener;
|
|||||||
import noppes.npcs.client.gui.util.ITextfieldListener;
|
import noppes.npcs.client.gui.util.ITextfieldListener;
|
||||||
import noppes.npcs.client.gui.util.IGuiData;
|
import noppes.npcs.client.gui.util.IGuiData;
|
||||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
import noppes.npcs.constants.EnumAvailabilityDialog;
|
|
||||||
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
||||||
import noppes.npcs.constants.EnumAvailabilityQuest;
|
|
||||||
import noppes.npcs.constants.EnumDayTime;
|
import noppes.npcs.constants.EnumDayTime;
|
||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
import noppes.npcs.controllers.Availability;
|
import noppes.npcs.controllers.Availability;
|
||||||
import noppes.npcs.controllers.Dialog;
|
|
||||||
import noppes.npcs.controllers.Faction;
|
import noppes.npcs.controllers.Faction;
|
||||||
import noppes.npcs.controllers.Quest;
|
|
||||||
|
|
||||||
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
|
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
|
||||||
{
|
{
|
||||||
@@ -66,7 +60,7 @@ public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfield
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175));
|
addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175));
|
||||||
this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + ""));
|
this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + ""));
|
||||||
this.getTextField(51).numbersOnly = true;
|
this.getTextField(51).integersOnly = true;
|
||||||
this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
|
|
||||||
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
|
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
|
|||||||
addButton(new GuiNpcButtonYesNo(15, guiLeft + 120, y += 22, dialog.disableEsc));
|
addButton(new GuiNpcButtonYesNo(15, guiLeft + 120, y += 22, dialog.disableEsc));
|
||||||
addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(15, "dialog.disableEsc", guiLeft + 4, y + 5));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButtonYesNo(16, guiLeft + 120, y += 22, dialog.darkenScreen));
|
||||||
|
addLabel(new GuiNpcLabel(16, "Darken Screen", guiLeft + 4, y + 5));
|
||||||
|
|
||||||
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
|
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -76,6 +79,9 @@ public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiList
|
|||||||
if(button.id == 15){
|
if(button.id == 15){
|
||||||
dialog.disableEsc = button.getValue() == 1;
|
dialog.disableEsc = button.getValue() == 1;
|
||||||
}
|
}
|
||||||
|
if(button.id == 16){
|
||||||
|
dialog.darkenScreen = button.getValue() == 1;
|
||||||
|
}
|
||||||
if(button.id == 13){
|
if(button.id == 13){
|
||||||
setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent()));
|
setSubGui(new SubGuiMailmanSendSetup(dialog.mail, getParent()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
|||||||
addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0));
|
addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10"));
|
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10"));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(1, 100000, 10);
|
getTextField(1).setMinMaxDefault(1, 100000, 10);
|
||||||
|
|
||||||
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add"));
|
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add"));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
|
|||||||
|
|
||||||
this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + ""));
|
this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + ""));
|
||||||
getTextField(2).setMaxStringLength(6);
|
getTextField(2).setMaxStringLength(6);
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
|
|
||||||
String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral");
|
String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral");
|
||||||
addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80));
|
addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80));
|
||||||
@@ -38,8 +38,8 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
|
|||||||
addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105));
|
addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105));
|
||||||
addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + ""));
|
addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + ""));
|
||||||
|
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
|
|
||||||
if(getTextField(3).xPosition > getTextField(4).xPosition)
|
if(getTextField(3).xPosition > getTextField(4).xPosition)
|
||||||
getTextField(4).xPosition = getTextField(3).xPosition;
|
getTextField(4).xPosition = getTextField(3).xPosition;
|
||||||
|
|||||||