mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 19:54:26 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
No files matched your search
@@ -1,86 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="CustomNPC-Plus-1.21" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.yourname.modid" external.system.module.version="1.2.1" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/api/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/api/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" name="Gradle: :forgeSrc:1.7.10-10.13.4.1614-1.7.10" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.minecraft:launchwrapper:1.12" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.ow2.asm:asm-debug-all:5.0.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.typesafe.akka:akka-actor_2.11:2.3.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.typesafe:config:1.2.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-actors-migration_2.11:1.1.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-compiler:2.11.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-library:2.11.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-parser-combinators_2.11:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-reflect:2.11.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-swing_2.11:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-xml_2.11:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.sf.jopt-simple:jopt-simple:4.5" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: lzma:lzma:0.0.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.mojang:realms:1.3.5" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-compress:1.8.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpclient:4.3.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.1.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore:4.3.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: java3d:vecmath:1.3.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.ibm.icu:icu4j-core-mojang:51.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.paulscode:codecjorbis:20101023" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.paulscode:codecwav:20101023" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.paulscode:libraryjavasound:20101123" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.paulscode:librarylwjglopenal:20100824" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.paulscode:soundsystem:20120107" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: io.netty:netty-all:4.0.10.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.google.guava:guava:17.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-lang3:3.3.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: commons-io:commons-io:2.4" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.java.jinput:jinput:2.0.5" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.java.jutils:jutils:1.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.2.4" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.mojang:authlib:1.5.16" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-api:2.0-beta9" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-core:2.0-beta9" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.lwjgl.lwjgl:lwjgl:2.9.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.lwjgl.lwjgl:lwjgl_util:2.9.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch:5.16" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang:scala-actors:2.11.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang.modules:scala-xml_2.11:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.java.jinput:jinput-platform:2.0.5:natives-linux" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.java.jinput:jinput-platform:2.0.5:natives-windows" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: net.java.jinput:jinput-platform:2.0.5:natives-osx" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch-platform:5.16:natives-windows-32" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch-platform:5.16:natives-windows-64" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch-platform:5.16:natives-osx" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch-external-platform:4.5:natives-windows-32" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: tv.twitch:twitch-external-platform:4.5:natives-windows-64" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.lwjgl.lwjgl:lwjgl-platform:2.9.1:natives-windows" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.lwjgl.lwjgl:lwjgl-platform:2.9.1:natives-linux" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: org.lwjgl.lwjgl:lwjgl-platform:2.9.1:natives-osx" level="project" />
|
|
||||||
<orderEntry type="module-library" scope="RUNTIME">
|
|
||||||
<library name="Gradle: C__Users_luisc__gradle_caches_minecraft_net_minecraftforge_forge_1_7_10_10_13_4_1614_1_7_10_start">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/start" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="library" name="guava-31.0.1-jre" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
@@ -31,7 +31,8 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
|
|||||||
- [x] Backported New Part Models
|
- [x] Backported New Part Models
|
||||||
- [X] Custom Part Disabling
|
- [X] Custom Part Disabling
|
||||||
- [X] Markov Name Generator
|
- [X] Markov Name Generator
|
||||||
- [ ] Flying NPCS [WIP]
|
- [X] Flying NPCS
|
||||||
|
- [X] Better Script Speeds
|
||||||
--- Please Suggest New Features!
|
--- Please Suggest New Features!
|
||||||
|
|
||||||
###### **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.*
|
||||||
|
|||||||
Binary file not shown.
+3
-1
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.3"
|
version = "1.4.2"
|
||||||
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "CustomNPC-Plus"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
@@ -64,3 +64,5 @@ processResources
|
|||||||
exclude 'mcmod.info'
|
exclude 'mcmod.info'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||||
@@ -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,7 +33,6 @@ 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",
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -4,32 +4,14 @@ 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.stats.Achievement;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
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.containers.ContainerMail;
|
|
||||||
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.controllers.PlayerData;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
@@ -59,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);
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import noppes.npcs.entity.old.EntityNpcNagaMale;
|
|||||||
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.3")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.4.2")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@ConfigProp(info = "Disable Chat Bubbles")
|
@ConfigProp(info = "Disable Chat Bubbles")
|
||||||
@@ -69,7 +69,7 @@ public class CustomNpcs {
|
|||||||
|
|
||||||
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 = "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 = "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")
|
||||||
@@ -167,6 +167,10 @@ public class CustomNpcs {
|
|||||||
if (NpcNavRange < 16) {
|
if (NpcNavRange < 16) {
|
||||||
NpcNavRange = 16;
|
NpcNavRange = 16;
|
||||||
}
|
}
|
||||||
|
if (NpcNavRange > 96) {
|
||||||
|
NpcNavRange = 96;
|
||||||
|
}
|
||||||
|
|
||||||
EnchantInterface.load();
|
EnchantInterface.load();
|
||||||
CustomItems.load();
|
CustomItems.load();
|
||||||
|
|
||||||
@@ -178,7 +182,12 @@ public class CustomNpcs {
|
|||||||
|
|
||||||
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
|
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
|
||||||
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
|
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
|
||||||
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler.registerForgeEvents());
|
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");
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public class DataAI {
|
|||||||
|
|
||||||
// Fly Change
|
// Fly Change
|
||||||
public int movementType = 0;
|
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;
|
||||||
@@ -96,7 +100,27 @@ public class DataAI {
|
|||||||
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
|
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
|
||||||
movingPos = compound.getInteger("MovingPos");
|
movingPos = compound.getInteger("MovingPos");
|
||||||
movingPattern = compound.getInteger("MovingPatern");
|
movingPattern = compound.getInteger("MovingPatern");
|
||||||
|
|
||||||
movementType = compound.getInteger("MovingType");
|
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){
|
||||||
@@ -143,7 +167,12 @@ public class DataAI {
|
|||||||
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
|
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
|
||||||
compound.setInteger("MovingPos", movingPos);
|
compound.setInteger("MovingPos", movingPos);
|
||||||
compound.setInteger("MovingPatern", movingPattern);
|
compound.setInteger("MovingPatern", movingPattern);
|
||||||
|
|
||||||
compound.setInteger("MovingType", movementType);
|
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);
|
||||||
|
|
||||||
|
|||||||
@@ -52,42 +52,13 @@ public class DataDisplay {
|
|||||||
|
|
||||||
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
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;
|
||||||
|
|
||||||
/*
|
|
||||||
Implementing MarkovNames generator. You can blame this blunder on Nikedemos.
|
|
||||||
|
|
||||||
Please refer to nikedemos.markovnames.generators.MarkovCustomNPCsClassic.java
|
|
||||||
|
|
||||||
String[] names = { "Noppes", "Noppes", "Noppes", "Noppes", "Atesson",
|
|
||||||
"Rothcersul", "Achdranys", "Pegato", "Chald", "Gareld",
|
|
||||||
"Nalworche", "Ineald", "Tia'kim", "Torerod", "Turturdar",
|
|
||||||
"Ranler", "Dyntan", "Oldrake", "Gharis", "Elmn", "Tanal",
|
|
||||||
"Waran-ess", "Ach-aldhat", "Athi", "Itageray", "Tasr",
|
|
||||||
"Ightech", "Gakih", "Adkal", "Qua'an", "Sieq", "Urnp", "Rods",
|
|
||||||
"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)];
|
|
||||||
*/
|
|
||||||
|
|
||||||
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
|
||||||
name = getRandomName();
|
name = getRandomName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRandomName() {
|
public String getRandomName() {
|
||||||
@@ -121,6 +92,8 @@ 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();
|
NBTTagList list = new NBTTagList();
|
||||||
for(UUID uuid : invisibleToList){
|
for(UUID uuid : invisibleToList){
|
||||||
list.appendTag(new NBTTagString(uuid.toString()));
|
list.appendTag(new NBTTagString(uuid.toString()));
|
||||||
@@ -159,7 +132,7 @@ 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, 30);
|
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
|
||||||
modelType = nbttagcompound.getInteger("modelType");
|
modelType = nbttagcompound.getInteger("modelType");
|
||||||
|
|
||||||
showName = nbttagcompound.getInteger("ShowName");
|
showName = nbttagcompound.getInteger("ShowName");
|
||||||
@@ -168,12 +141,22 @@ public class DataDisplay {
|
|||||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||||
showBossBar = nbttagcompound.getByte("BossBar");
|
showBossBar = nbttagcompound.getByte("BossBar");
|
||||||
|
|
||||||
invisibleToList.clear();
|
|
||||||
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
||||||
for(int i = 0; i < tagList.tagCount(); i++){
|
if(tagList != null) {
|
||||||
String nbtTagString = tagList.getStringTagAt(i);
|
invisibleToList.clear();
|
||||||
invisibleToList.add(UUID.fromString(nbtTagString));
|
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;
|
||||||
|
|||||||
@@ -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,20 +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.NpcAPI;
|
||||||
import noppes.npcs.scripted.event.ScriptEvent;
|
import noppes.npcs.scripted.event.ScriptEvent;
|
||||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
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.interfaces.IWorld;
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
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();
|
||||||
@@ -34,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 IWorld 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) {
|
||||||
@@ -61,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);
|
||||||
@@ -144,6 +155,74 @@ public class DataScript {
|
|||||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.item.EntityXPOrb;
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -18,11 +19,14 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.event.entity.EntityEvent;
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import noppes.npcs.controllers.CustomGuiController;
|
||||||
|
import noppes.npcs.controllers.Quest;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.*;
|
import noppes.npcs.scripted.*;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
import noppes.npcs.scripted.event.*;
|
import noppes.npcs.scripted.event.*;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
|
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
|
||||||
@@ -32,6 +36,7 @@ import noppes.npcs.scripted.event.PlayerEvent.LoginEvent;
|
|||||||
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGui;
|
||||||
import noppes.npcs.scripted.interfaces.IEntity;
|
import noppes.npcs.scripted.interfaces.IEntity;
|
||||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||||
import noppes.npcs.scripted.interfaces.IWorld;
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
@@ -46,6 +51,8 @@ public class EventHooks {
|
|||||||
public EventHooks() {
|
public EventHooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
||||||
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||||
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||||
@@ -53,224 +60,224 @@ public class EventHooks {
|
|||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerInit(PlayerDataScript handler) {
|
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(handler.getPlayer());
|
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
|
||||||
handler.callScript(EnumScriptType.INIT, event, "event", event);
|
handler.callScript(EnumScriptType.INIT, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerTick(PlayerDataScript handler) {
|
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(handler.getPlayer());
|
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
|
||||||
handler.callScript(EnumScriptType.TICK, event, "event", event);
|
handler.callScript(EnumScriptType.TICK, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
|
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
|
||||||
handler.callScript(EnumScriptType.INTERACT, event,"event", event);
|
handler.callScript(EnumScriptType.INTERACT, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onStartUsingItem(PlayerDataScript handler, int duration, ItemStack item){
|
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(handler.getPlayer(), item, duration);
|
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
|
||||||
handler.callScript(EnumScriptType.START_USING_ITEM, event,"event", event);
|
handler.callScript(EnumScriptType.START_USING_ITEM, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onUsingItem(PlayerDataScript handler, int duration, ItemStack item){
|
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(handler.getPlayer(), item, duration);
|
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
|
||||||
handler.callScript(EnumScriptType.USING_ITEM, event,"event", event);
|
handler.callScript(EnumScriptType.USING_ITEM, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onStopUsingItem(PlayerDataScript handler, int duration, ItemStack item){
|
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(handler.getPlayer(), item, duration);
|
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
|
||||||
handler.callScript(EnumScriptType.STOP_USING_ITEM, event,"event", event);
|
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onFinishUsingItem(PlayerDataScript handler, int duration, ItemStack item){
|
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(handler.getPlayer(), item, duration);
|
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
|
||||||
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event,"event", event);
|
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerDropItems(PlayerDataScript handler, ArrayList<EntityItem> entityItems) {
|
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
|
||||||
IItemStack[] items = new IItemStack[entityItems.size()];
|
IItemStack[] items = new IItemStack[entityItems.size()];
|
||||||
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
|
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
|
||||||
|
|
||||||
DropEvent event = new DropEvent(handler.getPlayer(), items);
|
DropEvent event = new DropEvent(player, items);
|
||||||
handler.callScript(EnumScriptType.DROP, event,"event", event);
|
handler.callScript(EnumScriptType.DROP, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerPickupXP(PlayerDataScript handler, EntityXPOrb orb) {
|
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
|
||||||
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(handler.getPlayer(), orb);
|
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
|
||||||
handler.callScript(EnumScriptType.PICKUP_XP, event,"event", event);
|
handler.callScript(EnumScriptType.PICKUP_XP, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerToss(PlayerDataScript handler, EntityItem entityItem) {
|
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(handler.getPlayer(), NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
handler.callScript(EnumScriptType.TOSS, event,"event", event);
|
handler.callScript(EnumScriptType.TOSS, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerPickUp(PlayerDataScript handler, EntityItem entityItem) {
|
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
PickUpEvent event = new PickUpEvent(handler.getPlayer(), new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
handler.callScript(EnumScriptType.PICKUP, event,"event", event);
|
handler.callScript(EnumScriptType.PICKUP, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerContainerOpen(PlayerDataScript handler, Container container) {
|
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
|
||||||
ContainerOpen event = new ContainerOpen(handler.getPlayer(), NpcAPI.Instance().getIContainer(container));
|
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
|
||||||
handler.callScript(EnumScriptType.CONTAINER_OPEN, event,"event", event);
|
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerUseHoe(PlayerDataScript handler, ItemStack hoe, int x, int y, int z) {
|
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(handler.getPlayer(), hoe, x, y, 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,"event", event);
|
handler.callScript(EnumScriptType.USE_HOE, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerSleep(PlayerDataScript handler, int x, int y, int z) {
|
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(handler.getPlayer(), x, y, z);
|
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
|
||||||
handler.callScript(EnumScriptType.SLEEP, event,"event", event);
|
handler.callScript(EnumScriptType.SLEEP, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerWakeUp(PlayerDataScript handler, boolean setSpawn) {
|
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
|
||||||
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(handler.getPlayer(), setSpawn);
|
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
|
||||||
handler.callScript(EnumScriptType.WAKE_UP, event,"event", event);
|
handler.callScript(EnumScriptType.WAKE_UP, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerDeath(PlayerDataScript handler, DamageSource source, Entity entity) {
|
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(handler.getPlayer(), source, entity);
|
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
|
||||||
handler.callScript(EnumScriptType.KILLED, event,"event", event);
|
handler.callScript(EnumScriptType.KILLED, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerKills(PlayerDataScript handler, EntityLivingBase entityLiving) {
|
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
|
||||||
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(handler.getPlayer(), entityLiving);
|
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
|
||||||
handler.callScript(EnumScriptType.KILLS, event,"event", event);
|
handler.callScript(EnumScriptType.KILLS, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
|
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
|
||||||
handler.callScript(EnumScriptType.DAMAGED, event,"event", event);
|
handler.callScript(EnumScriptType.DAMAGED, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerLightning(PlayerDataScript handler) {
|
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(handler.getPlayer());
|
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
|
||||||
handler.callScript(EnumScriptType.LIGHTNING, event, "event", event);
|
handler.callScript(EnumScriptType.LIGHTNING, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerSound(PlayerDataScript handler, String name, float pitch, float volume) {
|
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
|
||||||
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(handler.getPlayer(), name, pitch, volume);
|
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
|
||||||
handler.callScript(EnumScriptType.PLAYSOUND, event,"event", event);
|
handler.callScript(EnumScriptType.PLAYSOUND, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerFall(PlayerDataScript handler, float distance) {
|
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
|
||||||
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(handler.getPlayer(),distance);
|
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
|
||||||
handler.callScript(EnumScriptType.FALL, event,"event", event);
|
handler.callScript(EnumScriptType.FALL, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerJump(PlayerDataScript handler) {
|
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(handler.getPlayer());
|
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
|
||||||
handler.callScript(EnumScriptType.JUMP, event,"event", event);
|
handler.callScript(EnumScriptType.JUMP, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerLogin(PlayerDataScript handler) {
|
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
LoginEvent event = new LoginEvent(handler.getPlayer());
|
LoginEvent event = new LoginEvent(player);
|
||||||
handler.callScript(EnumScriptType.LOGIN, event, "event", event);
|
handler.callScript(EnumScriptType.LOGIN, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerAchievement(PlayerDataScript handler, String description) {
|
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
|
||||||
PlayerEvent.Achievement event = new PlayerEvent.Achievement(handler.getPlayer(), description);
|
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
|
||||||
handler.callScript(EnumScriptType.ACHIEVEMENT, event, "event", event);
|
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerFillBucket(PlayerDataScript handler, ItemStack current, ItemStack result) {
|
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
|
||||||
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(handler.getPlayer(), current, result);
|
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
|
||||||
handler.callScript(EnumScriptType.FILL_BUCKET, event, "event", event);
|
handler.callScript(EnumScriptType.FILL_BUCKET, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerBonemeal(PlayerDataScript handler, int x, int y, int z, World world) {
|
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
|
||||||
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(handler.getPlayer(), x, y, z, world);
|
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
|
||||||
handler.callScript(EnumScriptType.BONEMEAL, event, "event", event);
|
handler.callScript(EnumScriptType.BONEMEAL, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerRespawn(PlayerDataScript handler) {
|
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(handler.getPlayer());
|
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
|
||||||
handler.callScript(EnumScriptType.RESPAWN, event, "event", event);
|
handler.callScript(EnumScriptType.RESPAWN, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerLogout(PlayerDataScript handler) {
|
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
LogoutEvent event = new LogoutEvent(handler.getPlayer());
|
LogoutEvent event = new LogoutEvent(player);
|
||||||
handler.callScript(EnumScriptType.LOGOUT, event, "event", event);
|
handler.callScript(EnumScriptType.LOGOUT, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
|
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
|
||||||
handler.callScript(EnumScriptType.CHAT, event,"event", event);
|
handler.callScript(EnumScriptType.CHAT, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
|
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
|
||||||
handler.callScript(EnumScriptType.RANGED_CHARGE, event,"event", event);
|
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
|
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
|
||||||
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event,"event", event);
|
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
|
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
|
||||||
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event,"event", event);
|
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerChangeDim(PlayerDataScript handler, int fromDim, int toDim) {
|
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
|
||||||
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(handler.getPlayer(), fromDim, toDim);
|
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
|
||||||
handler.callScript(EnumScriptType.CHANGED_DIM, event,"event", event);
|
handler.callScript(EnumScriptType.CHANGED_DIM, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
|
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
|
||||||
PlayerDataScript handler = PlayerData.get(player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent(handler.getPlayer(), button, mouseWheel, buttonDown);
|
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
|
||||||
handler.callScript(EnumScriptType.MOUSE_CLICKED, event,"event", event);
|
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown) {
|
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown) {
|
||||||
PlayerDataScript handler = PlayerData.get(player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
KeyPressedEvent event = new KeyPressedEvent(handler.getPlayer(), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown);
|
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown);
|
||||||
handler.callScript(EnumScriptType.KEY_PRESSED, event,"event", event);
|
handler.callScript(EnumScriptType.KEY_PRESSED, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPlayerTimer(PlayerData data, int id) {
|
public static void onPlayerTimer(PlayerData data, int id) {
|
||||||
PlayerDataScript handler = data.scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent(handler.getPlayer(), id);
|
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,"event", event);
|
handler.callScript(EnumScriptType.TIMER, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
|
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
|
||||||
handler.callScript(EnumScriptType.BREAK_BLOCK, event,"event", event);
|
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
|
||||||
return WrapperNpcAPI.EVENT_BUS.post(event);
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,4 +317,73 @@ public class EventHooks {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
//
|
|
||||||
// Source code recreated from a .class file by IntelliJ IDEA
|
|
||||||
// (powered by Fernflower decompiler)
|
|
||||||
//
|
|
||||||
|
|
||||||
package noppes.npcs;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.*;
|
|
||||||
import javax.script.Compilable;
|
|
||||||
import javax.script.CompiledScript;
|
|
||||||
import javax.script.Invocable;
|
|
||||||
import javax.script.ScriptEngine;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
|
||||||
import noppes.npcs.controllers.IScriptHandler;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
|
|
||||||
public class EventScriptContainer {
|
|
||||||
public static EventScriptContainer Current;
|
|
||||||
//public String type = "init";
|
|
||||||
private static String CurrentType;
|
|
||||||
public String fullscript = "";
|
|
||||||
public String script = "";
|
|
||||||
public TreeMap<Long, String> console = new TreeMap();
|
|
||||||
private HashSet<String> unknownFunctions = new HashSet();
|
|
||||||
public boolean errored = false;
|
|
||||||
public List<String> scripts = new ArrayList();
|
|
||||||
public long lastCreated = 0L;
|
|
||||||
private String currentScriptLanguage = null;
|
|
||||||
public ScriptEngine engine = null;
|
|
||||||
private IScriptHandler handler = null;
|
|
||||||
private CompiledScript compScript = null;
|
|
||||||
private boolean init = false;
|
|
||||||
|
|
||||||
public EventScriptContainer(IScriptHandler handler) {
|
|
||||||
this.handler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
|
||||||
this.script = compound.getString("Script");
|
|
||||||
//this.type = compound.getString("Type");
|
|
||||||
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
|
|
||||||
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
|
|
||||||
this.lastCreated = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
|
||||||
compound.setString("Script", this.script);
|
|
||||||
//compound.setString("Type", this.type);
|
|
||||||
compound.setTag("Console", NBTTags.NBTLongStringMap(this.console));
|
|
||||||
compound.setTag("ScriptList", NBTTags.nbtStringList(this.scripts));
|
|
||||||
return compound;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFullCode() {
|
|
||||||
if(!this.init) {
|
|
||||||
this.fullscript = this.script;
|
|
||||||
if(!this.fullscript.isEmpty()) {
|
|
||||||
this.fullscript = this.fullscript + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator var1 = this.scripts.iterator();
|
|
||||||
|
|
||||||
while(var1.hasNext()) {
|
|
||||||
String loc = (String)var1.next();
|
|
||||||
String code = (String)ScriptController.Instance.scripts.get(loc);
|
|
||||||
if(code != null && !code.isEmpty()) {
|
|
||||||
this.fullscript = this.fullscript + code + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fullscript;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public void run(ScriptEngine engine){
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
|
||||||
engine.getContext().setWriter(pw);
|
|
||||||
engine.getContext().setErrorWriter(pw);
|
|
||||||
try {
|
|
||||||
if(compScript == null && engine instanceof Compilable)
|
|
||||||
compScript = ((Compilable)engine).compile(getFullCode());
|
|
||||||
|
|
||||||
if(compScript != null){
|
|
||||||
compScript.eval(engine.getContext());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
engine.eval(getFullCode());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
errored = true;
|
|
||||||
appandConsole(e.getMessage());
|
|
||||||
}
|
|
||||||
appandConsole(sw.getBuffer().toString().trim());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void run(EnumScriptType type, Event event) {
|
|
||||||
this.run((String)type.function, (Object)event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(String type, Object event) {
|
|
||||||
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
|
||||||
this.setEngine(this.handler.getLanguage());
|
|
||||||
if (this.engine != null) {
|
|
||||||
if (ScriptController.Instance.lastLoaded > this.lastCreated) {
|
|
||||||
this.lastCreated = ScriptController.Instance.lastLoaded;
|
|
||||||
this.init = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String var3 = "lock";
|
|
||||||
synchronized("lock") {
|
|
||||||
Current = this;
|
|
||||||
CurrentType = type;
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
|
||||||
this.engine.getContext().setWriter(pw);
|
|
||||||
this.engine.getContext().setErrorWriter(pw);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!this.init) {
|
|
||||||
this.engine.eval(this.getFullCode());
|
|
||||||
this.init = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
((Invocable)this.engine).invokeFunction(type, new Object[]{event});
|
|
||||||
} catch (NoSuchMethodException var13) {
|
|
||||||
this.unknownFunctions.add(type);
|
|
||||||
} catch (Throwable var14) {
|
|
||||||
this.errored = true;
|
|
||||||
var14.printStackTrace(pw);
|
|
||||||
} finally {
|
|
||||||
this.appandConsole(sw.getBuffer().toString().trim());
|
|
||||||
pw.close();
|
|
||||||
Current = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void appandConsole(String message) {
|
|
||||||
if (message != null && !message.isEmpty()) {
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
if (this.console.containsKey(time)) {
|
|
||||||
message = (String)this.console.get(time) + "\n" + message;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.console.put(time, message);
|
|
||||||
|
|
||||||
while(this.console.size() > 40) {
|
|
||||||
this.console.remove(this.console.firstKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasCode() {
|
|
||||||
return !this.getFullCode().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEngine(String scriptLanguage) {
|
|
||||||
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
|
|
||||||
return;
|
|
||||||
engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
|
||||||
currentScriptLanguage = scriptLanguage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,6 +34,10 @@ public class ModelDataShared{
|
|||||||
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],
|
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
|
||||||
public byte hideHead = 0;
|
public byte hideHead = 0;
|
||||||
public byte hideBody = 0;
|
public byte hideBody = 0;
|
||||||
@@ -58,6 +62,9 @@ public class ModelDataShared{
|
|||||||
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("hideHead", hideHead);
|
||||||
compound.setByte("hideBody", hideBody);
|
compound.setByte("hideBody", hideBody);
|
||||||
compound.setByte("hideArms", hideArms);
|
compound.setByte("hideArms", hideArms);
|
||||||
@@ -92,6 +99,9 @@ public class ModelDataShared{
|
|||||||
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");
|
hideHead = compound.getByte("hideHead");
|
||||||
hideBody = compound.getByte("hideBody");
|
hideBody = compound.getByte("hideBody");
|
||||||
hideArms = compound.getByte("hideArms");
|
hideArms = compound.getByte("hideArms");
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.controllers.IScriptHandler;
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
|
||||||
public class NBTTags {
|
public class NBTTags {
|
||||||
@@ -408,12 +409,12 @@ public class NBTTags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<EventScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
|
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
|
||||||
ArrayList scripts = new ArrayList();
|
ArrayList scripts = new ArrayList();
|
||||||
|
|
||||||
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);
|
||||||
EventScriptContainer script = new EventScriptContainer(handler);
|
ScriptContainer script = new ScriptContainer(handler);
|
||||||
script.readFromNBT(compoundd);
|
script.readFromNBT(compoundd);
|
||||||
scripts.add(script);
|
scripts.add(script);
|
||||||
}
|
}
|
||||||
@@ -421,12 +422,12 @@ public class NBTTags {
|
|||||||
return scripts;
|
return scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NBTTagList NBTScript(List<EventScriptContainer> scripts) {
|
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
Iterator var2 = scripts.iterator();
|
Iterator var2 = scripts.iterator();
|
||||||
|
|
||||||
while(var2.hasNext()) {
|
while(var2.hasNext()) {
|
||||||
EventScriptContainer script = (EventScriptContainer)var2.next();
|
ScriptContainer script = (ScriptContainer)var2.next();
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
script.writeToNBT(compound);
|
script.writeToNBT(compound);
|
||||||
list.appendTag(compound);
|
list.appendTag(compound);
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -43,6 +44,11 @@ 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 {
|
||||||
|
|
||||||
@@ -259,13 +265,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));
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -293,41 +305,58 @@ public class NoppesUtilPlayer {
|
|||||||
public static void questCompletion(EntityPlayerMP player, int questId) {
|
public static void questCompletion(EntityPlayerMP player, int questId) {
|
||||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||||
QuestData data = playerdata.activeQuests.get(questId);
|
QuestData data = playerdata.activeQuests.get(questId);
|
||||||
|
|
||||||
if(data == null)
|
if(data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!data.quest.questInterface.isCompleted(player))
|
if(!data.quest.questInterface.isCompleted(player))
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -400,4 +429,31 @@ public class NoppesUtilPlayer {
|
|||||||
public static void isGUIOpen(EntityPlayerMP player){
|
public static void isGUIOpen(EntityPlayerMP player){
|
||||||
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -72,6 +72,8 @@ 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.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.DialogEvent;
|
||||||
import noppes.npcs.scripted.event.ScriptEventDialog;
|
import noppes.npcs.scripted.event.ScriptEventDialog;
|
||||||
|
|
||||||
public class NoppesUtilServer {
|
public class NoppesUtilServer {
|
||||||
@@ -180,6 +182,9 @@ public class NoppesUtilServer {
|
|||||||
|
|
||||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
|
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
|
||||||
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()));
|
||||||
@@ -314,7 +319,7 @@ public class NoppesUtilServer {
|
|||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
int entityID
|
int entityID
|
||||||
){
|
){
|
||||||
Server.sendAssociatedData(entity, EnumPacketClient.SCRIPTED_PARTICLE,
|
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||||
directory, HEXcolor, amount, maxAge,
|
directory, HEXcolor, amount, maxAge,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
@@ -711,4 +716,8 @@ public class NoppesUtilServer {
|
|||||||
boolean isGUIOpen = buffer.readBoolean();
|
boolean isGUIOpen = buffer.readBoolean();
|
||||||
playerdata.setGUIOpen(isGUIOpen);
|
playerdata.setGUIOpen(isGUIOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean IsItemStackNull(ItemStack is) {
|
||||||
|
return is == null || is.stackSize == 0 || is.getItem() == null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -36,31 +36,10 @@ 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.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.PlayerMail;
|
|
||||||
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.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
@@ -71,6 +50,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{
|
||||||
|
|
||||||
@@ -93,6 +75,25 @@ public class PacketHandlerServer{
|
|||||||
if(type == EnumPacketServer.IsGuiOpen) {
|
if(type == EnumPacketServer.IsGuiOpen) {
|
||||||
isGuiOpenPacket(buffer, player);
|
isGuiOpenPacket(buffer, player);
|
||||||
return;
|
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){
|
||||||
@@ -103,24 +104,28 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.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(type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
else if (item.getItem() == CustomItems.teleporter)
|
||||||
playerScriptPackets(type, buffer, player);
|
featherPackets(type, buffer, player);
|
||||||
else if(type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||||
forgeScriptPackets(type, buffer, player);
|
playerScriptPackets(type, buffer, player);
|
||||||
else if(item.getItem() == CustomItems.scripter)
|
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||||
scriptPackets(type, buffer, player, npc);
|
forgeScriptPackets(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 (item.getItem() == CustomItems.scripter)
|
||||||
blockPackets(type, buffer, player);
|
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);
|
||||||
}
|
}
|
||||||
@@ -264,7 +269,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);
|
||||||
}
|
}
|
||||||
@@ -380,7 +385,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(""));
|
||||||
}
|
}
|
||||||
@@ -562,7 +567,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);
|
||||||
|
|||||||
@@ -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.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent;
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ContainerPlayer;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
@@ -43,14 +44,14 @@ import net.minecraftforge.event.entity.living.LivingEvent;
|
|||||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.minecraftforge.event.entity.player.*;
|
import net.minecraftforge.event.entity.player.*;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.*;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
|
||||||
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
|
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
import noppes.npcs.scripted.event.ForgeEvent;
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
import noppes.npcs.controllers.PixelmonHelper;
|
import noppes.npcs.controllers.PixelmonHelper;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
@@ -63,12 +64,16 @@ public class ScriptPlayerEventHandler {
|
|||||||
public void onServerTick(TickEvent.PlayerTickEvent event) {
|
public void onServerTick(TickEvent.PlayerTickEvent event) {
|
||||||
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
||||||
EntityPlayer player = event.player;
|
EntityPlayer player = event.player;
|
||||||
PlayerData data = PlayerData.get(player);
|
|
||||||
EventHooks.onPlayerTick(data.scriptData);
|
if(player.ticksExisted%10 == 0) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
|
||||||
|
EventHooks.onPlayerTick(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
if(PlayerDataController.instance != null) {
|
if(PlayerDataController.instance != null) {
|
||||||
PlayerDataController.instance.getPlayerData(player).scriptData = data.scriptData;
|
if(PlayerDataController.instance.getPlayerData(player).timers.size() > 0)
|
||||||
PlayerDataController.instance.getPlayerData(player).timers.update();
|
PlayerDataController.instance.getPlayerData(player).timers.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,8 +81,9 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(EntityInteractEvent event) {
|
public void invoke(EntityInteractEvent event) {
|
||||||
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(handler.getPlayer(), 1, NpcAPI.Instance().getIEntity(event.target));
|
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));
|
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,8 +91,9 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(ArrowNockEvent event) {
|
public void invoke(ArrowNockEvent event) {
|
||||||
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(handler.getPlayer());
|
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);
|
EventHooks.onPlayerBowCharge(handler, ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,8 +101,9 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(ArrowLooseEvent event) {
|
public void invoke(ArrowLooseEvent event) {
|
||||||
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(handler.getPlayer(), event.bow, event.charge);
|
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);
|
EventHooks.onPlayerRanged(handler, ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,8 +111,9 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(BlockEvent.BreakEvent event) {
|
public void invoke(BlockEvent.BreakEvent event) {
|
||||||
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
|
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.getPlayer()).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(handler.getPlayer(), NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
|
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.setCanceled(EventHooks.onPlayerBreak(handler, ev));
|
||||||
event.setExpToDrop(ev.exp);
|
event.setExpToDrop(ev.exp);
|
||||||
}
|
}
|
||||||
@@ -113,135 +122,151 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerUseItemEvent.Start event) {
|
public void invoke(PlayerUseItemEvent.Start event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
event.setCanceled(EventHooks.onStartUsingItem(handler, event.duration, event.item));
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerUseItemEvent.Tick event) {
|
public void invoke(PlayerUseItemEvent.Tick event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
event.setCanceled(EventHooks.onUsingItem(handler, event.duration, event.item));
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerUseItemEvent.Stop event) {
|
public void invoke(PlayerUseItemEvent.Stop event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
event.setCanceled(EventHooks.onStopUsingItem(handler, event.duration, event.item));
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerUseItemEvent.Finish event) {
|
public void invoke(PlayerUseItemEvent.Finish event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onFinishUsingItem(handler, event.duration, event.item);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerDropsEvent event) {
|
public void invoke(PlayerDropsEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
event.setCanceled(EventHooks.onPlayerDropItems(handler, event.drops));
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerPickupXpEvent event) {
|
public void invoke(PlayerPickupXpEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerPickupXP(handler, event.orb);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
|
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerChangeDim(handler, event.fromDim, event.toDim);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerEvent.ItemPickupEvent event) {
|
public void invoke(PlayerEvent.ItemPickupEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerPickUp(handler, event.pickedUp);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerOpenContainerEvent event) {
|
public void invoke(PlayerOpenContainerEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerContainerOpen(handler, event.entityPlayer.openContainer);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(UseHoeEvent event) {
|
public void invoke(UseHoeEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerUseHoe(handler, event.current, event.x, event.y, event.z);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerSleepInBedEvent event) {
|
public void invoke(PlayerSleepInBedEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerSleep(handler, event.x, event.y, event.z);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerWakeUpEvent event) {
|
public void invoke(PlayerWakeUpEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerWakeUp(handler, event.setSpawn);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(FillBucketEvent event) {
|
public void invoke(FillBucketEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerFillBucket(handler, event.current, event.result);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(BonemealEvent event) {
|
public void invoke(BonemealEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerBonemeal(handler, event.x, event.y, event.z, event.world);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(AchievementEvent event) {
|
public void invoke(AchievementEvent event) {
|
||||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerAchievement(handler, CustomNpcs.proxy.getAchievementDesc(event.achievement));
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(ItemTossEvent event) {
|
public void invoke(ItemTossEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerToss(handler, event.entityItem);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(LivingFallEvent event) {
|
public void invoke(LivingFallEvent event) {
|
||||||
if(event.entityLiving.worldObj instanceof WorldServer) {
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler;
|
|
||||||
if (event.entityLiving instanceof EntityPlayer) {
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerFall(handler, event.distance);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,10 +274,10 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(LivingEvent.LivingJumpEvent event) {
|
public void invoke(LivingEvent.LivingJumpEvent event) {
|
||||||
if(event.entityLiving.worldObj instanceof WorldServer) {
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler;
|
|
||||||
if (event.entityLiving instanceof EntityPlayer) {
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerJump(handler);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerJump(handler, scriptPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,10 +285,10 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(EntityStruckByLightningEvent event) {
|
public void invoke(EntityStruckByLightningEvent event) {
|
||||||
if(event.entity.worldObj instanceof WorldServer) {
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler;
|
|
||||||
if (event.entity instanceof EntityPlayer) {
|
if (event.entity instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entity).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerLightning(handler);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerLightning(handler, scriptPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,10 +296,10 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlaySoundAtEntityEvent event) {
|
public void invoke(PlaySoundAtEntityEvent event) {
|
||||||
if(event.entity.worldObj instanceof WorldServer) {
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler;
|
|
||||||
if (event.entity instanceof EntityPlayer) {
|
if (event.entity instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entity).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerSound(handler,event.name,event.pitch,event.volume);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,15 +308,15 @@ public class ScriptPlayerEventHandler {
|
|||||||
public void invoke(LivingDeathEvent event) {
|
public void invoke(LivingDeathEvent event) {
|
||||||
if(event.entityLiving.worldObj instanceof WorldServer) {
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
PlayerDataScript handler;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
if(event.entityLiving instanceof EntityPlayer) {
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
EventHooks.onPlayerDeath(handler, event.source, source);
|
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(source instanceof EntityPlayer) {
|
if(source instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)source).scriptData;
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
|
||||||
EventHooks.onPlayerKills(handler, event.entityLiving);
|
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -301,17 +326,15 @@ public class ScriptPlayerEventHandler {
|
|||||||
public void invoke(LivingHurtEvent event) {
|
public void invoke(LivingHurtEvent event) {
|
||||||
if(event.entityLiving.worldObj instanceof WorldServer) {
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
PlayerDataScript handler;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
if(event.entityLiving instanceof EntityPlayer) {
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
|
||||||
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent(handler.getPlayer(), source, event.ammount, event.source);
|
|
||||||
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
|
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
|
||||||
event.ammount = pevent.damage;
|
event.ammount = pevent.damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(source instanceof EntityPlayer) {
|
if(source instanceof EntityPlayer) {
|
||||||
handler = PlayerData.get((EntityPlayer)source).scriptData;
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||||
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent(handler.getPlayer(), event.entityLiving, event.ammount, event.source);
|
|
||||||
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
|
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
|
||||||
event.ammount = pevent1.damage;
|
event.ammount = pevent1.damage;
|
||||||
}
|
}
|
||||||
@@ -322,24 +345,27 @@ public class ScriptPlayerEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
|
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerRespawn(handler);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerRespawn(handler, scriptPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
|
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerLogin(handler);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
|
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer) {
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
EventHooks.onPlayerLogout(handler);
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogout(handler, scriptPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,9 +374,10 @@ public class ScriptPlayerEventHandler {
|
|||||||
)
|
)
|
||||||
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
|
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
|
||||||
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
|
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
|
||||||
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
String message = event.message;
|
String message = event.message;
|
||||||
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(handler.getPlayer(), event.message);
|
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
|
||||||
EventHooks.onPlayerChat(handler, ev);
|
EventHooks.onPlayerChat(handler, ev);
|
||||||
event.setCanceled(ev.isCanceled());
|
event.setCanceled(ev.isCanceled());
|
||||||
if(!message.equals(ev.message)) {
|
if(!message.equals(ev.message)) {
|
||||||
@@ -360,118 +387,4 @@ public class ScriptPlayerEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptPlayerEventHandler registerForgeEvents() {
|
|
||||||
ScriptPlayerEventHandler.ForgeEventHandler handler = new ScriptPlayerEventHandler.ForgeEventHandler();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Method e = handler.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"));
|
|
||||||
Iterator e1 = list.iterator();
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
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 = (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(!EntityConstructing.class.isAssignableFrom(c1) && !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())) {
|
|
||||||
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, handler, e, Loader.instance().activeModContainer()});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception var13) {
|
|
||||||
var13.printStackTrace();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ForgeEventHandler {
|
|
||||||
public ForgeEventHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void forgeEntity(Event event) {
|
|
||||||
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
|
|
||||||
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.worldObj instanceof WorldServer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@SubscribeEvent
|
|
||||||
public void forgeTick(TickEvent.ServerTickEvent event){
|
|
||||||
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
|
||||||
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void forgeTick(TickEvent.WorldTickEvent event){
|
|
||||||
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
|
||||||
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void forgeTick(TickEvent.PlayerTickEvent event){
|
|
||||||
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
|
||||||
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
|||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import net.minecraft.village.MerchantRecipeList;
|
import net.minecraft.village.MerchantRecipeList;
|
||||||
|
import net.minecraftforge.event.CommandEvent;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
@@ -35,20 +36,14 @@ 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;
|
||||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||||
import noppes.npcs.quests.QuestKill;
|
import noppes.npcs.quests.QuestKill;
|
||||||
import noppes.npcs.roles.RoleFollower;
|
import noppes.npcs.roles.RoleFollower;
|
||||||
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
|
|
||||||
public class ServerEventsHandler {
|
public class ServerEventsHandler {
|
||||||
|
|
||||||
@@ -111,17 +106,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 +127,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 +175,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 +227,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,448 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, 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, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
|
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
|
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
|
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint11;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint12;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint13;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_)
|
||||||
|
{
|
||||||
|
this.pathOptions[i++] = pathpoint14;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,66 +2,114 @@ package noppes.npcs.ai.pathfinder;
|
|||||||
|
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.EntityMoveHelper;
|
import net.minecraft.entity.ai.EntityMoveHelper;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
// Fly Change
|
// Fly Change
|
||||||
|
|
||||||
public class FlyingMoveHelper extends EntityMoveHelper {
|
public class FlyingMoveHelper extends EntityMoveHelper{
|
||||||
private EntityNPCInterface entity;
|
private final EntityNPCInterface entity;
|
||||||
|
|
||||||
private int field_179928_h;
|
private double posX;
|
||||||
protected boolean update;
|
private double posY;
|
||||||
|
private double posZ;
|
||||||
public double posX;
|
private double speed;
|
||||||
public double posY;
|
private boolean update;
|
||||||
public double posZ;
|
|
||||||
|
|
||||||
public FlyingMoveHelper(EntityNPCInterface entity){
|
public FlyingMoveHelper(EntityNPCInterface entity){
|
||||||
super(entity);
|
super(entity);
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
this.posX = entity.posX;
|
||||||
|
this.posY = entity.posY;
|
||||||
|
this.posZ = entity.posZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdateMoveHelper(){
|
public void onUpdateMoveHelper() {
|
||||||
if (this.update){
|
if (this.update) {
|
||||||
|
this.update = false;
|
||||||
|
|
||||||
|
double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
||||||
|
double speedMult = 0.6000000238418579D / 0.5D;
|
||||||
|
|
||||||
double d0 = this.posX - this.entity.posX;
|
double d0 = this.posX - this.entity.posX;
|
||||||
double d1 = this.posY - this.entity.posY;
|
double d1 = this.posY - this.entity.posY;
|
||||||
double d2 = this.posZ - this.entity.posZ;
|
double d2 = this.posZ - this.entity.posZ;
|
||||||
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
|
||||||
if (this.field_179928_h-- <= 0){
|
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
||||||
this.field_179928_h += this.entity.getRNG().nextInt(5) + 2;
|
if (this.posY != this.entity.posY) {
|
||||||
d3 = (double) MathHelper.sqrt_double(d3);
|
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) {
|
||||||
|
this.entity.motionY = 0.0D;
|
||||||
|
}
|
||||||
|
|
||||||
if (d3 > 1 && this.func_179926_b(this.posX, this.posY, this.posZ, d3)){
|
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
||||||
double speed = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() / 2.5;
|
if(verticalSpeed > speed * speedMult)
|
||||||
this.entity.motionX += d0 / d3 * speed;
|
verticalSpeed = speed * speedMult;
|
||||||
this.entity.motionY += d1 / d3 * speed;
|
verticalSpeed += this.entity.ai.flySpeed/2.0D;
|
||||||
this.entity.motionZ += d2 / d3 * speed;
|
|
||||||
this.entity.renderYawOffset = this.entity.rotationYaw = -((float)Math.atan2(this.entity.motionX, this.entity.motionZ)) * 180.0F / (float)Math.PI;
|
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
|
||||||
}
|
verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
||||||
else{
|
|
||||||
this.update = false;
|
int blockY = (int) this.posY;
|
||||||
|
double heightOffGround = 0;
|
||||||
|
if(this.entity.ai.hasFlyLimit) {
|
||||||
|
for (blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||||
|
heightOffGround = this.posY - blockY;
|
||||||
|
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit)
|
||||||
|
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double d5 = MathHelper.sqrt_double(d4);
|
||||||
|
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult;
|
||||||
|
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean func_179926_b(double p_179926_1_, double p_179926_3_, double p_179926_5_, double p_179926_7_){
|
private float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
|
||||||
double d4 = (p_179926_1_ - this.entity.posX) / p_179926_7_;
|
{
|
||||||
double d5 = (p_179926_3_ - this.entity.posY) / p_179926_7_;
|
float f3 = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);
|
||||||
double d6 = (p_179926_5_ - this.entity.posZ) / p_179926_7_;
|
|
||||||
AxisAlignedBB axisalignedbb = this.entity.getBoundingBox();
|
|
||||||
|
|
||||||
for (int i = 1; (double)i < p_179926_7_; ++i){
|
if (f3 > p_75639_3_)
|
||||||
axisalignedbb = axisalignedbb.offset(d4, d5, d6);
|
{
|
||||||
|
f3 = p_75639_3_;
|
||||||
if (!this.entity.worldObj.getCollidingBoundingBoxes(this.entity, axisalignedbb).isEmpty()){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,491 @@
|
|||||||
package noppes.npcs.ai.pathfinder;
|
package noppes.npcs.ai.pathfinder;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.pathfinding.PathFinder;
|
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 net.minecraft.world.World;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class PathNavigateFlying extends PathNavigateSwimmer {
|
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) {
|
public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) {
|
||||||
super(p_i45873_1_, worldIn);
|
super(p_i45873_1_, worldIn);
|
||||||
}
|
this.theEntity = (EntityNPCInterface)p_i45873_1_;
|
||||||
|
this.worldObj = worldIn;
|
||||||
|
this.pathSearchRange = p_i45873_1_.getEntityAttribute(SharedMonsterAttributes.followRange);
|
||||||
|
}
|
||||||
|
|
||||||
protected PathFinder func_179679_a()
|
public void setAvoidsWater(boolean p_75491_1_)
|
||||||
{
|
{
|
||||||
return new NPCPathFinder(new FlyNodeProcessor());
|
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, (double)this.getPathableYPos(), this.theEntity.posZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
||||||
|
*/
|
||||||
|
private int getPathableYPos()
|
||||||
|
{
|
||||||
|
return (int)(this.theEntity.boundingBox.minY + 0.5D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If on ground or swimming and can swim
|
* If on ground or swimming and can swim
|
||||||
*/
|
*/
|
||||||
protected boolean canNavigate()
|
private boolean canNavigate()
|
||||||
{
|
{
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ 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.*;
|
import noppes.npcs.client.gui.*;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
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;
|
||||||
@@ -128,22 +129,7 @@ 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.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.controllers.PlayerData;
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.entity.*;
|
import noppes.npcs.entity.*;
|
||||||
|
|
||||||
@@ -437,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ 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 noppes.npcs.EventScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
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;
|
||||||
@@ -13,10 +13,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
|
|||||||
public class EventGuiScriptList extends SubGuiInterface{
|
public class EventGuiScriptList extends SubGuiInterface{
|
||||||
private GuiCustomScroll scroll1;
|
private GuiCustomScroll scroll1;
|
||||||
private GuiCustomScroll scroll2;
|
private GuiCustomScroll scroll2;
|
||||||
private EventScriptContainer container;
|
private ScriptContainer container;
|
||||||
private List<String> scripts;
|
private List<String> scripts;
|
||||||
|
|
||||||
public EventGuiScriptList(List<String> scripts, EventScriptContainer container){
|
public EventGuiScriptList(List<String> scripts, ScriptContainer container){
|
||||||
this.container = container;
|
this.container = container;
|
||||||
setBackground("menubg.png");
|
setBackground("menubg.png");
|
||||||
xSize = 346;
|
xSize = 346;
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -43,10 +40,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 +56,18 @@ 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");
|
list.add("script.timer");
|
||||||
|
|
||||||
if(showScript){
|
if(showScript){
|
||||||
@@ -79,9 +76,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);
|
||||||
|
|
||||||
@@ -139,27 +136,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) {
|
||||||
@@ -174,7 +168,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());
|
||||||
@@ -186,13 +180,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,7 +206,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) {
|
||||||
@@ -228,7 +222,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");
|
||||||
@@ -257,7 +251,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
|
||||||
@@ -278,3 +272,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;
|
||||||
|
|||||||
@@ -27,30 +27,30 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
|
|||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15));
|
addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15));
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 50, 18, stats.getAttackStrength()+""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 50, 18, String.format("%.0f", stats.getAttackStrength()) + ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).floatsOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(0, 99999, 5);
|
getTextField(1).setMinMaxDefaultFloat(0,Float.MAX_VALUE,5);
|
||||||
addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45));
|
addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45));
|
||||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 50, 18, stats.attackRange+""));
|
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 50, 18, stats.attackRange+""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(1, 30, 2);
|
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
|
||||||
addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75));
|
addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75));
|
||||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 50, 18, stats.attackSpeed+""));
|
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 50, 18, stats.attackSpeed+""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(1, 1000, 20);
|
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||||
|
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105));
|
addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105));
|
||||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 50, 18, stats.knockback + ""));
|
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 50, 18, stats.knockback + ""));
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
getTextField(4).setMinMaxDefault(0, 4, 0);
|
getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135));
|
addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135));
|
||||||
addButton(new GuiNpcButton(5,guiLeft + 85, guiTop + 130, 52, 20, potionNames, stats.potionType.ordinal()));
|
addButton(new GuiNpcButton(5,guiLeft + 85, guiTop + 130, 52, 20, potionNames, stats.potionType.ordinal()));
|
||||||
if(stats.potionType != EnumPotionType.None) {
|
if(stats.potionType != EnumPotionType.None) {
|
||||||
addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165));
|
addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165));
|
||||||
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 50, 18, stats.potionDuration + ""));
|
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 50, 18, stats.potionDuration + ""));
|
||||||
getTextField(6).numbersOnly = true;
|
getTextField(6).integersOnly = true;
|
||||||
getTextField(6).setMinMaxDefault(1, 99999, 5);
|
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
|
||||||
if(stats.potionType != EnumPotionType.Fire) {
|
if(stats.potionType != EnumPotionType.Fire) {
|
||||||
addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195));
|
addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195));
|
||||||
addButton(new GuiNpcButton(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"gui.no", "gui.yes"} ,stats.potionAmp));
|
addButton(new GuiNpcButton(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"gui.no", "gui.yes"} ,stats.potionAmp));
|
||||||
@@ -61,7 +61,7 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
|
|||||||
|
|
||||||
public void unFocused(GuiNpcTextField textfield) {
|
public void unFocused(GuiNpcTextField textfield) {
|
||||||
if(textfield.id == 1){
|
if(textfield.id == 1){
|
||||||
stats.setAttackStrength(textfield.getInteger());
|
stats.setAttackStrength(Float.parseFloat(textfield.getText()));
|
||||||
}
|
}
|
||||||
else if(textfield.id == 2){
|
else if(textfield.id == 2){
|
||||||
stats.attackRange = textfield.getInteger();
|
stats.attackRange = textfield.getInteger();
|
||||||
|
|||||||
@@ -30,12 +30,34 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal()));
|
this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal()));
|
||||||
|
|
||||||
// Fly Change
|
// Fly Change
|
||||||
// this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
|
this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
|
||||||
|
|
||||||
|
if(ai.movementType == 1){
|
||||||
|
this.addLabel(new GuiNpcLabel(18, "fly.speed", guiLeft + 4, y + 140));
|
||||||
|
addTextField(new GuiNpcTextField(18,this, guiLeft + 80, y + 135, 40, 20, ai.flySpeed + ""));
|
||||||
|
getTextField(18).doublesOnly = true;
|
||||||
|
getTextField(18).setMinMaxDefaultDouble(0.0D,Double.MAX_VALUE,1.0D);
|
||||||
|
|
||||||
|
this.addLabel(new GuiNpcLabel(19, "fly.gravity", guiLeft + 4, y + 160));
|
||||||
|
addTextField(new GuiNpcTextField(19,this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + ""));
|
||||||
|
getTextField(19).doublesOnly = true;
|
||||||
|
getTextField(19).setMinMaxDefaultDouble(0.0D,1.0D,0.0D);
|
||||||
|
|
||||||
|
this.addLabel(new GuiNpcLabel(20, "Limit Height", guiLeft + 150, y + 116));
|
||||||
|
addButton(new GuiNpcButton(20, guiLeft + 210, y + 110, 40, 20, new String[]{"gui.no","gui.yes"}, ai.hasFlyLimit?1:0));
|
||||||
|
|
||||||
|
if(ai.hasFlyLimit) {
|
||||||
|
this.addLabel(new GuiNpcLabel(21, "Height", guiLeft + 150, y + 140));
|
||||||
|
addTextField(new GuiNpcTextField(21, this, guiLeft + 185, y + 135, 40, 20, ai.flyHeightLimit + ""));
|
||||||
|
getTextField(21).integersOnly = true;
|
||||||
|
getTextField(21).setMinMaxDefaultDouble(0.0D, Double.MAX_VALUE, 1.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ai.movingType == EnumMovingType.Wandering){
|
if(ai.movingType == EnumMovingType.Wandering){
|
||||||
addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + ""));
|
addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + ""));
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
getTextField(4).setMinMaxDefault(0, 1000, 5);
|
getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5);
|
||||||
addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0));
|
addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0));
|
||||||
@@ -45,15 +67,15 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + ""));
|
addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + ""));
|
||||||
addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5));
|
||||||
addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5));
|
addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5));
|
||||||
getTextField(7).numbersOnly = true;
|
getTextField(7).integersOnly = true;
|
||||||
getTextField(7).setMinMaxDefault(0, 10, 5);
|
getTextField(7).setMinMaxDefault(0, 10, 5);
|
||||||
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
|
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
|
||||||
addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + ""));
|
addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + ""));
|
||||||
getTextField(8).numbersOnly = true;
|
getTextField(8).integersOnly = true;
|
||||||
getTextField(8).setMinMaxDefault(0, 10, 5);
|
getTextField(8).setMinMaxDefault(0, 10, 5);
|
||||||
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
|
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
|
||||||
addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + ""));
|
addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + ""));
|
||||||
getTextField(9).numbersOnly = true;
|
getTextField(9).integersOnly = true;
|
||||||
getTextField(9).setMinMaxDefault(0, 10, 5);
|
getTextField(9).setMinMaxDefault(0, 10, 5);
|
||||||
|
|
||||||
this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal()));
|
this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal()));
|
||||||
@@ -65,14 +87,14 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + ""));
|
addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + ""));
|
||||||
getTextField(5).numbersOnly = true;
|
getTextField(5).integersOnly = true;
|
||||||
getTextField(5).setMinMaxDefault(0, 359, 0);
|
getTextField(5).setMinMaxDefault(0, 359, 0);
|
||||||
this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5));
|
this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5));
|
||||||
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5));
|
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5));
|
||||||
}
|
}
|
||||||
if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){
|
if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){
|
||||||
addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + ""));
|
addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + ""));
|
||||||
getTextField(5).numbersOnly = true;
|
getTextField(5).integersOnly = true;
|
||||||
getTextField(5).setMinMaxDefault(0, 359, 0);
|
getTextField(5).setMinMaxDefault(0, 359, 0);
|
||||||
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5));
|
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5));
|
||||||
}
|
}
|
||||||
@@ -92,8 +114,8 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+""));
|
addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+""));
|
||||||
getTextField(14).numbersOnly = true;
|
getTextField(14).integersOnly = true;
|
||||||
getTextField(14).setMinMaxDefault(0, 10, 4);
|
getTextField(14).setMinMaxDefault(0, Integer.MAX_VALUE, 4);
|
||||||
addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
||||||
@@ -146,10 +168,13 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
}
|
}
|
||||||
else if (button.id == 15) {
|
else if (button.id == 15) {
|
||||||
ai.movementType = button.getValue();
|
ai.movementType = button.getValue();
|
||||||
|
initGui();
|
||||||
|
} else if (button.id == 20) {
|
||||||
|
ai.hasFlyLimit = button.getValue() == 1;
|
||||||
|
initGui();
|
||||||
|
} else if (button.id == 66) {
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
else if(button.id == 66){
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,6 +197,15 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
|
|||||||
else if(textfield.id == 14){
|
else if(textfield.id == 14){
|
||||||
ai.setWalkingSpeed(textfield.getInteger());
|
ai.setWalkingSpeed(textfield.getInteger());
|
||||||
}
|
}
|
||||||
|
else if(textfield.id == 18){
|
||||||
|
ai.flySpeed = textfield.getDouble();
|
||||||
|
}
|
||||||
|
else if(textfield.id == 19){
|
||||||
|
ai.flyGravity = textfield.getDouble();
|
||||||
|
}
|
||||||
|
else if(textfield.id == 21){
|
||||||
|
ai.flyHeightLimit = textfield.getInteger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
|
|||||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||||
import noppes.npcs.client.gui.util.ITextfieldListener;
|
import noppes.npcs.client.gui.util.ITextfieldListener;
|
||||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
import noppes.npcs.constants.EnumAnimation;
|
|
||||||
import noppes.npcs.constants.EnumPotionType;
|
import noppes.npcs.constants.EnumPotionType;
|
||||||
import noppes.npcs.constants.EnumParticleType;
|
import noppes.npcs.constants.EnumParticleType;
|
||||||
|
|
||||||
@@ -29,21 +28,21 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
|||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15));
|
addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15));
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, stats.pDamage+""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, String.format("%.0f", stats.pDamage) +""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).setFloatsOnly();
|
||||||
getTextField(1).setMinMaxDefault(0, 9999, 5);
|
getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5);
|
||||||
addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15));
|
addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15));
|
||||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+""));
|
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(0, 3, 0);
|
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45));
|
addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45));
|
||||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+""));
|
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(1, 10, 10);
|
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
|
||||||
addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75));
|
addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75));
|
||||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+""));
|
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+""));
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
getTextField(4).setMinMaxDefault(1, 50, 10);
|
getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105));
|
addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105));
|
||||||
addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0));
|
addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0));
|
||||||
@@ -59,8 +58,8 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
|||||||
addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal()));
|
addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal()));
|
||||||
if(stats.pEffect != EnumPotionType.None) {
|
if(stats.pEffect != EnumPotionType.None) {
|
||||||
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + ""));
|
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + ""));
|
||||||
getTextField(5).numbersOnly = true;
|
getTextField(5).integersOnly = true;
|
||||||
getTextField(5).setMinMaxDefault(1, 99999, 5);
|
getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
|
||||||
if(stats.pEffect != EnumPotionType.Fire) {
|
if(stats.pEffect != EnumPotionType.Fire) {
|
||||||
addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp));
|
addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp));
|
||||||
}
|
}
|
||||||
@@ -82,7 +81,7 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
|||||||
|
|
||||||
public void unFocused(GuiNpcTextField textfield) {
|
public void unFocused(GuiNpcTextField textfield) {
|
||||||
if(textfield.id == 1){
|
if(textfield.id == 1){
|
||||||
stats.pDamage = textfield.getInteger();
|
stats.pDamage = (float)(Math.floor(Float.parseFloat(textfield.getText())));
|
||||||
}
|
}
|
||||||
else if(textfield.id == 2){
|
else if(textfield.id == 2){
|
||||||
stats.pImpact = textfield.getInteger();
|
stats.pImpact = textfield.getInteger();
|
||||||
|
|||||||
@@ -29,36 +29,36 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
|||||||
int y = guiTop + 4;
|
int y = guiTop + 4;
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+""));
|
||||||
addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(0, 100, 90);
|
getTextField(1).setMinMaxDefault(0, 100, 90);
|
||||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+""));
|
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+""));
|
||||||
addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(1, 64, 2);
|
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
|
||||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+""));
|
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+""));
|
||||||
addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(1, 9999, 20);
|
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+""));
|
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+""));
|
||||||
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5));
|
||||||
getTextField(4).numbersOnly = true;
|
getTextField(4).integersOnly = true;
|
||||||
getTextField(4).setMinMaxDefault(1, 9999, 20);
|
getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + ""));
|
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + ""));
|
||||||
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5));
|
||||||
getTextField(5).numbersOnly = true;
|
getTextField(5).integersOnly = true;
|
||||||
getTextField(5).setMinMaxDefault(0, 30, 0);
|
getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + ""));
|
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + ""));
|
||||||
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
|
||||||
getTextField(6).numbersOnly = true;
|
getTextField(6).integersOnly = true;
|
||||||
getTextField(6).setMinMaxDefault(1, 100, 20);
|
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||||
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound));
|
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound));
|
||||||
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
|
||||||
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "mco.template.button.select"));
|
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "mco.template.button.select"));
|
||||||
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + ""));
|
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + ""));
|
||||||
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5));
|
||||||
getTextField(8).numbersOnly = true;
|
getTextField(8).integersOnly = true;
|
||||||
getTextField(8).setMinMaxDefault(1, 10, 1);
|
getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||||
|
|
||||||
addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
|
addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
|
||||||
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListe
|
|||||||
if(stats.respawnTime > 0){
|
if(stats.respawnTime > 0){
|
||||||
addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57));
|
addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57));
|
||||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + ""));
|
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79));
|
addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79));
|
||||||
|
|||||||
@@ -0,0 +1,897 @@
|
|||||||
|
package noppes.npcs.client.gui.custom;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.client.gui.custom.components.*;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
|
||||||
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
|
import noppes.npcs.client.gui.util.ICustomScrollListener;
|
||||||
|
import noppes.npcs.client.gui.util.IGuiData;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.containers.ContainerCustomGui;
|
||||||
|
import noppes.npcs.scripted.gui.*;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiData {
|
||||||
|
ScriptGui gui;
|
||||||
|
int xSize;
|
||||||
|
int ySize;
|
||||||
|
public static int guiLeft;
|
||||||
|
public static int guiTop;
|
||||||
|
ResourceLocation background;
|
||||||
|
public String[] hoverText;
|
||||||
|
Map<Integer, IGuiComponent> components = new HashMap();
|
||||||
|
List<IClickListener> clickListeners = new ArrayList();
|
||||||
|
List<CustomGuiTextField> keyListeners = new ArrayList();
|
||||||
|
List<IDataHolder> dataHolders = new ArrayList();
|
||||||
|
|
||||||
|
public Container inventorySlots;
|
||||||
|
private Slot theSlot;
|
||||||
|
private Slot clickedSlot;
|
||||||
|
private boolean isRightMouseClick;
|
||||||
|
private ItemStack draggedStack;
|
||||||
|
private int field_147011_y;
|
||||||
|
private int field_147010_z;
|
||||||
|
private Slot returningStackDestSlot;
|
||||||
|
private long returningStackTime;
|
||||||
|
private ItemStack returningStack;
|
||||||
|
private Slot field_146985_D;
|
||||||
|
private long field_146986_E;
|
||||||
|
protected final Set field_147008_s = new HashSet();
|
||||||
|
protected boolean field_147007_t;
|
||||||
|
private int field_146987_F;
|
||||||
|
private int field_146988_G;
|
||||||
|
private boolean field_146995_H;
|
||||||
|
private int field_146996_I;
|
||||||
|
private long field_146997_J;
|
||||||
|
private Slot field_146998_K;
|
||||||
|
private int field_146992_L;
|
||||||
|
private boolean field_146993_M;
|
||||||
|
private ItemStack field_146994_N;
|
||||||
|
|
||||||
|
public GuiCustom(ContainerCustomGui container) {
|
||||||
|
this.inventorySlots = container;
|
||||||
|
this.field_146995_H = true;
|
||||||
|
this.allowUserInput = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
this.mc.thePlayer.openContainer = this.inventorySlots;
|
||||||
|
if (this.gui != null) {
|
||||||
|
guiLeft = (this.width - this.xSize)/2;
|
||||||
|
guiTop = (this.height - this.ySize)/2;
|
||||||
|
this.components.clear();
|
||||||
|
this.clickListeners.clear();
|
||||||
|
this.keyListeners.clear();
|
||||||
|
this.dataHolders.clear();
|
||||||
|
Iterator var1 = this.gui.getComponents().iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
ICustomGuiComponent c = (ICustomGuiComponent)var1.next();
|
||||||
|
this.addComponent(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateScreen() {
|
||||||
|
super.updateScreen();
|
||||||
|
|
||||||
|
Iterator var1 = this.dataHolders.iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
IDataHolder component = (IDataHolder)var1.next();
|
||||||
|
if (component instanceof GuiTextField) {
|
||||||
|
((GuiTextField)component).updateCursorCounter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
|
||||||
|
{
|
||||||
|
this.mc.thePlayer.closeScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.hoverText = null;
|
||||||
|
//this.drawDefaultBackground();
|
||||||
|
if (this.background != null) {
|
||||||
|
this.drawBackgroundTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var4 = this.components.values().iterator();
|
||||||
|
|
||||||
|
while(var4.hasNext()) {
|
||||||
|
IGuiComponent component = (IGuiComponent)var4.next();
|
||||||
|
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hoverText != null) {
|
||||||
|
this.func_146283_a(Arrays.asList(this.hoverText), mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawScreenSuper(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreenSuper(int mouseX, int mouseY, float partialTicks)
|
||||||
|
{
|
||||||
|
//this.drawDefaultBackground();
|
||||||
|
int k = this.guiLeft;
|
||||||
|
int l = this.guiTop;
|
||||||
|
//this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);
|
||||||
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||||
|
RenderHelper.disableStandardItemLighting();
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float)k, (float)l, 0.0F);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
|
this.theSlot = null;
|
||||||
|
short short1 = 240;
|
||||||
|
short short2 = 240;
|
||||||
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
int k1;
|
||||||
|
|
||||||
|
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1)
|
||||||
|
{
|
||||||
|
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
|
||||||
|
this.drawSlot(slot);
|
||||||
|
|
||||||
|
if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b())
|
||||||
|
{
|
||||||
|
this.theSlot = slot;
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
|
int j1 = slot.xDisplayPosition;
|
||||||
|
k1 = slot.yDisplayPosition;
|
||||||
|
GL11.glColorMask(true, true, true, false);
|
||||||
|
this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
|
||||||
|
GL11.glColorMask(true, true, true, true);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Forge: Force lighting to be disabled as there are some issue where lighting would
|
||||||
|
//incorrectly be applied based on items that are in the inventory.
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
//this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
|
||||||
|
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||||
|
|
||||||
|
if (itemstack != null)
|
||||||
|
{
|
||||||
|
byte b0 = 8;
|
||||||
|
k1 = this.draggedStack == null ? 8 : 16;
|
||||||
|
String s = null;
|
||||||
|
|
||||||
|
if (this.draggedStack != null && this.isRightMouseClick)
|
||||||
|
{
|
||||||
|
itemstack = itemstack.copy();
|
||||||
|
itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F);
|
||||||
|
}
|
||||||
|
else if (this.field_147007_t && this.field_147008_s.size() > 1)
|
||||||
|
{
|
||||||
|
itemstack = itemstack.copy();
|
||||||
|
itemstack.stackSize = this.field_146996_I;
|
||||||
|
|
||||||
|
if (itemstack.stackSize == 0)
|
||||||
|
{
|
||||||
|
s = "" + EnumChatFormatting.YELLOW + "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.drawItemStack(itemstack, mouseX - k - b0, mouseY - l - k1, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.returningStack != null)
|
||||||
|
{
|
||||||
|
float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
|
||||||
|
|
||||||
|
if (f1 >= 1.0F)
|
||||||
|
{
|
||||||
|
f1 = 1.0F;
|
||||||
|
this.returningStack = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y;
|
||||||
|
int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z;
|
||||||
|
int l1 = this.field_147011_y + (int)((float)k1 * f1);
|
||||||
|
int i2 = this.field_147010_z + (int)((float)j2 * f1);
|
||||||
|
this.drawItemStack(this.returningStack, l1, i2, (String)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||||
|
{
|
||||||
|
ItemStack itemstack1 = this.theSlot.getStack();
|
||||||
|
this.renderToolTip(itemstack1, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
|
RenderHelper.enableStandardItemLighting();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_)
|
||||||
|
{
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||||
|
this.zLevel = 200.0F;
|
||||||
|
itemRender.zLevel = 200.0F;
|
||||||
|
FontRenderer font = null;
|
||||||
|
if (p_146982_1_ != null) font = p_146982_1_.getItem().getFontRenderer(p_146982_1_);
|
||||||
|
if (font == null) font = fontRendererObj;
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_);
|
||||||
|
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_ - (this.draggedStack == null ? 0 : 8), p_146982_4_);
|
||||||
|
this.zLevel = 0.0F;
|
||||||
|
itemRender.zLevel = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMouseOverSlot(Slot slot, int posX, int posY)
|
||||||
|
{
|
||||||
|
return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, posX, posY);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY)
|
||||||
|
{
|
||||||
|
int k1 = this.guiLeft;
|
||||||
|
int l1 = this.guiTop;
|
||||||
|
posX -= k1;
|
||||||
|
posY -= l1;
|
||||||
|
return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawSlot(Slot p_146977_1_)
|
||||||
|
{
|
||||||
|
int i = p_146977_1_.xDisplayPosition;
|
||||||
|
int j = p_146977_1_.yDisplayPosition;
|
||||||
|
ItemStack itemstack = p_146977_1_.getStack();
|
||||||
|
boolean flag = false;
|
||||||
|
boolean flag1 = p_146977_1_ == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
|
||||||
|
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
|
||||||
|
String s = null;
|
||||||
|
|
||||||
|
if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
|
||||||
|
{
|
||||||
|
itemstack = itemstack.copy();
|
||||||
|
itemstack.stackSize /= 2;
|
||||||
|
}
|
||||||
|
else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null)
|
||||||
|
{
|
||||||
|
if (this.field_147008_s.size() == 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_))
|
||||||
|
{
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
flag = true;
|
||||||
|
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize);
|
||||||
|
|
||||||
|
if (itemstack.stackSize > itemstack.getMaxStackSize())
|
||||||
|
{
|
||||||
|
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
|
||||||
|
itemstack.stackSize = itemstack.getMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack.stackSize > p_146977_1_.getSlotStackLimit())
|
||||||
|
{
|
||||||
|
s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit();
|
||||||
|
itemstack.stackSize = p_146977_1_.getSlotStackLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.field_147008_s.remove(p_146977_1_);
|
||||||
|
this.func_146980_g();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.zLevel = 100.0F;
|
||||||
|
itemRender.zLevel = 100.0F;
|
||||||
|
|
||||||
|
if (itemstack == null)
|
||||||
|
{
|
||||||
|
IIcon iicon = p_146977_1_.getBackgroundIconIndex();
|
||||||
|
|
||||||
|
if (iicon != null)
|
||||||
|
{
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
|
||||||
|
this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
|
||||||
|
this.drawTexturedModelRectFromIcon(i, j, iicon, 16, 16);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND); // Forge: And clean that up
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag1)
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
drawRect(i, j, i + 16, j + 16, -2130706433);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j);
|
||||||
|
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemRender.zLevel = 0.0F;
|
||||||
|
this.zLevel = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void func_146980_g()
|
||||||
|
{
|
||||||
|
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||||
|
|
||||||
|
if (itemstack != null && this.field_147007_t)
|
||||||
|
{
|
||||||
|
this.field_146996_I = itemstack.stackSize;
|
||||||
|
ItemStack itemstack1;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i)
|
||||||
|
{
|
||||||
|
Slot slot = (Slot)iterator.next();
|
||||||
|
itemstack1 = itemstack.copy();
|
||||||
|
i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
|
||||||
|
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i);
|
||||||
|
|
||||||
|
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
|
||||||
|
{
|
||||||
|
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.stackSize > slot.getSlotStackLimit())
|
||||||
|
{
|
||||||
|
itemstack1.stackSize = slot.getSlotStackLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawBackgroundTexture() {
|
||||||
|
this.mc.getTextureManager().bindTexture(this.background);
|
||||||
|
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addComponent(ICustomGuiComponent component) {
|
||||||
|
ScriptGuiComponent c = (ScriptGuiComponent)component;
|
||||||
|
switch(c.getType()) {
|
||||||
|
case 0:
|
||||||
|
CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton)component);
|
||||||
|
button.setParent(this);
|
||||||
|
this.components.put(button.getID(), button);
|
||||||
|
this.addClickListener(button);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel)component);
|
||||||
|
lbl.setParent(this);
|
||||||
|
this.components.put(lbl.getID(), lbl);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect)component);
|
||||||
|
rect.setParent(this);
|
||||||
|
this.components.put(rect.getID(), rect);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField)component);
|
||||||
|
textField.setParent(this);
|
||||||
|
this.components.put(textField.getID(), textField);
|
||||||
|
this.addDataHolder(textField);
|
||||||
|
this.addClickListener(textField);
|
||||||
|
this.addKeyListener(textField);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll)component).isMultiSelect());
|
||||||
|
scroll.fromComponent((ScriptGuiScroll)component);
|
||||||
|
scroll.setParent(this);
|
||||||
|
this.components.put(scroll.getID(), scroll);
|
||||||
|
this.addDataHolder(scroll);
|
||||||
|
this.addClickListener(scroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton button) {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buttonClick(CustomGuiButton button) {
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void slotChange(CustomGuiSlot slot) {
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiSlotChange, new Object[]{this.updateGui().toNBT(), slot.slotNumber});
|
||||||
|
}
|
||||||
|
|
||||||
|
public String prevScrollClicked = null;
|
||||||
|
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false});
|
||||||
|
if(Integer.toString(scroll.selected).equals(prevScrollClicked)){
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true});
|
||||||
|
}
|
||||||
|
prevScrollClicked = Integer.toString(scroll.selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuiClosed() {
|
||||||
|
if (this.gui != null) {
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiClose, new Object[]{this.updateGui().toNBT()});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mc.thePlayer != null)
|
||||||
|
{
|
||||||
|
this.inventorySlots.onContainerClosed(this.mc.thePlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTextFieldUnfocused(CustomGuiTextField textField){
|
||||||
|
Client.sendData(EnumPacketServer.CustomGuiUnfocused, new Object[]{this.updateGui().toNBT(), textField.getID()});
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptGui updateGui() {
|
||||||
|
Iterator var1 = this.dataHolders.iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
IDataHolder component = (IDataHolder)var1.next();
|
||||||
|
this.gui.updateComponent(component.toComponent());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound getScrollSelection(CustomGuiScrollComponent scroll) {
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
if (scroll.multiSelect) {
|
||||||
|
Iterator var3 = scroll.getSelectedList().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
String s = (String)var3.next();
|
||||||
|
list.appendTag(new NBTTagString(s));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.appendTag(new NBTTagString(scroll.getSelected()));
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound selection = new NBTTagCompound();
|
||||||
|
selection.setTag("selection", list);
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void keyTyped(char typedChar, int keyCode) {
|
||||||
|
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
|
||||||
|
{
|
||||||
|
this.mc.thePlayer.closeScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.checkHotbarKeys(keyCode);
|
||||||
|
|
||||||
|
if (this.theSlot != null && this.theSlot.getHasStack())
|
||||||
|
{
|
||||||
|
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3);
|
||||||
|
}
|
||||||
|
else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var3 = this.keyListeners.iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
CustomGuiTextField listener = (CustomGuiTextField) var3.next();
|
||||||
|
listener.keyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mc.gameSettings.keyBindInventory.getKeyCode() != keyCode && !this.mc.gameSettings.keyBindInventory.getIsKeyPressed()) {
|
||||||
|
super.keyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100;
|
||||||
|
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||||
|
long l = Minecraft.getSystemTime();
|
||||||
|
this.field_146993_M = this.field_146998_K == slot && l - this.field_146997_J < 250L && this.field_146992_L == mouseButton;
|
||||||
|
this.field_146995_H = false;
|
||||||
|
|
||||||
|
if (mouseButton == 0 || mouseButton == 1 || flag) {
|
||||||
|
boolean flag1 = true;
|
||||||
|
int k1 = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
|
||||||
|
{
|
||||||
|
Slot invSlot = (Slot)this.inventorySlots.inventorySlots.get(i);
|
||||||
|
|
||||||
|
if (invSlot.equals(slot))
|
||||||
|
{
|
||||||
|
flag1 = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot != null) {
|
||||||
|
k1 = slot.slotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag1) {
|
||||||
|
k1 = -999;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||||
|
this.mc.displayGuiScreen((GuiScreen) null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 != -1) {
|
||||||
|
if (this.mc.gameSettings.touchscreen) {
|
||||||
|
if (slot != null && slot.getHasStack()) {
|
||||||
|
this.clickedSlot = slot;
|
||||||
|
this.draggedStack = null;
|
||||||
|
this.isRightMouseClick = mouseButton == 1;
|
||||||
|
} else {
|
||||||
|
this.clickedSlot = null;
|
||||||
|
}
|
||||||
|
} else if (!this.field_147007_t) {
|
||||||
|
if (this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||||
|
if (mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) {
|
||||||
|
this.handleMouseClick(slot, k1, mouseButton, 3);
|
||||||
|
} else {
|
||||||
|
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||||
|
byte b0 = 0;
|
||||||
|
|
||||||
|
if (flag2) {
|
||||||
|
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||||
|
b0 = 1;
|
||||||
|
} else if (k1 == -999) {
|
||||||
|
b0 = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handleMouseClick(slot, k1, mouseButton, b0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field_146995_H = true;
|
||||||
|
} else {
|
||||||
|
this.field_147007_t = true;
|
||||||
|
this.field_146988_G = mouseButton;
|
||||||
|
this.field_147008_s.clear();
|
||||||
|
|
||||||
|
if (mouseButton == 0) {
|
||||||
|
this.field_146987_F = 0;
|
||||||
|
} else if (mouseButton == 1) {
|
||||||
|
this.field_146987_F = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field_146998_K = slot;
|
||||||
|
this.field_146997_J = l;
|
||||||
|
this.field_146992_L = mouseButton;
|
||||||
|
|
||||||
|
Iterator var4 = this.clickListeners.iterator();
|
||||||
|
|
||||||
|
while(var4.hasNext()) {
|
||||||
|
IClickListener listener = (IClickListener)var4.next();
|
||||||
|
listener.mouseClicked(this, mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doesGuiPauseGame() {
|
||||||
|
return this.gui == null || this.gui.getDoesPauseGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDataHolder(IDataHolder component) {
|
||||||
|
this.dataHolders.add(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addKeyListener(CustomGuiTextField component) {
|
||||||
|
this.keyListeners.add(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClickListener(IClickListener component) {
|
||||||
|
this.clickListeners.add(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
ScriptGui gui = (ScriptGui)(new ScriptGui()).fromNBT(compound);
|
||||||
|
((ContainerCustomGui)this.inventorySlots).setGui(gui, mc.thePlayer);
|
||||||
|
this.gui = gui;
|
||||||
|
this.xSize = gui.getWidth();
|
||||||
|
this.ySize = gui.getHeight();
|
||||||
|
if (!gui.getBackgroundTexture().isEmpty()) {
|
||||||
|
this.background = new ResourceLocation(gui.getBackgroundTexture());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is what controls the hotbar shortcut check when you press a number key when hovering a stack.
|
||||||
|
*/
|
||||||
|
protected boolean checkHotbarKeys(int p_146983_1_)
|
||||||
|
{
|
||||||
|
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 9; ++j)
|
||||||
|
{
|
||||||
|
if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode())
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_)
|
||||||
|
{
|
||||||
|
if (slot != null)
|
||||||
|
{
|
||||||
|
index = slot.slotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mc.playerController.windowClick(this.inventorySlots.windowId, index, p_146984_3_, p_146984_4_, this.mc.thePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_)
|
||||||
|
{
|
||||||
|
super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons
|
||||||
|
Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_);
|
||||||
|
int l = this.guiLeft;
|
||||||
|
int i1 = this.guiTop;
|
||||||
|
boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize;
|
||||||
|
int j1 = -1;
|
||||||
|
|
||||||
|
if (slot != null)
|
||||||
|
{
|
||||||
|
j1 = slot.slotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
j1 = -999;
|
||||||
|
}
|
||||||
|
|
||||||
|
Slot slot1;
|
||||||
|
Iterator iterator;
|
||||||
|
|
||||||
|
if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot))
|
||||||
|
{
|
||||||
|
if (isShiftKeyDown())
|
||||||
|
{
|
||||||
|
if (slot != null && slot.inventory != null && this.field_146994_N != null)
|
||||||
|
{
|
||||||
|
iterator = this.inventorySlots.inventorySlots.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
slot1 = (Slot)iterator.next();
|
||||||
|
|
||||||
|
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true))
|
||||||
|
{
|
||||||
|
this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.handleMouseClick(slot, j1, p_146286_3_, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field_146993_M = false;
|
||||||
|
this.field_146997_J = 0L;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.field_147007_t && this.field_146988_G != p_146286_3_)
|
||||||
|
{
|
||||||
|
this.field_147007_t = false;
|
||||||
|
this.field_147008_s.clear();
|
||||||
|
this.field_146995_H = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field_146995_H)
|
||||||
|
{
|
||||||
|
this.field_146995_H = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean flag1;
|
||||||
|
|
||||||
|
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||||
|
{
|
||||||
|
if (p_146286_3_ == 0 || p_146286_3_ == 1)
|
||||||
|
{
|
||||||
|
if (this.draggedStack == null && slot != this.clickedSlot)
|
||||||
|
{
|
||||||
|
this.draggedStack = this.clickedSlot.getStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
flag1 = Container.func_94527_a(slot, this.draggedStack, false);
|
||||||
|
|
||||||
|
if (j1 != -1 && this.draggedStack != null && flag1)
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
|
||||||
|
this.handleMouseClick(slot, j1, 0, 0);
|
||||||
|
|
||||||
|
if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
|
||||||
|
this.field_147011_y = p_146286_1_ - l;
|
||||||
|
this.field_147010_z = p_146286_2_ - i1;
|
||||||
|
this.returningStackDestSlot = this.clickedSlot;
|
||||||
|
this.returningStack = this.draggedStack;
|
||||||
|
this.returningStackTime = Minecraft.getSystemTime();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.returningStack = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.draggedStack != null)
|
||||||
|
{
|
||||||
|
this.field_147011_y = p_146286_1_ - l;
|
||||||
|
this.field_147010_z = p_146286_2_ - i1;
|
||||||
|
this.returningStackDestSlot = this.clickedSlot;
|
||||||
|
this.returningStack = this.draggedStack;
|
||||||
|
this.returningStackTime = Minecraft.getSystemTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.draggedStack = null;
|
||||||
|
this.clickedSlot = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.field_147007_t && !this.field_147008_s.isEmpty())
|
||||||
|
{
|
||||||
|
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5);
|
||||||
|
iterator = this.field_147008_s.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
slot1 = (Slot)iterator.next();
|
||||||
|
this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5);
|
||||||
|
}
|
||||||
|
else if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||||
|
{
|
||||||
|
if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
|
||||||
|
{
|
||||||
|
this.handleMouseClick(slot, j1, p_146286_3_, 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
{
|
||||||
|
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handleMouseClick(slot, j1, p_146286_3_, flag1 ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.mc.thePlayer.inventory.getItemStack() == null)
|
||||||
|
{
|
||||||
|
this.field_146997_J = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field_147007_t = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Slot getSlotAtPosition(int posX, int posY)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k)
|
||||||
|
{
|
||||||
|
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k);
|
||||||
|
|
||||||
|
if (this.isMouseOverSlot(slot, posX, posY))
|
||||||
|
{
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_)
|
||||||
|
{
|
||||||
|
Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_);
|
||||||
|
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||||
|
|
||||||
|
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||||
|
{
|
||||||
|
if (p_146273_3_ == 0 || p_146273_3_ == 1)
|
||||||
|
{
|
||||||
|
if (this.draggedStack == null)
|
||||||
|
{
|
||||||
|
if (slot != this.clickedSlot)
|
||||||
|
{
|
||||||
|
this.draggedStack = this.clickedSlot.getStack().copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false))
|
||||||
|
{
|
||||||
|
long i1 = Minecraft.getSystemTime();
|
||||||
|
|
||||||
|
if (this.field_146985_D == slot)
|
||||||
|
{
|
||||||
|
if (i1 - this.field_146986_E > 500L)
|
||||||
|
{
|
||||||
|
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||||
|
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
|
||||||
|
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||||
|
this.field_146986_E = i1 + 750L;
|
||||||
|
--this.draggedStack.stackSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.field_146985_D = slot;
|
||||||
|
this.field_146986_E = i1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
|
||||||
|
{
|
||||||
|
this.field_147008_s.add(slot);
|
||||||
|
this.func_146980_g();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGuiButton;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||||
|
GuiCustom parent;
|
||||||
|
ResourceLocation texture;
|
||||||
|
public int textureX;
|
||||||
|
public int textureY;
|
||||||
|
boolean field_146123_n;
|
||||||
|
String label;
|
||||||
|
int colour;
|
||||||
|
String[] hoverText;
|
||||||
|
|
||||||
|
public CustomGuiButton(int id, String buttonText, int x, int y) {
|
||||||
|
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, buttonText);
|
||||||
|
this.colour = 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomGuiButton(int id, String buttonText, int x, int y, int width, int height) {
|
||||||
|
super(id, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height, buttonText);
|
||||||
|
this.colour = 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture) {
|
||||||
|
this(buttonId, buttonText, x, y, width, height, texture, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
|
||||||
|
this(buttonId, buttonText, x, y, width, height);
|
||||||
|
this.textureX = textureX;
|
||||||
|
this.textureY = textureY;
|
||||||
|
this.label = buttonText;
|
||||||
|
this.texture = new ResourceLocation(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(GuiCustom parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomGuiButton fromComponent(ScriptGuiButton component) {
|
||||||
|
CustomGuiButton btn;
|
||||||
|
if (component.hasTexture()) {
|
||||||
|
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
|
||||||
|
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture(), component.getTextureX(), component.getTextureY());
|
||||||
|
} else {
|
||||||
|
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTexture());
|
||||||
|
}
|
||||||
|
} else if (component.getWidth() >= 0 && component.getHeight() >= 0) {
|
||||||
|
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
|
||||||
|
} else {
|
||||||
|
btn = new CustomGuiButton(component.getID(), component.getLabel(), component.getPosX(), component.getPosY());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.hasHoverText()) {
|
||||||
|
btn.hoverText = component.getHoverText();
|
||||||
|
}
|
||||||
|
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
|
//GL11.func_179094_E();
|
||||||
|
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
|
||||||
|
FontRenderer fontRenderer = mc.fontRenderer;
|
||||||
|
int i;
|
||||||
|
if (this.texture == null) {
|
||||||
|
mc.getTextureManager().bindTexture(buttonTextures);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||||
|
i = this.getHoverState(this.field_146123_n);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
|
||||||
|
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
|
||||||
|
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
|
||||||
|
this.mouseDragged(mc, mouseX, mouseY);
|
||||||
|
int j = 14737632;
|
||||||
|
if (this.packedFGColour != 0) {
|
||||||
|
j = this.packedFGColour;
|
||||||
|
} else if (!this.enabled) {
|
||||||
|
j = 10526880;
|
||||||
|
} else if (this.field_146123_n) {
|
||||||
|
j = 16777120;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glTranslated(0.0D, 0.0D, 0.1D);
|
||||||
|
this.drawCenteredString(fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j);
|
||||||
|
} else {
|
||||||
|
mc.getTextureManager().bindTexture(this.texture);
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||||
|
i = this.hoverState(this.field_146123_n);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
//GL11.func_187428_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
|
||||||
|
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
|
||||||
|
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.colour);
|
||||||
|
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
|
this.parent.hoverText = this.hoverText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICustomGuiComponent toComponent() {
|
||||||
|
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture.toString(), this.textureX, this.textureY);
|
||||||
|
component.setHoverText(this.hoverText);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColour(int colour) {
|
||||||
|
this.colour = colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int hoverState(boolean mouseOver) {
|
||||||
|
int i = 0;
|
||||||
|
if (mouseOver) {
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
|
||||||
|
if (mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
||||||
|
//Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(SoundEvents.field_187909_gi, 1.0F));
|
||||||
|
gui.buttonClick(this);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.Gui;
|
||||||
|
import net.minecraft.client.gui.GuiLabel;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGuiLabel;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CustomGuiLabel extends Gui implements IGuiComponent {
|
||||||
|
int x, y, width, height;
|
||||||
|
GuiCustom parent;
|
||||||
|
String fullLabel;
|
||||||
|
int color;
|
||||||
|
String[] hoverText;
|
||||||
|
float scale;
|
||||||
|
int id;
|
||||||
|
int border = 2;
|
||||||
|
boolean labelBgEnabled = true;
|
||||||
|
|
||||||
|
protected int field_146167_a;
|
||||||
|
protected int field_146161_f;
|
||||||
|
public int field_146162_g;
|
||||||
|
public int field_146174_h;
|
||||||
|
private ArrayList field_146173_k;
|
||||||
|
private boolean field_146170_l;
|
||||||
|
public boolean field_146172_j;
|
||||||
|
private boolean field_146171_m;
|
||||||
|
private int field_146168_n;
|
||||||
|
private int field_146169_o;
|
||||||
|
private int field_146166_p;
|
||||||
|
private int field_146165_q;
|
||||||
|
private FontRenderer field_146164_r;
|
||||||
|
private int field_146163_s;
|
||||||
|
private static final String __OBFID = "CL_00000671";
|
||||||
|
|
||||||
|
public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height){
|
||||||
|
this.id = id;
|
||||||
|
this.fullLabel = fullLabel;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(GuiCustom parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
|
boolean hovered = mouseX >= this.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f;
|
||||||
|
this.drawLabel();
|
||||||
|
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
|
this.parent.hoverText = this.hoverText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScale(float scale) {
|
||||||
|
this.scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomGuiLabel fromComponent(ScriptGuiLabel component) {
|
||||||
|
CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight());
|
||||||
|
lbl.scale = 1.0F;
|
||||||
|
lbl.color = component.getColor();
|
||||||
|
lbl.field_146172_j = true;
|
||||||
|
lbl.setScale(component.getScale());
|
||||||
|
if (component.hasHoverText()) {
|
||||||
|
lbl.hoverText = component.getHoverText();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lbl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICustomGuiComponent toComponent() {
|
||||||
|
ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color);
|
||||||
|
component.setHoverText(this.hoverText);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawLabel()
|
||||||
|
{
|
||||||
|
if (this.field_146172_j)
|
||||||
|
{
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
this.drawLabelBackground();
|
||||||
|
this.drawString(Minecraft.getMinecraft().fontRenderer, fullLabel, this.x, this.y, this.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawLabelBackground()
|
||||||
|
{
|
||||||
|
if (this.labelBgEnabled)
|
||||||
|
{
|
||||||
|
int k = this.width + this.border * 2;
|
||||||
|
int l = this.height + this.border * 2;
|
||||||
|
int i1 = this.x - this.border;
|
||||||
|
int j1 = this.y - this.border;
|
||||||
|
drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor
|
||||||
|
this.drawHorizontalLine(i1, i1 + k, j1, this.color);//ulColor
|
||||||
|
this.drawHorizontalLine(i1, i1 + k, j1 + l, this.color);//brColor
|
||||||
|
this.drawVerticalLine(i1, j1, j1 + l, this.color);//ulColor
|
||||||
|
this.drawVerticalLine(i1 + k, j1, j1 + l, this.color);//brColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
|
||||||
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGuiScroll;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener {
|
||||||
|
GuiCustom parent;
|
||||||
|
String[] hoverText;
|
||||||
|
public boolean multiSelect = false;
|
||||||
|
|
||||||
|
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
|
||||||
|
super(parent, id);
|
||||||
|
this.mc = mc;
|
||||||
|
this.fontRendererObj = mc.fontRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id, boolean multiSelect) {
|
||||||
|
super(parent, id, multiSelect);
|
||||||
|
this.mc = mc;
|
||||||
|
this.fontRendererObj = mc.fontRenderer;
|
||||||
|
this.multiSelect = multiSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(GuiCustom parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef(0.0F, 0.0F, (float)this.id);
|
||||||
|
boolean hovered = mouseX >= this.guiLeft && mouseY >= this.guiTop && mouseX < this.guiLeft + this.xSize && mouseY < this.guiTop + this.ySize;
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks, mouseWheel);
|
||||||
|
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
|
this.parent.hoverText = this.hoverText;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
return this.isMouseOver(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fromComponent(ScriptGuiScroll component) {
|
||||||
|
this.guiLeft = GuiCustom.guiLeft + component.getPosX();
|
||||||
|
this.guiTop = GuiCustom.guiTop + component.getPosY();
|
||||||
|
this.setSize(component.getWidth(), component.getHeight());
|
||||||
|
this.setUnsortedList(Arrays.asList(component.getList()));
|
||||||
|
if (component.getDefaultSelection() >= 0) {
|
||||||
|
int defaultSelect = component.getDefaultSelection();
|
||||||
|
if (defaultSelect < this.getList().size()) {
|
||||||
|
this.selected = defaultSelect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.hasHoverText()) {
|
||||||
|
this.hoverText = component.getHoverText();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICustomGuiComponent toComponent() {
|
||||||
|
ScriptGuiScroll component = new ScriptGuiScroll(this.id, this.guiLeft - GuiCustom.guiLeft, this.guiTop - GuiCustom.guiTop, this.width, this.height, (String[])this.getList().toArray(new String[0]));
|
||||||
|
component.setHoverText(this.hoverText);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound toNBT() {
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
nbt.setInteger("id", this.id);
|
||||||
|
if (!this.getSelectedList().isEmpty()) {
|
||||||
|
NBTTagList tagList = new NBTTagList();
|
||||||
|
Iterator var3 = this.getSelectedList().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
String s = (String)var3.next();
|
||||||
|
tagList.appendTag(new NBTTagString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setTag("selectedList", tagList);
|
||||||
|
} else if (this.getSelected() != null && !this.getSelected().isEmpty()) {
|
||||||
|
nbt.setString("selected", this.getSelected());
|
||||||
|
} else {
|
||||||
|
nbt.setString("selected", "Null");
|
||||||
|
}
|
||||||
|
|
||||||
|
return nbt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
|
||||||
|
public class CustomGuiSlot extends Slot {
|
||||||
|
public boolean clientSide;
|
||||||
|
public int slotNumber;
|
||||||
|
|
||||||
|
public CustomGuiSlot(IInventory inventoryIn, int index, int xPosition, int yPosition, boolean clientSide) {
|
||||||
|
super(inventoryIn, index, xPosition, yPosition);
|
||||||
|
this.clientSide = clientSide;
|
||||||
|
this.slotNumber = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSlotChanged() {
|
||||||
|
if (this.clientSide) {
|
||||||
|
((GuiCustom)Minecraft.getMinecraft().currentScreen).slotChange(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onSlotChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IKeyListener;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGuiTextField;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
|
||||||
|
public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener {
|
||||||
|
GuiCustom parent;
|
||||||
|
String[] hoverText;
|
||||||
|
int id;
|
||||||
|
|
||||||
|
public CustomGuiTextField(int id, int x, int y, int width, int height) {
|
||||||
|
super(Minecraft.getMinecraft().fontRenderer, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
|
||||||
|
this.id = id;
|
||||||
|
this.setMaxStringLength(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyTyped(char typedChar, int keyCode) {
|
||||||
|
this.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
|
boolean hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
|
||||||
|
this.drawTextBox();
|
||||||
|
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
|
this.parent.hoverText = this.hoverText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(GuiCustom parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound toNBT() {
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
tag.setInteger("id", this.id);
|
||||||
|
tag.setString("text", this.getText());
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICustomGuiComponent toComponent() {
|
||||||
|
ScriptGuiTextField component = new ScriptGuiTextField(this.id, this.xPosition - GuiCustom.guiLeft, this.yPosition - GuiCustom.guiTop, this.width, this.height);
|
||||||
|
component.setText(this.getText());
|
||||||
|
component.setHoverText(this.hoverText);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomGuiTextField fromComponent(ScriptGuiTextField component) {
|
||||||
|
CustomGuiTextField txt = new CustomGuiTextField(component.getID(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
|
||||||
|
if (component.hasHoverText()) {
|
||||||
|
txt.hoverText = component.getHoverText();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.getText() != null && !component.getText().isEmpty()) {
|
||||||
|
txt.setText(component.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
return txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mouseClicked(GuiCustom gui, int mouseX, int mouseY, int mouseButton) {
|
||||||
|
boolean flag = mouseX >= this.xPosition && mouseX < this.xPosition + this.width && mouseY >= this.yPosition && mouseY < this.yPosition + this.height;
|
||||||
|
|
||||||
|
if (this.isFocused() && mouseButton == 0 && !flag){
|
||||||
|
parent.onTextFieldUnfocused(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.components;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Gui;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||||
|
GuiCustom parent;
|
||||||
|
ResourceLocation texture;
|
||||||
|
int id;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int textureX;
|
||||||
|
int textureY;
|
||||||
|
float scale;
|
||||||
|
String[] hoverText;
|
||||||
|
|
||||||
|
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||||
|
this(id, texture, x, y, width, height, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||||
|
this.scale = 1.0F;
|
||||||
|
this.id = id;
|
||||||
|
this.texture = new ResourceLocation(texture);
|
||||||
|
this.x = GuiCustom.guiLeft + x;
|
||||||
|
this.y = GuiCustom.guiTop + y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.textureX = textureX;
|
||||||
|
this.textureY = textureY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(GuiCustom parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
|
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||||
|
mc.getTextureManager().bindTexture(this.texture);
|
||||||
|
|
||||||
|
this.drawTexturedModalRect(this.x + this.textureX, this.y + this.textureY, 0, 0, (int)(this.width*this.scale), (int)(this.height*this.scale));
|
||||||
|
|
||||||
|
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
|
this.parent.hoverText = this.hoverText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICustomGuiComponent toComponent() {
|
||||||
|
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||||
|
component.setHoverText(this.hoverText);
|
||||||
|
component.setScale(this.scale);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomGuiTexturedRect fromComponent(ScriptGuiTexturedRect component) {
|
||||||
|
CustomGuiTexturedRect rect;
|
||||||
|
if (component.getTextureX() >= 0 && component.getTextureY() >= 0) {
|
||||||
|
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight(), component.getTextureX(), component.getTextureY());
|
||||||
|
} else {
|
||||||
|
rect = new CustomGuiTexturedRect(component.getID(), component.getTexture(), component.getPosX(), component.getPosY(), component.getWidth(), component.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
rect.scale = component.getScale();
|
||||||
|
if (component.hasHoverText()) {
|
||||||
|
rect.hoverText = component.getHoverText();
|
||||||
|
}
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.interfaces;
|
||||||
|
|
||||||
|
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||||
|
|
||||||
|
public interface IClickListener extends IGuiComponent {
|
||||||
|
boolean mouseClicked(GuiCustom var1, int var2, int var3, int var4);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.interfaces;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
public interface IDataHolder extends IGuiComponent {
|
||||||
|
NBTTagCompound toNBT();
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.interfaces;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||||
|
|
||||||
|
public interface IGuiComponent {
|
||||||
|
int getID();
|
||||||
|
|
||||||
|
void onRender(Minecraft var1, int var2, int var3, int var4, float var5);
|
||||||
|
|
||||||
|
ICustomGuiComponent toComponent();
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.custom.interfaces;
|
||||||
|
|
||||||
|
public interface IKeyListener extends IGuiComponent {
|
||||||
|
void keyTyped(char var1, int var2);
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.CustomNpcResourceListener;
|
import noppes.npcs.client.CustomNpcResourceListener;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
|
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
|
||||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
import noppes.npcs.client.gui.util.ICustomScrollListener;
|
import noppes.npcs.client.gui.util.ICustomScrollListener;
|
||||||
@@ -63,11 +62,11 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
|||||||
getTextField(0).setMaxStringLength(20);
|
getTextField(0).setMaxStringLength(20);
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, ""));
|
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMaxStringLength(1);
|
getTextField(1).setMaxStringLength(1);
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
|
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMaxStringLength(1);
|
getTextField(2).setMaxStringLength(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public class GuiNpcQuestReward extends GuiContainerNPCInterface implements IText
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45));
|
addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45));
|
||||||
addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + ""));
|
addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, 99999, 0);
|
getTextField(0).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(GuiButton guibutton){
|
public void actionPerformed(GuiButton guibutton){
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
|
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
|
||||||
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;
|
||||||
@@ -45,13 +44,13 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
|
|||||||
super.initGui();
|
super.initGui();
|
||||||
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
||||||
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, Short.MAX_VALUE, 0);
|
getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(0, Short.MAX_VALUE, 0);
|
getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0);
|
||||||
|
|
||||||
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
|||||||
if (ai.useRangeMelee >= 1){
|
if (ai.useRangeMelee >= 1){
|
||||||
addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115));
|
addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115));
|
||||||
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + ""));
|
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + ""));
|
||||||
getTextField(6).numbersOnly = true;
|
getTextField(6).integersOnly = true;
|
||||||
getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5);
|
getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5);
|
||||||
}
|
}
|
||||||
addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140));
|
addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140));
|
||||||
@@ -70,7 +70,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
|||||||
}
|
}
|
||||||
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140));
|
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140));
|
||||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + ""));
|
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + ""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5);
|
getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit"));
|
this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit"));
|
||||||
addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
|
addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
|
||||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
|
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(1, 30, 5);
|
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
|
||||||
addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
|
//addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
|
||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5));
|
||||||
@@ -82,6 +82,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(5,"display.livingAnimation", guiLeft + 5, y + 5));
|
||||||
this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0));
|
this.addButton(new GuiNpcButton(5, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no"}, display.disableLivingAnimation?1:0));
|
||||||
|
|
||||||
|
addLabel(new GuiNpcLabel(6,"Collides With Entities", guiLeft + 185, y + 5));
|
||||||
|
this.addButton(new GuiNpcButton(6, guiLeft + 300, y, 100, 20, new String[]{"gui.yes","gui.no","Only CNPCs","Only Players","CNPCs & Players"}, display.collidesWith));
|
||||||
|
|
||||||
y+=23;
|
y+=23;
|
||||||
addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(7,"display.visible", guiLeft + 5, y + 5));
|
||||||
this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible));
|
this.addButton(new GuiNpcButton(7, guiLeft + 120, y, 50, 20, new String[]{"gui.yes","gui.no","gui.partly"}, display.visible));
|
||||||
@@ -155,6 +158,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
else if(button.id == 5){
|
else if(button.id == 5){
|
||||||
display.disableLivingAnimation = button.getValue() == 1;
|
display.disableLivingAnimation = button.getValue() == 1;
|
||||||
}
|
}
|
||||||
|
else if(button.id == 6){
|
||||||
|
display.collidesWith = button.getValue();
|
||||||
|
}
|
||||||
else if(button.id == 7){
|
else if(button.id == 7){
|
||||||
display.visible = button.getValue();
|
display.visible = button.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
super.initGui();
|
super.initGui();
|
||||||
int y = guiTop + 10;
|
int y = guiTop + 10;
|
||||||
addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5));
|
||||||
addTextField(new GuiNpcTextField(0,this, guiLeft + 85, y, 50, 18, stats.maxHealth+""));
|
addTextField(new GuiNpcTextField(0,this, guiLeft + 85, y, 50, 18, String.format("%.0f", stats.maxHealth) + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).doublesOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
|
getTextField(0).setMinMaxDefaultDouble(0, Double.MAX_VALUE,20);
|
||||||
addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 140, y + 5));
|
addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 140, y + 5));
|
||||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 220, y, 50, 18, stats.aggroRange+""));
|
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 220, y, 50, 18, stats.aggroRange+""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(1, 64, 2);
|
getTextField(1).setMinMaxDefault(1, 96, 2); // Doesn't work past 32 technically (MC Limitations)
|
||||||
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
|
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
|
||||||
addButton(new GuiNpcButton(8,guiLeft + 355, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
|
addButton(new GuiNpcButton(8,guiLeft + 355, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
|
||||||
|
|
||||||
@@ -63,10 +63,10 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5));
|
||||||
addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.canDrown? 1:0));
|
addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.canDrown? 1:0));
|
||||||
addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5));
|
addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5));
|
||||||
addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, stats.healthRegen + "").setNumbersOnly());
|
addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, String.format("%.0f", stats.healthRegen) + "").setFloatsOnly());
|
||||||
addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5));
|
addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, stats.combatRegen + "").setNumbersOnly());
|
addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, String.format("%.0f", stats.combatRegen) + "").setFloatsOnly());
|
||||||
addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5));
|
addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5));
|
||||||
addButton(new GuiNpcButton(6,guiLeft + 82, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
|
addButton(new GuiNpcButton(6,guiLeft + 82, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
|
||||||
addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5));
|
||||||
@@ -82,17 +82,17 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
@Override
|
@Override
|
||||||
public void unFocused(GuiNpcTextField textfield){
|
public void unFocused(GuiNpcTextField textfield){
|
||||||
if(textfield.id == 0){
|
if(textfield.id == 0){
|
||||||
stats.maxHealth = textfield.getInteger();
|
stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText()));
|
||||||
npc.heal(stats.maxHealth);
|
npc.heal((float)(stats.maxHealth));
|
||||||
}
|
}
|
||||||
else if(textfield.id == 1){
|
else if(textfield.id == 1){
|
||||||
stats.aggroRange = textfield.getInteger();
|
stats.aggroRange = textfield.getInteger();
|
||||||
}
|
}
|
||||||
else if(textfield.id == 14){
|
else if(textfield.id == 14){
|
||||||
stats.healthRegen = textfield.getInteger();
|
stats.healthRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
|
||||||
}
|
}
|
||||||
else if(textfield.id == 16){
|
else if(textfield.id == 16){
|
||||||
stats.combatRegen = textfield.getInteger();
|
stats.combatRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class GuiModelArms extends GuiModelInterface{
|
|||||||
|
|
||||||
private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"};
|
private final String[] arrArm = new String[]{"gui.no","Both","Right","Left"};
|
||||||
private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"};
|
private final String[] arrArmwear = new String[]{"gui.no","Both","Left","Right"};
|
||||||
|
private final String[] arrSolidArmwear = new String[]{"gui.no","Both","Left","Right"};
|
||||||
private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"};
|
private final String[] arrClaws = new String[]{"gui.no","Both","Left","Right"};
|
||||||
|
|
||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
@@ -32,6 +33,9 @@ public class GuiModelArms extends GuiModelInterface{
|
|||||||
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
|
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
|
||||||
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear));
|
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrArmwear, playerdata.armwear));
|
||||||
addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF));
|
addLabel(new GuiNpcLabel(8, "Armwear", guiLeft, y + 5, 0xFFFFFF));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidArmwear, playerdata.solidArmwear));
|
||||||
|
addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelPartData claws = playerdata.getPartData("claws");
|
ModelPartData claws = playerdata.getPartData("claws");
|
||||||
@@ -50,6 +54,9 @@ public class GuiModelArms extends GuiModelInterface{
|
|||||||
if(button.id == 8){
|
if(button.id == 8){
|
||||||
playerdata.armwear = (byte) button.getValue();
|
playerdata.armwear = (byte) button.getValue();
|
||||||
}
|
}
|
||||||
|
if(button.id == 9){
|
||||||
|
playerdata.solidArmwear = (byte) button.getValue();
|
||||||
|
}
|
||||||
if(button.id == 30){
|
if(button.id == 30){
|
||||||
playerdata.hideArms = (byte) button.getValue();
|
playerdata.hideArms = (byte) button.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class GuiModelBody extends GuiModelInterface{
|
|||||||
|
|
||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
private final String[] arrBody = new String[]{"gui.no","gui.yes"};
|
private final String[] arrBody = new String[]{"gui.no","gui.yes"};
|
||||||
private final String[] arrBodywear = new String[]{"gui.no","gui.yes"};
|
private final String[] arrBodywear = new String[]{"gui.no","gui.yes","Solid"};
|
||||||
private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9",
|
private final String[] arrWing = new String[]{"gui.no","Player","Type1","Type2","Type3","Type4","Type5","Type6","Type7","Type8","Type9",
|
||||||
"Type10","Type11","Type12","Type13"};
|
"Type10","Type11","Type12","Type13"};
|
||||||
private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"};
|
private final String[] arrBreasts = new String[]{"gui.no","Type1","Type2","Type3"};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class GuiModelLegs extends GuiModelInterface{
|
|||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"};
|
private final String[] arrLeg = new String[]{"gui.no","Both","Right","Left"};
|
||||||
private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"};
|
private final String[] arrLegwear = new String[]{"gui.no","Both","Left","Right"};
|
||||||
|
private final String[] arrSolidLegwear = new String[]{"gui.no","Both","Left","Right"};
|
||||||
private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"};
|
private final String[] arrLegs = new String[]{"gui.no","Player","Player Naga","Spider","Horse","Naga", "Mermaid", "Mermaid 2", "Digitigrade"};
|
||||||
private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather"};
|
private final String[] arrTail = new String[]{"gui.no","Player", "Player Dragon","Cat","Wolf","Horse","Dragon", "Squirrel", "Fin", "Rodent", "Feather"};
|
||||||
public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){
|
public GuiModelLegs(GuiScreen parent, EntityCustomNpc npc){
|
||||||
@@ -32,6 +33,9 @@ public class GuiModelLegs extends GuiModelInterface{
|
|||||||
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
|
if (npc.display.modelType == 1 || npc.display.modelType == 2) {
|
||||||
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear));
|
addButton(new GuiNpcButton(8, guiLeft + 50, y += 22, 70, 20, arrLegwear, playerdata.legwear));
|
||||||
addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF));
|
addLabel(new GuiNpcLabel(8, "Legwear", guiLeft, y + 5, 0xFFFFFF));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(9, guiLeft + 50, y += 22, 70, 20, arrSolidLegwear, playerdata.solidLegwear));
|
||||||
|
addLabel(new GuiNpcLabel(9, "Solid", guiLeft, y + 5, 0xFFFFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts)));
|
addButton(new GuiNpcButton(1, guiLeft + 50, y += 22, 70, 20, arrLegs, getLegIndex(playerdata.legParts)));
|
||||||
@@ -91,6 +95,9 @@ public class GuiModelLegs extends GuiModelInterface{
|
|||||||
if(button.id == 8){
|
if(button.id == 8){
|
||||||
playerdata.legwear = (byte) button.getValue();
|
playerdata.legwear = (byte) button.getValue();
|
||||||
}
|
}
|
||||||
|
if(button.id == 9){
|
||||||
|
playerdata.solidLegwear = (byte) button.getValue();
|
||||||
|
}
|
||||||
if(button.id == 30){
|
if(button.id == 30){
|
||||||
playerdata.hideLegs = (byte) button.getValue();
|
playerdata.hideLegs = (byte) button.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
|
|||||||
grabMouse(dialog.showWheel);
|
grabMouse(dialog.showWheel);
|
||||||
guiTop = (height - ySize);
|
guiTop = (height - ySize);
|
||||||
calculateRowHeight();
|
calculateRowHeight();
|
||||||
|
this.drawDefaultBackground = dialog.darkenScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void grabMouse(boolean grab){
|
public void grabMouse(boolean grab){
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
for (String name : quest.targets.keySet()) {
|
for (String name : quest.targets.keySet()) {
|
||||||
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name));
|
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name));
|
||||||
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + ""));
|
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + ""));
|
||||||
this.getTextField(i+3).numbersOnly = true;
|
this.getTextField(i+3).integersOnly = true;
|
||||||
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
for(;i < 3; i++){
|
for(;i < 3; i++){
|
||||||
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, ""));
|
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, ""));
|
||||||
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1"));
|
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1"));
|
||||||
this.getTextField(i+3).numbersOnly = true;
|
this.getTextField(i+3).integersOnly = true;
|
||||||
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||||
}
|
}
|
||||||
Map<?,?> data = EntityList.stringToClassMapping;
|
Map<?,?> data = EntityList.stringToClassMapping;
|
||||||
|
|||||||
@@ -39,16 +39,16 @@ public class GuiNpcBard extends GuiNPCInterface2
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143));
|
addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143));
|
||||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + ""));
|
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(2, 64, 5);
|
getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166));
|
addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166));
|
||||||
addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0));
|
addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0));
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189));
|
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189));
|
||||||
addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + ""));
|
addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + ""));
|
||||||
getTextField(3).numbersOnly = true;
|
getTextField(3).integersOnly = true;
|
||||||
getTextField(3).setMinMaxDefault(2, 64, 10);
|
getTextField(3).setMinMaxDefault(2, Integer.MAX_VALUE, 10);
|
||||||
|
|
||||||
getLabel(3).enabled = job.hasOffRange;
|
getLabel(3).enabled = job.hasOffRange;
|
||||||
getTextField(3).enabled = job.hasOffRange;
|
getTextField(3).enabled = job.hasOffRange;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListe
|
|||||||
addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5));
|
||||||
if(role.canAge){
|
if(role.canAge){
|
||||||
addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + ""));
|
addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,19 +48,19 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi
|
|||||||
|
|
||||||
if(i > 0){
|
if(i > 0){
|
||||||
this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + ""));
|
this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + ""));
|
||||||
this.getTextField(i + 14).numbersOnly = true;
|
this.getTextField(i + 14).integersOnly = true;
|
||||||
this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40);
|
this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175));
|
addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175));
|
||||||
addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + ""));
|
addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + ""));
|
||||||
getTextField(50).numbersOnly = true;
|
getTextField(50).integersOnly = true;
|
||||||
getTextField(50).setMinMaxDefault(10, 1000000, 12000);
|
getTextField(50).setMinMaxDefault(10, Integer.MAX_VALUE, 12000);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196));
|
addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196));
|
||||||
addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + ""));
|
addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + ""));
|
||||||
getTextField(54).numbersOnly = true;
|
getTextField(54).integersOnly = true;
|
||||||
getTextField(54).setMinMaxDefault(4, 60, 20);
|
getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175));
|
addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175));
|
||||||
String title = job.questTitle;
|
String title = job.questTitle;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2
|
|||||||
int y = guiTop + 37;
|
int y = guiTop + 37;
|
||||||
y += i * 25;
|
y += i * 25;
|
||||||
GuiNpcTextField tf = new GuiNpcTextField(i,this, fontRendererObj,x, y, 24, 20, "1");
|
GuiNpcTextField tf = new GuiNpcTextField(i,this, fontRendererObj,x, y, 24, 20, "1");
|
||||||
tf.numbersOnly = true;
|
tf.integersOnly = true;
|
||||||
tf.setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
tf.setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||||
addTextField(tf);
|
addTextField(tf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ public class GuiNpcHealer extends GuiNPCInterface2
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"Healing Speed:", guiLeft + 60, guiTop + 110));
|
addLabel(new GuiNpcLabel(1,"Healing Speed:", guiLeft + 60, guiTop + 110));
|
||||||
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+130, guiTop + 105, 40, 20, job.speed + ""));
|
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+130, guiTop + 105, 40, 20, job.speed + ""));
|
||||||
getTextField(1).numbersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(1, 10, 8);
|
getTextField(1).setMinMaxDefault(1, Integer.MAX_VALUE, 8);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(2,"Range:", guiLeft + 60, guiTop + 133));
|
addLabel(new GuiNpcLabel(2,"Range:", guiLeft + 60, guiTop + 133));
|
||||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+130, guiTop + 128, 40, 20, job.range + ""));
|
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+130, guiTop + 128, 40, 20, job.range + ""));
|
||||||
getTextField(2).numbersOnly = true;
|
getTextField(2).integersOnly = true;
|
||||||
getTextField(2).setMinMaxDefault(2, 20, 5);
|
getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ public class GuiNpcItemGiver extends GuiContainerNPCInterface2
|
|||||||
this.addButton(new GuiNpcButton(1, guiLeft + 6, guiTop + 29, 140,20, new String[]{"Timer","Give Only Once","Daily"},role.cooldownType));
|
this.addButton(new GuiNpcButton(1, guiLeft + 6, guiTop + 29, 140,20, new String[]{"Timer","Give Only Once","Daily"},role.cooldownType));
|
||||||
|
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 55, guiTop + 54, 90, 20, role.cooldown + ""));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 55, guiTop + 54, 90, 20, role.cooldown + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
addLabel(new GuiNpcLabel(0,"Cooldown:", guiLeft + 6, guiTop + 59));
|
addLabel(new GuiNpcLabel(0,"Cooldown:", guiLeft + 6, guiTop + 59));
|
||||||
addLabel(new GuiNpcLabel(1,"Items to give", guiLeft + 46, guiTop + 79));
|
addLabel(new GuiNpcLabel(1,"Items to give", guiLeft + 46, guiTop + 79));
|
||||||
|
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(String line : role.lines){
|
for(String line : role.lines){
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerSelector;
|
import noppes.npcs.client.gui.GuiNpcMobSpawnerSelector;
|
||||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
|
||||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||||
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;
|
||||||
@@ -82,15 +81,15 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
|||||||
y += 23;
|
y += 23;
|
||||||
addLabel(new GuiNpcLabel(7,StatCollector.translateToLocal("spawner.posoffset")+" X:", guiLeft + 4, y + 5));
|
addLabel(new GuiNpcLabel(7,StatCollector.translateToLocal("spawner.posoffset")+" X:", guiLeft + 4, y + 5));
|
||||||
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 99, y, 24, 20, job.xOffset + ""));
|
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 99, y, 24, 20, job.xOffset + ""));
|
||||||
getTextField(7).numbersOnly = true;
|
getTextField(7).integersOnly = true;
|
||||||
getTextField(7).setMinMaxDefault(-9, 9, 0);
|
getTextField(7).setMinMaxDefault(-9, 9, 0);
|
||||||
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
|
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
|
||||||
addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 135, y, 24, 20, job.yOffset + ""));
|
addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 135, y, 24, 20, job.yOffset + ""));
|
||||||
getTextField(8).numbersOnly = true;
|
getTextField(8).integersOnly = true;
|
||||||
getTextField(8).setMinMaxDefault(-9, 9, 0);
|
getTextField(8).setMinMaxDefault(-9, 9, 0);
|
||||||
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
|
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
|
||||||
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171, y, 24, 20, job.zOffset + ""));
|
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171, y, 24, 20, job.zOffset + ""));
|
||||||
getTextField(9).numbersOnly = true;
|
getTextField(9).integersOnly = true;
|
||||||
getTextField(9).setMinMaxDefault(-9, 9, 0);
|
getTextField(9).setMinMaxDefault(-9, 9, 0);
|
||||||
|
|
||||||
y += 23;
|
y += 23;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import noppes.npcs.EventScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
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;
|
||||||
@@ -18,10 +18,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
|
|||||||
public class EventGuiScriptList extends SubGuiInterface {
|
public class EventGuiScriptList extends SubGuiInterface {
|
||||||
private GuiCustomScroll scroll1;
|
private GuiCustomScroll scroll1;
|
||||||
private GuiCustomScroll scroll2;
|
private GuiCustomScroll scroll2;
|
||||||
private EventScriptContainer container;
|
private ScriptContainer container;
|
||||||
private List<String> scripts;
|
private List<String> scripts;
|
||||||
|
|
||||||
public EventGuiScriptList(List<String> scripts, EventScriptContainer container) {
|
public EventGuiScriptList(List<String> scripts, ScriptContainer container) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.setBackground("menubg.png");
|
this.setBackground("menubg.png");
|
||||||
this.xSize = 346;
|
this.xSize = 346;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package noppes.npcs.client.gui.script;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.constants.EnumPacketServer;
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
|
||||||
public class GuiScriptForge extends GuiScriptInterface {
|
public class GuiScriptForge extends GuiScriptInterface {
|
||||||
@@ -15,7 +16,7 @@ public class GuiScriptForge extends GuiScriptInterface {
|
|||||||
|
|
||||||
public GuiScriptForge() {
|
public GuiScriptForge() {
|
||||||
this.handler = this.script;
|
this.handler = this.script;
|
||||||
Client.sendData(EnumPacketServer.ScriptForgeGet);
|
Client.sendData(EnumPacketServer.ScriptForgeGet, new Object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
@@ -25,6 +26,6 @@ public class GuiScriptForge extends GuiScriptInterface {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
super.save();
|
||||||
Client.sendData(EnumPacketServer.ScriptForgeSave, script.writeToNBT(new NBTTagCompound()));
|
Client.sendData(EnumPacketServer.ScriptForgeSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,15 +6,11 @@
|
|||||||
package noppes.npcs.client.gui.script;
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
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.Event;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
@@ -24,17 +20,19 @@ import net.minecraft.client.gui.GuiYesNo;
|
|||||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
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.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.event.CommandEvent;
|
||||||
import net.minecraftforge.event.entity.EntityEvent;
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
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 net.minecraftforge.event.world.WorldEvent;
|
||||||
import noppes.npcs.EventScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.NoppesStringUtils;
|
import noppes.npcs.NoppesStringUtils;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
import noppes.npcs.client.NoppesUtil;
|
||||||
import noppes.npcs.client.gui.swing.GuiJTextArea;
|
import noppes.npcs.client.gui.swing.GuiJTextArea;
|
||||||
import noppes.npcs.client.gui.util.*;
|
import noppes.npcs.client.gui.util.*;
|
||||||
import noppes.npcs.controllers.IScriptHandler;
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
import noppes.npcs.controllers.PixelmonHelper;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
@@ -137,6 +135,18 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
hookList.add("playSound");
|
hookList.add("playSound");
|
||||||
hookList.add("lightning");
|
hookList.add("lightning");
|
||||||
hookList.add("changedDim");
|
hookList.add("changedDim");
|
||||||
|
hookList.add("questStart");
|
||||||
|
hookList.add("questCompleted");
|
||||||
|
hookList.add("questTurnIn");
|
||||||
|
hookList.add("factionPoints");
|
||||||
|
hookList.add("dialogOpen");
|
||||||
|
hookList.add("dialogOption");
|
||||||
|
hookList.add("dialogClose");
|
||||||
|
hookList.add("customGuiClosed");
|
||||||
|
hookList.add("customGuiButton");
|
||||||
|
hookList.add("customGuiSlot");
|
||||||
|
hookList.add("customGuiScroll");
|
||||||
|
hookList.add("customGuiTextfield");
|
||||||
}
|
}
|
||||||
else if(handler instanceof ForgeDataScript) {
|
else if(handler instanceof ForgeDataScript) {
|
||||||
hooks.setSize(238, 198);
|
hooks.setSize(238, 198);
|
||||||
@@ -146,9 +156,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
|
|
||||||
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
|
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
|
||||||
try {
|
try {
|
||||||
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.event"));
|
|
||||||
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
|
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.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
|
||||||
|
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -163,7 +173,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
Iterator var10 = c.iterator();
|
Iterator var10 = c.iterator();
|
||||||
while(var10.hasNext()) {
|
while(var10.hasNext()) {
|
||||||
Class c1 = (Class) var10.next();
|
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())) {
|
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)) {
|
||||||
String eventName = c1.getName();
|
String eventName = c1.getName();
|
||||||
int i = eventName.lastIndexOf(".");
|
int i = eventName.lastIndexOf(".");
|
||||||
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
||||||
@@ -180,7 +190,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
hookLabel.color = 0xaaaaaa;
|
hookLabel.color = 0xaaaaaa;
|
||||||
addLabel(hookLabel);
|
addLabel(hookLabel);
|
||||||
|
|
||||||
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
ScriptContainer var7 = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + yoffset, this.guiTop + yoffset, this.xSize - 110 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
|
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + yoffset, this.guiTop + yoffset, this.xSize - 110 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
|
||||||
this.addTextField(left);
|
this.addTextField(left);
|
||||||
int left1 = this.guiLeft + this.xSize - 104;
|
int left1 = this.guiLeft + this.xSize - 104;
|
||||||
@@ -224,26 +234,27 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
this.ySize = 256;
|
this.ySize = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String previousHookClicked = "";
|
||||||
@Override
|
@Override
|
||||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||||
//this.handler.getScripts().get(this.activeTab - 1).setType(scroll.getSelected().replace("playerscript.",""));
|
String hook = scroll.getSelected();
|
||||||
|
if(previousHookClicked.equals(hook)){
|
||||||
|
String addString = "";
|
||||||
|
if(!this.getTextField(2).getText().isEmpty())
|
||||||
|
addString += "\n";
|
||||||
|
addString += "function "+hook+"(event) {\n \n}\n";
|
||||||
|
|
||||||
|
this.getTextField(2).setText(this.getTextField(2).getText()+addString);
|
||||||
|
previousHookClicked = "";
|
||||||
|
} else {
|
||||||
|
previousHookClicked = hook;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unFocused(GuiNpcTextField textfield) {
|
public void unFocused(GuiNpcTextField textfield) {
|
||||||
/*if(textfield.id == 1){
|
|
||||||
this.handler.getScripts().get(this.activeTab - 1).setType(textfield.getText());
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/*private int getScriptHook(EventScriptContainer eventScriptContainer, List<String> list) {
|
}
|
||||||
for(String s : list) {
|
|
||||||
if (s.replace("playerscript.", "").equals(eventScriptContainer.type)) {
|
|
||||||
return list.indexOf(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
private String getConsoleText() {
|
private String getConsoleText() {
|
||||||
Map<Long, String> map = this.handler.getConsoleText();
|
Map<Long, String> map = this.handler.getConsoleText();
|
||||||
@@ -307,7 +318,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(guibutton.id == scriptLimit) {
|
if(guibutton.id == scriptLimit) {
|
||||||
this.handler.getScripts().add(new EventScriptContainer(this.handler));
|
this.handler.getScripts().add(new ScriptContainer(this.handler));
|
||||||
this.activeTab = this.handler.getScripts().size();
|
this.activeTab = this.handler.getScripts().size();
|
||||||
this.initGui();
|
this.initGui();
|
||||||
}
|
}
|
||||||
@@ -336,10 +347,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
|
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
EventScriptContainer container;
|
ScriptContainer container;
|
||||||
if(guibutton.id == 102) {
|
if(guibutton.id == 102) {
|
||||||
if(this.activeTab > 0) {
|
if(this.activeTab > 0) {
|
||||||
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
container.script = "";
|
container.script = "";
|
||||||
} else {
|
} else {
|
||||||
this.handler.clearConsole();
|
this.handler.clearConsole();
|
||||||
@@ -366,16 +377,16 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(guibutton.id == 107) {
|
if(guibutton.id == 107) {
|
||||||
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
if(container == null) {
|
if(container == null) {
|
||||||
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
|
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
|
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(guibutton.id == 108) {
|
if(guibutton.id == 108) {
|
||||||
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
if(container != null) {
|
if(container != null) {
|
||||||
this.setScript();
|
this.setScript();
|
||||||
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||||
@@ -386,9 +397,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
|
|
||||||
private void setScript() {
|
private void setScript() {
|
||||||
if(this.activeTab > 0) {
|
if(this.activeTab > 0) {
|
||||||
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
if(container == null) {
|
if(container == null) {
|
||||||
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
|
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = (this.getTextField(2)).getText();
|
String text = (this.getTextField(2)).getText();
|
||||||
@@ -424,7 +435,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void textUpdate(String text) {
|
public void textUpdate(String text) {
|
||||||
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
if(container != null) {
|
if(container != null) {
|
||||||
container.script = text;
|
container.script = text;
|
||||||
}
|
}
|
||||||
@@ -433,7 +444,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveText(String text) {
|
public void saveText(String text) {
|
||||||
EventScriptContainer container = handler.getScripts().get(activeTab);
|
ScriptContainer container = handler.getScripts().get(activeTab);
|
||||||
if(container != null)
|
if(container != null)
|
||||||
container.script = text;
|
container.script = text;
|
||||||
initGui();
|
initGui();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
|||||||
|
|
||||||
public GuiScriptPlayers() {
|
public GuiScriptPlayers() {
|
||||||
this.handler = this.script;
|
this.handler = this.script;
|
||||||
Client.sendData(EnumPacketServer.ScriptPlayerGet);
|
Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGuiData(NBTTagCompound compound) {
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
@@ -27,7 +27,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
|||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
super.save();
|
super.save();
|
||||||
Client.sendData(EnumPacketServer.ScriptPlayerSave, script.writeToNBT(new NBTTagCompound()));
|
Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class GuiCustomScroll extends GuiScreen
|
|||||||
public int id;
|
public int id;
|
||||||
public int guiLeft = 0;
|
public int guiLeft = 0;
|
||||||
public int guiTop = 0;
|
public int guiTop = 0;
|
||||||
private int xSize, ySize;
|
public int xSize, ySize;
|
||||||
public int selected;
|
public int selected;
|
||||||
private HashSet<String> selectedList;
|
private HashSet<String> selectedList;
|
||||||
private int hover;
|
private int hover;
|
||||||
|
|||||||
@@ -8,10 +8,14 @@ import net.minecraft.client.gui.GuiTextField;
|
|||||||
public class GuiNpcTextField extends GuiTextField{
|
public class GuiNpcTextField extends GuiTextField{
|
||||||
public boolean enabled = true;
|
public boolean enabled = true;
|
||||||
public boolean inMenu = true;
|
public boolean inMenu = true;
|
||||||
public boolean numbersOnly = false;
|
public boolean integersOnly = false;
|
||||||
|
public boolean doublesOnly = false;
|
||||||
|
public boolean floatsOnly = false;
|
||||||
private ITextfieldListener listener;
|
private ITextfieldListener listener;
|
||||||
public int id;
|
public int id;
|
||||||
public int min = 0,max = Integer.MAX_VALUE,def = 0;
|
public int min = 0,max = Integer.MAX_VALUE,def = 0;
|
||||||
|
public double minDouble = 0, maxDouble = Double.MAX_VALUE, defDouble = 0;
|
||||||
|
public float minFloat = 0, maxFloat = Float.MAX_VALUE, defFloat = 0;
|
||||||
private static GuiNpcTextField activeTextfield = null;
|
private static GuiNpcTextField activeTextfield = null;
|
||||||
public boolean canEdit = true;
|
public boolean canEdit = true;
|
||||||
|
|
||||||
@@ -37,7 +41,7 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean charAllowed(char c, int i){
|
private boolean charAllowed(char c, int i){
|
||||||
if(!numbersOnly || Character.isDigit(c))
|
if(!integersOnly || Character.isDigit(c))
|
||||||
return true;
|
return true;
|
||||||
for(int j : allowedSpecialChars)
|
for(int j : allowedSpecialChars)
|
||||||
if(j == i)
|
if(j == i)
|
||||||
@@ -61,6 +65,7 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
public int getInteger(){
|
public int getInteger(){
|
||||||
return Integer.parseInt(getText());
|
return Integer.parseInt(getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInteger(){
|
public boolean isInteger(){
|
||||||
try{
|
try{
|
||||||
Integer.parseInt(getText());
|
Integer.parseInt(getText());
|
||||||
@@ -69,6 +74,33 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getDouble(){
|
||||||
|
return Double.parseDouble(getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDouble() {
|
||||||
|
try{
|
||||||
|
Double.parseDouble(getText());
|
||||||
|
return true;
|
||||||
|
}catch(NumberFormatException e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFloat(){
|
||||||
|
return Float.parseFloat(getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFloat() {
|
||||||
|
try{
|
||||||
|
Float.parseFloat(getText());
|
||||||
|
return true;
|
||||||
|
}catch(NumberFormatException e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int i, int j, int k){
|
public void mouseClicked(int i, int j, int k){
|
||||||
if(!canEdit)
|
if(!canEdit)
|
||||||
@@ -85,30 +117,58 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unFocused(){
|
public void unFocused(){
|
||||||
if(numbersOnly){
|
if(integersOnly && !doublesOnly && !floatsOnly){
|
||||||
if(isEmpty() || !isInteger())
|
if(isEmpty() || !isInteger())
|
||||||
setText(def + "");
|
setText(def+"");
|
||||||
else if( getInteger() < min)
|
else if(getInteger() < min)
|
||||||
setText(min+"");
|
setText(min+"");
|
||||||
else if(getInteger() > max)
|
else if(getInteger() > max)
|
||||||
setText(max+"");
|
setText(max+"");
|
||||||
}
|
}
|
||||||
|
else if(doublesOnly && !floatsOnly){
|
||||||
|
if (isEmpty() || !isDouble())
|
||||||
|
setText(defDouble + "");
|
||||||
|
else if (getDouble() < minDouble)
|
||||||
|
setText(minDouble + "");
|
||||||
|
else if (getDouble() > maxDouble)
|
||||||
|
setText(maxDouble + "");
|
||||||
|
}
|
||||||
|
else if(floatsOnly){
|
||||||
|
if(isEmpty() || !isFloat())
|
||||||
|
setText(defFloat +"");
|
||||||
|
else if(getFloat() < minFloat)
|
||||||
|
setText(minFloat +"");
|
||||||
|
else if(getFloat() > maxFloat)
|
||||||
|
setText(maxFloat +"");
|
||||||
|
}
|
||||||
|
|
||||||
if(listener != null)
|
if(listener != null)
|
||||||
listener.unFocused(this);
|
listener.unFocused(this);
|
||||||
|
|
||||||
if(this == activeTextfield)
|
if(this == activeTextfield)
|
||||||
activeTextfield = null;
|
activeTextfield = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTextBox()
|
public void drawTextBox()
|
||||||
{
|
{
|
||||||
if(enabled)
|
if(enabled)
|
||||||
super.drawTextBox();
|
super.drawTextBox();
|
||||||
}
|
}
|
||||||
public void setMinMaxDefault(int i, int j, int k) {
|
public void setMinMaxDefault(int min, int max, int def) {
|
||||||
min = i;
|
this.min = min;
|
||||||
max = j;
|
this.max = max;
|
||||||
def = k;
|
this.def = def;
|
||||||
|
}
|
||||||
|
public void setMinMaxDefaultDouble(double min, double max, double def) {
|
||||||
|
minDouble = min;
|
||||||
|
maxDouble = max;
|
||||||
|
defDouble = def;
|
||||||
|
}
|
||||||
|
public void setMinMaxDefaultFloat(float min, float max, float def) {
|
||||||
|
minFloat = min;
|
||||||
|
maxFloat = max;
|
||||||
|
defFloat = def;
|
||||||
}
|
}
|
||||||
public static void unfocus() {
|
public static void unfocus() {
|
||||||
GuiNpcTextField prev = activeTextfield;
|
GuiNpcTextField prev = activeTextfield;
|
||||||
@@ -122,8 +182,17 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
drawTextBox();
|
drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiNpcTextField setNumbersOnly() {
|
public GuiNpcTextField setIntegersOnly() {
|
||||||
numbersOnly = true;
|
integersOnly = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiNpcTextField setDoublesOnly() {
|
||||||
|
doublesOnly = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public GuiNpcTextField setFloatsOnly() {
|
||||||
|
floatsOnly = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,17 +43,18 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
|
|
||||||
// New
|
// New
|
||||||
public ModelRenderer bipedBodywear;
|
public ModelRenderer bipedBodywear;
|
||||||
public ModelRenderer bipedRightArmwear;
|
public ModelRenderer bipedRightArmWear;
|
||||||
public ModelRenderer bipedLeftArmwear;
|
public ModelRenderer bipedLeftArmwear;
|
||||||
public ModelRenderer bipedRightLegWear;
|
public ModelRenderer bipedRightLegWear;
|
||||||
public ModelRenderer bipedLeftLegWear;
|
public ModelRenderer bipedLeftLegWear;
|
||||||
|
|
||||||
private ModelLegs legs;
|
private ModelLegs legs;
|
||||||
private ModelScaleRenderer headwear;
|
private ModelScaleRenderer headwear;
|
||||||
|
private ModelScaleRenderer bodywear;
|
||||||
// private ModelScaleRenderer bodywear;
|
private final ModelScaleRenderer solidLeftArmWear;
|
||||||
// private ModelScaleRenderer armwear;
|
private final ModelScaleRenderer solidRightArmWear;
|
||||||
// private ModelScaleRenderer legwear;
|
private final ModelScaleRenderer solidLeftLegWear;
|
||||||
|
private final ModelScaleRenderer solidRightLegWear;
|
||||||
|
|
||||||
private ModelTail tail;
|
private ModelTail tail;
|
||||||
public ModelBase entityModel;
|
public ModelBase entityModel;
|
||||||
@@ -110,15 +111,17 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1);
|
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1);
|
||||||
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
|
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
|
||||||
|
|
||||||
this.bipedRightArmwear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmwear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmwear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
// this.bipedRightArmWear.setRotationPoint(-5.0F, 2.5F + par2, 0.0F);
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
||||||
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
// this.bipedLeftArmWear.setRotationPoint(5.0F, 2.5F + par2, 0.0F);
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
||||||
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Steve Version
|
// Steve Version
|
||||||
@@ -130,15 +133,17 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1);
|
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1);
|
||||||
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
|
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
|
||||||
|
|
||||||
this.bipedRightArmwear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmwear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmwear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
//this.bipedRightArmWear.setRotationPoint(-5.0F, 2.0F + par2, 0.0F);
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
||||||
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
//this.bipedLeftArmWear.setRotationPoint(5.0F, 2.0F + par2, 0.0F);
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
||||||
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16));
|
this.bipedRightLeg = (new ModelScaleRenderer(this, 0, 16));
|
||||||
@@ -152,15 +157,19 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
||||||
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
||||||
// this.bipedRightLegWear.setRotationPoint(-1.9F, 12.0F + par2, 0.0F);
|
this.solidRightLegWear = new ModelLimbWear(this,"leg","right");
|
||||||
|
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
||||||
|
|
||||||
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
||||||
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
||||||
|
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left");
|
||||||
|
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
||||||
|
|
||||||
|
|
||||||
headwear = new ModelHeadwear(this);
|
headwear = new ModelHeadwear(this);
|
||||||
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 64);
|
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 64);
|
||||||
// bodywear = new ModelBodywear(this);
|
bodywear = new ModelBodywear(this);
|
||||||
|
|
||||||
this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 64));
|
this.bipedBody.addChild(breasts = new ModelBreasts(this, 64, 64));
|
||||||
if(!isArmor){
|
if(!isArmor){
|
||||||
@@ -235,16 +244,24 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedBody.addChild(this.bipedBodywear);
|
this.bipedBody.addChild(this.bipedBodywear);
|
||||||
|
|
||||||
// Arms
|
// Arms
|
||||||
this.bipedRightArmwear = (new ModelScaleRenderer(this, 0, 0));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 0, 0));
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmwear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
|
this.solidRightArmWear = (new ModelScaleRenderer(this, 0, 0));
|
||||||
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 0, 0);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 0, 0);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
|
this.solidLeftArmWear = (new ModelScaleRenderer(this, 0, 0));
|
||||||
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
|
|
||||||
// Legs
|
// Legs
|
||||||
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 0));
|
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 0));
|
||||||
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
||||||
|
this.solidRightLegWear = new ModelScaleRenderer(this, 0, 0);
|
||||||
|
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
||||||
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 0);
|
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 0);
|
||||||
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
||||||
|
this.solidLeftLegWear = new ModelScaleRenderer(this, 0, 0);
|
||||||
|
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
||||||
|
|
||||||
headwear = new ModelHeadwear(this, true);
|
headwear = new ModelHeadwear(this, true);
|
||||||
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 32);
|
legs = new ModelLegs(this, (ModelScaleRenderer)bipedRightLeg, (ModelScaleRenderer)bipedLeftLeg, 64, 32);
|
||||||
@@ -539,7 +556,24 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
((ModelScaleRenderer)this.bipedBody).isHidden = entity.modelData.hideBody == 1;
|
((ModelScaleRenderer)this.bipedBody).isHidden = entity.modelData.hideBody == 1;
|
||||||
|
|
||||||
// Hide Bodywear
|
// Hide Bodywear
|
||||||
((ModelScaleRenderer)this.bipedBodywear).isHidden = entity.modelData.bodywear != 1;
|
((ModelScaleRenderer)this.bipedBodywear).isHidden = entity.modelData.bodywear == 0;
|
||||||
|
|
||||||
|
if(bipedBodywear.showModel && !bipedBodywear.isHidden){
|
||||||
|
if(entity.modelData.bodywear == 1 || isArmor){
|
||||||
|
((ModelScaleRenderer)this.bipedBodywear).setConfig(entity.modelData.body,x,y,z);
|
||||||
|
((ModelScaleRenderer)this.bipedBodywear).render(f);
|
||||||
|
}
|
||||||
|
else if(entity.modelData.bodywear == 2){
|
||||||
|
this.bodywear.rotateAngleX = bipedBodywear.rotateAngleX;
|
||||||
|
this.bodywear.rotateAngleY = bipedBodywear.rotateAngleY;
|
||||||
|
this.bodywear.rotateAngleZ = bipedBodywear.rotateAngleZ;
|
||||||
|
this.bodywear.rotationPointX = bipedBodywear.rotationPointX;
|
||||||
|
this.bodywear.rotationPointY = bipedBodywear.rotationPointY;
|
||||||
|
this.bodywear.rotationPointZ = bipedBodywear.rotationPointZ;
|
||||||
|
this.bodywear.setConfig(entity.modelData.body,x,y,z);
|
||||||
|
this.bodywear.render(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
((ModelScaleRenderer)this.bipedBody).setConfig(body,x,y,z);
|
((ModelScaleRenderer)this.bipedBody).setConfig(body,x,y,z);
|
||||||
((ModelScaleRenderer)this.bipedBody).render(f);
|
((ModelScaleRenderer)this.bipedBody).render(f);
|
||||||
@@ -581,20 +615,31 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
|
|
||||||
// Hide Armwear
|
// Hide Armwear
|
||||||
if(entity.modelData.armwear == 1){
|
if(entity.modelData.armwear == 1){
|
||||||
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = false;
|
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3;
|
||||||
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = false;
|
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2;
|
||||||
|
|
||||||
|
this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2;
|
||||||
|
this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3;
|
||||||
}
|
}
|
||||||
else if(entity.modelData.armwear == 2){
|
else if(entity.modelData.armwear == 2){
|
||||||
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = true;
|
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true;
|
||||||
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = false;
|
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 2;
|
||||||
|
|
||||||
|
this.solidRightArmWear.isHidden = true;
|
||||||
|
this.solidLeftArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 3;
|
||||||
}
|
}
|
||||||
else if(entity.modelData.armwear == 3){
|
else if(entity.modelData.armwear == 3){
|
||||||
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = false;
|
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = entity.modelData.solidArmwear == 1 || entity.modelData.solidArmwear == 3;
|
||||||
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
|
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
|
||||||
|
|
||||||
|
this.solidRightArmWear.isHidden = entity.modelData.solidArmwear == 0 || entity.modelData.solidArmwear == 2;
|
||||||
|
this.solidLeftArmWear.isHidden = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
((ModelScaleRenderer)this.bipedRightArmwear).isHidden = true;
|
((ModelScaleRenderer)this.bipedRightArmWear).isHidden = true;
|
||||||
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
|
((ModelScaleRenderer)this.bipedLeftArmwear).isHidden = true;
|
||||||
|
this.solidRightArmWear.isHidden = true;
|
||||||
|
this.solidLeftArmWear.isHidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bo){
|
if(!bo){
|
||||||
@@ -641,20 +686,31 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
|
|
||||||
// Hide Legwear
|
// Hide Legwear
|
||||||
if(entity.modelData.legwear == 1){
|
if(entity.modelData.legwear == 1){
|
||||||
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = false;
|
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3;
|
||||||
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = false;
|
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2;
|
||||||
|
|
||||||
|
this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2;
|
||||||
|
this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3;
|
||||||
}
|
}
|
||||||
else if(entity.modelData.legwear == 2){
|
else if(entity.modelData.legwear == 2){
|
||||||
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
|
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
|
||||||
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = false;
|
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 2;
|
||||||
|
|
||||||
|
this.solidRightLegWear.isHidden = true;
|
||||||
|
this.solidLeftLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 3;
|
||||||
}
|
}
|
||||||
else if(entity.modelData.legwear == 3){
|
else if(entity.modelData.legwear == 3){
|
||||||
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = false;
|
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = entity.modelData.solidLegwear == 1 || entity.modelData.solidLegwear == 3;
|
||||||
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
|
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
|
||||||
|
|
||||||
|
this.solidRightLegWear.isHidden = entity.modelData.solidLegwear == 0 || entity.modelData.solidLegwear == 2;
|
||||||
|
this.solidLeftLegWear.isHidden = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
|
((ModelScaleRenderer)this.bipedRightLegWear).isHidden = true;
|
||||||
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
|
((ModelScaleRenderer)this.bipedLeftLegWear).isHidden = true;
|
||||||
|
this.solidRightLegWear.isHidden = true;
|
||||||
|
this.solidLeftLegWear.isHidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.legs.setConfig(legs,x,y,z);
|
this.legs.setConfig(legs,x,y,z);
|
||||||
|
|||||||
@@ -10,54 +10,47 @@ public class ModelBodywear extends ModelScaleRenderer{
|
|||||||
public ModelBodywear(ModelBase base) {
|
public ModelBodywear(ModelBase base) {
|
||||||
super(base);
|
super(base);
|
||||||
|
|
||||||
float scaler = 0.81f;
|
float thick = 0.50f;
|
||||||
float thick = 0.65f;
|
|
||||||
|
|
||||||
float x = -0.10f;
|
|
||||||
float y = 12.76f;
|
|
||||||
float z = -0.5f;
|
|
||||||
|
|
||||||
float z1 = 0.27f;
|
|
||||||
|
|
||||||
Model2DRenderer front = new Model2DRenderer(base, 20, 36, 8, 12, 64, 64);
|
Model2DRenderer front = new Model2DRenderer(base, 20, 36, 8, 12, 64, 64);
|
||||||
front.setRotationPoint(-4.588f, 0 + y, -2.302f + z);
|
front.setRotationPoint(-4.53f, 12.535f, -2.52f);
|
||||||
front.setScale(scaler);
|
front.setScale(0.85f,0.8175f);
|
||||||
front.setThickness(thick);
|
front.setThickness(thick);
|
||||||
setRotation(front, 0, 0, 0);
|
setRotation(front, 0, 0, 0);
|
||||||
this.addChild(front);
|
this.addChild(front);
|
||||||
|
|
||||||
Model2DRenderer back = new Model2DRenderer(base, 32, 36, 8, 12, 64, 64);
|
Model2DRenderer back = new Model2DRenderer(base, 32, 36, 8, 12, 64, 64);
|
||||||
back.setRotationPoint(4.588f, 0 + y, 2.302f);
|
back.setRotationPoint(4.53f, 12.535f, 2.52f);
|
||||||
back.setScale(scaler);
|
back.setScale(0.85f,0.8175f);
|
||||||
back.setThickness(thick);
|
back.setThickness(thick);
|
||||||
setRotation(back, 0, (float)(Math.PI), 0);
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 28, 36, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 28, 36, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(3.9425f, 0 + y, 2.29695f);
|
right.setRotationPoint(4.03f, 12.55f, 2.55f);
|
||||||
right.setScale(scaler);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 16, 36, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 16, 36, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-3.9425f, 0 + y, -2.29695f + z);
|
left.setRotationPoint(-4.03f, 12.55f, -2.55f);
|
||||||
left.setScale(scaler);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
Model2DRenderer top = new Model2DRenderer(base, 20, 32, 8, 4, 64, 64);
|
Model2DRenderer top = new Model2DRenderer(base, 20, 32, 8, 4, 64, 64);
|
||||||
top.setRotationPoint(-4.588f, -13.0f + y, -2.29695f);
|
top.setRotationPoint(-4.5f, -0.6f, -2.525f);
|
||||||
top.setScale(scaler/3);
|
top.setScale(0.2815f,0.315f);
|
||||||
top.setThickness(thick);
|
top.setThickness(thick);
|
||||||
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
this.addChild(top);
|
this.addChild(top);
|
||||||
|
|
||||||
Model2DRenderer bottom = new Model2DRenderer(base, 28, 32, 8, 4, 64, 64);
|
Model2DRenderer bottom = new Model2DRenderer(base, 28, 32, 8, 4, 64, 64);
|
||||||
bottom.setRotationPoint(-4.588f, -0.65f + y, -2.29695f);
|
bottom.setRotationPoint(-4.5f, 12.11f, -2.525f);
|
||||||
bottom.setScale(scaler/3);
|
bottom.setScale(0.2815f,0.315f);
|
||||||
bottom.setThickness(thick);
|
bottom.setThickness(thick);
|
||||||
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
this.addChild(bottom);
|
this.addChild(bottom);
|
||||||
|
|||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package noppes.npcs.client.model.part;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
import noppes.npcs.client.model.util.Model2DRenderer;
|
||||||
|
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||||
|
|
||||||
|
public class ModelLimbWear extends ModelScaleRenderer {
|
||||||
|
public ModelLimbWear(ModelBase base, String limb, String side) {
|
||||||
|
super(base);
|
||||||
|
|
||||||
|
float thick = 0.55f;
|
||||||
|
switch (limb){
|
||||||
|
case "arm":
|
||||||
|
switch (side){
|
||||||
|
case "right":
|
||||||
|
rightArm(base,thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftArm(base,thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "leg":
|
||||||
|
switch (side){
|
||||||
|
case "right":
|
||||||
|
rightLeg(base,thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftLeg(base,thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rightArm(ModelBase base, float thick){
|
||||||
|
float x = 0.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 44, 36, 4, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 52, 36, 4, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.1f+x, 12.55f+y, 2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-3.98f+x, 12.55f+y, -2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 48, 32, 4, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-4.5f+x, 12.0f+y, -2.525f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leftArm(ModelBase base,float thick){
|
||||||
|
float x = 2.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 52, 52, 4, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 60, 52, 4, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.06f+x, 12.55f+y, 2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 52, 48, 4, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 56, 48, 4, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-4.56f+x, 12.0f+y, -2.55f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rightLeg(ModelBase base, float thick){
|
||||||
|
float x = 1.8f;
|
||||||
|
float y = 0.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 4, 36, 4, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 12, 36, 4, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 4, 32, 4, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 8, 32, 4, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leftLeg(ModelBase base,float thick){
|
||||||
|
float x = 2.05f;
|
||||||
|
float y = 0.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 4, 52, 4, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-4.52f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 12, 52, 4, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.6f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 4, 48, 4, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-4.525f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 8, 48, 4, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-4.5f+x, 12.11f+y, -2.525f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(ModelRenderer model, float x, float y, float z) {
|
||||||
|
model.rotateAngleX = x;
|
||||||
|
model.rotateAngleY = y;
|
||||||
|
model.rotateAngleZ = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,7 +73,7 @@ public class RenderNPCInterface extends RenderLiving{
|
|||||||
|
|
||||||
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
|
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
|
||||||
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
|
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
|
||||||
if(!npc.isKilled())
|
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
|
||||||
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
|
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package noppes.npcs.constants;
|
package noppes.npcs.constants;
|
||||||
|
|
||||||
public enum EnumGuiType {
|
public enum EnumGuiType {
|
||||||
MainMenuDisplay, MainMenuInv, MainMenuStats, ManageFactions, MainMenuAdvanced, MainMenuGlobal, PlayerBankSmall, PlayerFollowerHire, PlayerFollower, SetupItemGiver, SetupTrader, SetupFollower, PlayerTrader, PlayerTransporter, RedstoneBlock, SetupTransporter, ManageTransport, ManageBanks, MobSpawner, SetupBank, ManageDialogs, ManageQuests, PlayerAnvil, QuestReward, ManageRecipes, QuestItem, NpcRemote, ScriptEvent, MoneyBag, MainMenuAI, MovingPath, PlayerBankUnlock, PlayerBankUprade, PlayerBankLarge, MobSpawnerAdd, PlayerMailbox, PlayerMailman, Waypoint, MerchantAdd, MobSpawnerMounter, Crate, NpcDimensions, Border, BigSign, Script, Companion, CompanionInv, CompanionTalent, CompanionTrader, ManageLinked
|
MainMenuDisplay, MainMenuInv, MainMenuStats, ManageFactions, MainMenuAdvanced, MainMenuGlobal, PlayerBankSmall, PlayerFollowerHire, PlayerFollower, SetupItemGiver, SetupTrader, SetupFollower, PlayerTrader, PlayerTransporter, RedstoneBlock, SetupTransporter, ManageTransport, ManageBanks, MobSpawner, SetupBank, ManageDialogs, ManageQuests, PlayerAnvil, QuestReward, ManageRecipes, QuestItem, NpcRemote, ScriptEvent, MoneyBag, MainMenuAI, MovingPath, PlayerBankUnlock, PlayerBankUprade, PlayerBankLarge, MobSpawnerAdd, PlayerMailbox, PlayerMailman, Waypoint, MerchantAdd, MobSpawnerMounter, Crate, NpcDimensions, Border, BigSign, Script, Companion, CompanionInv, CompanionTalent, CompanionTrader, ManageLinked, CustomGui;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,9 @@ public enum EnumPacketServer {
|
|||||||
RemoteTpToNpc,QuestGet, QuestCategoryGet,
|
RemoteTpToNpc,QuestGet, QuestCategoryGet,
|
||||||
SaveTileEntity,
|
SaveTileEntity,
|
||||||
NaturalSpawnGetAll, MailOpenSetup,
|
NaturalSpawnGetAll, MailOpenSetup,
|
||||||
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen;
|
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen,
|
||||||
|
|
||||||
|
CustomGuiButton,CustomGuiSlotChange,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused;
|
||||||
|
|
||||||
public CustomNpcsPermissions.Permission permission = null;
|
public CustomNpcsPermissions.Permission permission = null;
|
||||||
public boolean needsNpc = false;
|
public boolean needsNpc = false;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public enum EnumScriptType {
|
|||||||
TARGET("target"),
|
TARGET("target"),
|
||||||
COLLIDE("collide"),
|
COLLIDE("collide"),
|
||||||
KILLS("kills"),
|
KILLS("kills"),
|
||||||
DIALOG_OPTION("dialogOption"),
|
DIALOG_CLOSE("dialogClose"),
|
||||||
TIMER("timer"),
|
TIMER("timer"),
|
||||||
|
|
||||||
ATTACK_MELEE("meleeAttack"),
|
ATTACK_MELEE("meleeAttack"),
|
||||||
@@ -36,7 +36,6 @@ public enum EnumScriptType {
|
|||||||
LOGOUT("logout"),
|
LOGOUT("logout"),
|
||||||
CHAT("chat"),
|
CHAT("chat"),
|
||||||
DAMAGED_ENTITY("damagedEntity"),
|
DAMAGED_ENTITY("damagedEntity"),
|
||||||
DIALOG_CLOSE("dialogClose"),
|
|
||||||
SPAWN("spawn"),
|
SPAWN("spawn"),
|
||||||
TOSSED("tossed"),
|
TOSSED("tossed"),
|
||||||
PICKEDUP("pickedUp"),
|
PICKEDUP("pickedUp"),
|
||||||
@@ -44,10 +43,13 @@ public enum EnumScriptType {
|
|||||||
PROJECTILE_TICK("projectileTick"),
|
PROJECTILE_TICK("projectileTick"),
|
||||||
PROJECTILE_IMPACT("projectileImpact"),
|
PROJECTILE_IMPACT("projectileImpact"),
|
||||||
LEVEL_UP("levelUp"),
|
LEVEL_UP("levelUp"),
|
||||||
|
KEY_PRESSED("keyPressed"),
|
||||||
QUEST_START("questStart"),
|
QUEST_START("questStart"),
|
||||||
QUEST_COMPLETED("questCompleted"),
|
QUEST_COMPLETED("questCompleted"),
|
||||||
QUEST_TURNIN("questTurnIn"),
|
QUEST_TURNIN("questTurnIn"),
|
||||||
KEY_PRESSED("keyPressed"),
|
FACTION_POINTS("factionPoints"),
|
||||||
|
DIALOG_OPEN("dialogOpen"),
|
||||||
|
DIALOG_OPTION("dialogOption"),
|
||||||
CUSTOM_CHEST_CLOSED("customChestClosed"),
|
CUSTOM_CHEST_CLOSED("customChestClosed"),
|
||||||
CUSTOM_CHEST_CLICKED("customChestClicked"),
|
CUSTOM_CHEST_CLICKED("customChestClicked"),
|
||||||
SCRIPT_COMMAND("scriptCommand"),
|
SCRIPT_COMMAND("scriptCommand"),
|
||||||
@@ -55,6 +57,7 @@ public enum EnumScriptType {
|
|||||||
CUSTOM_GUI_BUTTON("customGuiButton"),
|
CUSTOM_GUI_BUTTON("customGuiButton"),
|
||||||
CUSTOM_GUI_SLOT("customGuiSlot"),
|
CUSTOM_GUI_SLOT("customGuiSlot"),
|
||||||
CUSTOM_GUI_SCROLL("customGuiScroll"),
|
CUSTOM_GUI_SCROLL("customGuiScroll"),
|
||||||
|
CUSTOM_GUI_TEXTFIELD("customGuiTextfield"),
|
||||||
PICKUP_XP("pickupXP"),
|
PICKUP_XP("pickupXP"),
|
||||||
MOUSE_CLICKED("mouseClicked"),
|
MOUSE_CLICKED("mouseClicked"),
|
||||||
START_USING_ITEM("startItem"),
|
START_USING_ITEM("startItem"),
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.containers;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import noppes.npcs.scripted.interfaces.IItemSlot;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGui;
|
||||||
|
import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
|
||||||
|
|
||||||
|
public class ContainerCustomGui extends Container {
|
||||||
|
public ScriptGui customGui;
|
||||||
|
public IInventory guiInventory;
|
||||||
|
int slotCount = 0;
|
||||||
|
|
||||||
|
public int playerInvX;
|
||||||
|
public int playerInvY;
|
||||||
|
|
||||||
|
public ContainerCustomGui(IInventory inventory) {
|
||||||
|
this.guiInventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGui(ScriptGui gui, EntityPlayer player) {
|
||||||
|
this.customGui = gui;
|
||||||
|
|
||||||
|
if (this.customGui.getShowPlayerInv()) {
|
||||||
|
this.addPlayerInventory(player, this.customGui.getPlayerInvX(), this.customGui.getPlayerInvY());
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var3 = this.customGui.getSlots().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
IItemSlot slot = (IItemSlot)var3.next();
|
||||||
|
if (slot.hasStack()) {
|
||||||
|
this.addSlot(slot.getPosX(), slot.getPosY(), slot.getStack().getMCItemStack(), player.worldObj.isRemote);
|
||||||
|
} else {
|
||||||
|
this.addSlot(slot.getPosX(), slot.getPosY(), player.worldObj.isRemote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
|
||||||
|
ItemStack itemstack = null;
|
||||||
|
Slot slot = (Slot)this.inventorySlots.get(index);
|
||||||
|
if (slot != null && slot.getHasStack()) {
|
||||||
|
ItemStack itemstack1 = slot.getStack();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
if (index < this.guiInventory.getSizeInventory()) {
|
||||||
|
if (!this.mergeItemStack(itemstack1, this.guiInventory.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (!this.mergeItemStack(itemstack1, 0, this.guiInventory.getSizeInventory(), false)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.stackSize <= 0) {
|
||||||
|
slot.putStack(null);
|
||||||
|
} else {
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addSlot(int x, int y, boolean clientSide) {
|
||||||
|
this.addSlotToContainer(new CustomGuiSlot(this.guiInventory, this.slotCount++, x, y, clientSide));
|
||||||
|
}
|
||||||
|
|
||||||
|
void addSlot(int x, int y, ItemStack itemStack, boolean clientSide) {
|
||||||
|
this.guiInventory.setInventorySlotContents(this.slotCount, itemStack);
|
||||||
|
this.addSlotToContainer(new CustomGuiSlot(this.guiInventory, this.slotCount++, x, y, clientSide));
|
||||||
|
}
|
||||||
|
|
||||||
|
void addPlayerInventory(EntityPlayer player, int x, int y) {
|
||||||
|
this.playerInvX = x;
|
||||||
|
this.playerInvY = y;
|
||||||
|
|
||||||
|
int row;
|
||||||
|
for(row = 0; row < 3; ++row) {
|
||||||
|
for(int col = 0; col < 9; ++col) {
|
||||||
|
this.addSlotToContainer(new Slot(player.inventory, col + row * 9 + 9, x + col * 18, y + row * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(row = 0; row < 9; ++row) {
|
||||||
|
this.addSlotToContainer(new Slot(player.inventory, row, x + row * 18, y + 58));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canDragIntoSlot(Slot p_94531_1_) { return true; }
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers;
|
|||||||
|
|
||||||
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.util.MathHelper;
|
||||||
import noppes.npcs.ICompatibilty;
|
import noppes.npcs.ICompatibilty;
|
||||||
import noppes.npcs.VersionCompatibility;
|
import noppes.npcs.VersionCompatibility;
|
||||||
import noppes.npcs.constants.EnumAvailabilityDialog;
|
import noppes.npcs.constants.EnumAvailabilityDialog;
|
||||||
@@ -9,8 +10,11 @@ import noppes.npcs.constants.EnumAvailabilityFaction;
|
|||||||
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
||||||
import noppes.npcs.constants.EnumAvailabilityQuest;
|
import noppes.npcs.constants.EnumAvailabilityQuest;
|
||||||
import noppes.npcs.constants.EnumDayTime;
|
import noppes.npcs.constants.EnumDayTime;
|
||||||
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
import noppes.npcs.scripted.handler.data.IAvailability;
|
||||||
|
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||||
|
|
||||||
public class Availability implements ICompatibilty {
|
public class Availability implements ICompatibilty, IAvailability {
|
||||||
public int version = VersionCompatibility.ModRev;
|
public int version = VersionCompatibility.ModRev;
|
||||||
|
|
||||||
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
|
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
|
||||||
@@ -178,7 +182,7 @@ public class Availability implements ICompatibilty {
|
|||||||
if(available == EnumAvailabilityFactionType.Always)
|
if(available == EnumAvailabilityFactionType.Always)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Faction faction = FactionController.getInstance().getFaction(id);
|
Faction faction = FactionController.getInstance().get(id);
|
||||||
if(faction == null)
|
if(faction == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -233,4 +237,170 @@ public class Availability implements ICompatibilty {
|
|||||||
public void setVersion(int version) {
|
public void setVersion(int version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAvailable(IPlayer player) {
|
||||||
|
return this.isAvailable((EntityPlayer)player.getMCEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDaytime() {
|
||||||
|
return this.daytime.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDaytime(int type) {
|
||||||
|
this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinPlayerLevel() {
|
||||||
|
return this.minPlayerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinPlayerLevel(int level) {
|
||||||
|
this.minPlayerLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDialog(int i) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else if (i == 0) {
|
||||||
|
return this.dialogId;
|
||||||
|
} else if (i == 1) {
|
||||||
|
return this.dialog2Id;
|
||||||
|
} else {
|
||||||
|
return i == 2 ? this.dialog3Id : this.dialog4Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDialog(int i, int id, int type) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else {
|
||||||
|
EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||||
|
if (i == 0) {
|
||||||
|
this.dialogId = id;
|
||||||
|
this.dialogAvailable = e;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.dialog2Id = id;
|
||||||
|
this.dialog2Available = e;
|
||||||
|
} else if (i == 2) {
|
||||||
|
this.dialog3Id = id;
|
||||||
|
this.dialog3Available = e;
|
||||||
|
} else if (i == 3) {
|
||||||
|
this.dialog4Id = id;
|
||||||
|
this.dialog4Available = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDialog(int i) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else {
|
||||||
|
if (i == 0) {
|
||||||
|
this.dialogId = -1;
|
||||||
|
this.dialogAvailable = EnumAvailabilityDialog.Always;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.dialog2Id = -1;
|
||||||
|
this.dialog2Available = EnumAvailabilityDialog.Always;
|
||||||
|
} else if (i == 2) {
|
||||||
|
this.dialog3Id = -1;
|
||||||
|
this.dialog3Available = EnumAvailabilityDialog.Always;
|
||||||
|
} else if (i == 3) {
|
||||||
|
this.dialog4Id = -1;
|
||||||
|
this.dialog4Available = EnumAvailabilityDialog.Always;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getQuest(int i) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else if (i == 0) {
|
||||||
|
return this.questId;
|
||||||
|
} else if (i == 1) {
|
||||||
|
return this.quest2Id;
|
||||||
|
} else {
|
||||||
|
return i == 2 ? this.quest3Id : this.quest4Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuest(int i, int id, int type) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else {
|
||||||
|
EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)];
|
||||||
|
if (i == 0) {
|
||||||
|
this.questId = id;
|
||||||
|
this.questAvailable = e;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.quest2Id = id;
|
||||||
|
this.quest2Available = e;
|
||||||
|
} else if (i == 2) {
|
||||||
|
this.quest3Id = id;
|
||||||
|
this.quest3Available = e;
|
||||||
|
} else if (i == 3) {
|
||||||
|
this.quest4Id = id;
|
||||||
|
this.quest4Available = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeQuest(int i) {
|
||||||
|
if (i < 0 && i > 3) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||||
|
} else {
|
||||||
|
if (i == 0) {
|
||||||
|
this.questId = -1;
|
||||||
|
this.questAvailable = EnumAvailabilityQuest.Always;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.quest2Id = -1;
|
||||||
|
this.quest2Available = EnumAvailabilityQuest.Always;
|
||||||
|
} else if (i == 2) {
|
||||||
|
this.quest3Id = -1;
|
||||||
|
this.quest3Available = EnumAvailabilityQuest.Always;
|
||||||
|
} else if (i == 3) {
|
||||||
|
this.quest4Id = -1;
|
||||||
|
this.quest4Available = EnumAvailabilityQuest.Always;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaction(int i, int id, int type, int stance) {
|
||||||
|
if (i < 0 && i > 1) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
|
||||||
|
} else {
|
||||||
|
EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||||
|
EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)];
|
||||||
|
if (i == 0) {
|
||||||
|
this.factionId = id;
|
||||||
|
this.factionAvailable = e;
|
||||||
|
this.factionStance = ee;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.faction2Id = id;
|
||||||
|
this.faction2Available = e;
|
||||||
|
this.faction2Stance = ee;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFaction(int i) {
|
||||||
|
if (i < 0 && i > 1) {
|
||||||
|
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
|
||||||
|
} else {
|
||||||
|
if (i == 0) {
|
||||||
|
this.factionId = -1;
|
||||||
|
this.factionAvailable = EnumAvailabilityFactionType.Always;
|
||||||
|
this.factionStance = EnumAvailabilityFaction.Friendly;
|
||||||
|
} else if (i == 1) {
|
||||||
|
this.faction2Id = -1;
|
||||||
|
this.faction2Available = EnumAvailabilityFactionType.Always;
|
||||||
|
this.faction2Stance = EnumAvailabilityFaction.Friendly;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.Server;
|
||||||
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.containers.ContainerCustomGui;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.CustomGuiEvent;
|
||||||
|
import noppes.npcs.scripted.gui.ScriptGui;
|
||||||
|
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CustomGuiController {
|
||||||
|
public CustomGuiController() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openGui(ScriptPlayer player, ScriptGui gui) {
|
||||||
|
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
|
||||||
|
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
|
||||||
|
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
|
||||||
|
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean updateGui(ScriptPlayer player, ScriptGui gui) {
|
||||||
|
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
|
||||||
|
Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean checkGui(CustomGuiEvent event) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
|
||||||
|
if (!(player.openContainer instanceof ContainerCustomGui)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return ((ContainerCustomGui)player.openContainer).customGui.getID() == event.gui.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IItemStack[] getSlotContents(EntityPlayer player) {
|
||||||
|
IItemStack[] slotContents = new IItemStack[0];
|
||||||
|
if (player.openContainer instanceof ContainerCustomGui) {
|
||||||
|
ContainerCustomGui container = (ContainerCustomGui)player.openContainer;
|
||||||
|
slotContents = new IItemStack[container.guiInventory.getSizeInventory()];
|
||||||
|
|
||||||
|
for(int i = 0; i < container.guiInventory.getSizeInventory(); ++i) {
|
||||||
|
slotContents[i] = NpcAPI.Instance().getIItemStack(container.guiInventory.getStackInSlot(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return slotContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onButton(CustomGuiEvent.ButtonEvent event) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
|
||||||
|
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
|
||||||
|
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onSlotChange(CustomGuiEvent.SlotEvent event) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
|
||||||
|
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
|
||||||
|
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SLOT, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onCustomGuiUnfocused(CustomGuiEvent.UnfocusedEvent event) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
|
||||||
|
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
|
||||||
|
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_TEXTFIELD, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onScrollClick(CustomGuiEvent.ScrollEvent event) {
|
||||||
|
EntityPlayer player = (EntityPlayer) event.player.getMCEntity();
|
||||||
|
if (checkGui(event) && getOpenGui(player).getScriptHandler() != null) {
|
||||||
|
getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onClose(CustomGuiEvent.CloseEvent event) {
|
||||||
|
if (ScriptController.Instance.playerScripts != null) {
|
||||||
|
ScriptController.Instance.playerScripts.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ScriptGui getOpenGui(EntityPlayer player) {
|
||||||
|
return player.openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)player.openContainer).customGui : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] readScrollSelection(ByteBuf buffer) {
|
||||||
|
try {
|
||||||
|
NBTTagList list = Server.readNBT(buffer).getTagList("selection", 8);
|
||||||
|
String[] selection = new String[list.tagCount()];
|
||||||
|
|
||||||
|
for(int i = 0; i < list.tagCount(); ++i) {
|
||||||
|
selection[i] = list.getStringTagAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selection;
|
||||||
|
} catch (IOException var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -8,8 +10,10 @@ import net.minecraft.nbt.NBTTagList;
|
|||||||
import noppes.npcs.ICompatibilty;
|
import noppes.npcs.ICompatibilty;
|
||||||
import noppes.npcs.VersionCompatibility;
|
import noppes.npcs.VersionCompatibility;
|
||||||
import noppes.npcs.constants.EnumOptionType;
|
import noppes.npcs.constants.EnumOptionType;
|
||||||
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
import noppes.npcs.scripted.handler.data.*;
|
||||||
|
|
||||||
public class Dialog implements ICompatibilty {
|
public class Dialog implements ICompatibilty, IDialog {
|
||||||
public int version = VersionCompatibility.ModRev;
|
public int version = VersionCompatibility.ModRev;
|
||||||
public int id = -1;
|
public int id = -1;
|
||||||
public String title = "";
|
public String title = "";
|
||||||
@@ -26,6 +30,7 @@ public class Dialog implements ICompatibilty {
|
|||||||
public boolean hideNPC = false;
|
public boolean hideNPC = false;
|
||||||
public boolean showWheel = false;
|
public boolean showWheel = false;
|
||||||
public boolean disableEsc = false;
|
public boolean disableEsc = false;
|
||||||
|
public boolean darkenScreen = true;
|
||||||
|
|
||||||
public boolean hasDialogs(EntityPlayer player) {
|
public boolean hasDialogs(EntityPlayer player) {
|
||||||
for(DialogOption option: options.values())
|
for(DialogOption option: options.values())
|
||||||
@@ -55,6 +60,7 @@ public class Dialog implements ICompatibilty {
|
|||||||
else
|
else
|
||||||
showWheel = true;
|
showWheel = true;
|
||||||
disableEsc = compound.getBoolean("DialogDisableEsc");
|
disableEsc = compound.getBoolean("DialogDisableEsc");
|
||||||
|
darkenScreen = compound.getBoolean("DialogDarkenScreen");
|
||||||
|
|
||||||
NBTTagList options = compound.getTagList("Options", 10);
|
NBTTagList options = compound.getTagList("Options", 10);
|
||||||
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
|
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
|
||||||
@@ -86,6 +92,7 @@ public class Dialog implements ICompatibilty {
|
|||||||
compound.setBoolean("DialogHideNPC", hideNPC);
|
compound.setBoolean("DialogHideNPC", hideNPC);
|
||||||
compound.setBoolean("DialogShowWheel", showWheel);
|
compound.setBoolean("DialogShowWheel", showWheel);
|
||||||
compound.setBoolean("DialogDisableEsc", disableEsc);
|
compound.setBoolean("DialogDisableEsc", disableEsc);
|
||||||
|
compound.setBoolean("DialogDarkenScreen", darkenScreen);
|
||||||
|
|
||||||
if(sound != null && !sound.isEmpty())
|
if(sound != null && !sound.isEmpty())
|
||||||
compound.setString("DialogSound", sound);
|
compound.setString("DialogSound", sound);
|
||||||
@@ -108,9 +115,7 @@ public class Dialog implements ICompatibilty {
|
|||||||
public boolean hasQuest() {
|
public boolean hasQuest() {
|
||||||
return getQuest() != null;
|
return getQuest() != null;
|
||||||
}
|
}
|
||||||
public Quest getQuest() {
|
|
||||||
return QuestController.instance.quests.get(quest);
|
|
||||||
}
|
|
||||||
public boolean hasOtherOptions() {
|
public boolean hasOtherOptions() {
|
||||||
for(DialogOption option: options.values())
|
for(DialogOption option: options.values())
|
||||||
if(option != null && option.optionType != EnumOptionType.Disabled)
|
if(option != null && option.optionType != EnumOptionType.Disabled)
|
||||||
@@ -131,6 +136,7 @@ public class Dialog implements ICompatibilty {
|
|||||||
dialog.hideNPC = hideNPC;
|
dialog.hideNPC = hideNPC;
|
||||||
dialog.showWheel = showWheel;
|
dialog.showWheel = showWheel;
|
||||||
dialog.disableEsc = disableEsc;
|
dialog.disableEsc = disableEsc;
|
||||||
|
dialog.darkenScreen = darkenScreen;
|
||||||
|
|
||||||
for(int slot : options.keySet()){
|
for(int slot : options.keySet()){
|
||||||
DialogOption option = options.get(slot);
|
DialogOption option = options.get(slot);
|
||||||
@@ -149,4 +155,73 @@ public class Dialog implements ICompatibilty {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IDialogOption> getOptions() {
|
||||||
|
return new ArrayList(this.options.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDialogOption getOption(int slot) {
|
||||||
|
IDialogOption option = (IDialogOption)this.options.get(slot);
|
||||||
|
if (option == null) {
|
||||||
|
throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]);
|
||||||
|
} else {
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAvailability getAvailability() {
|
||||||
|
return this.availability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDialogCategory getCategory() {
|
||||||
|
return this.category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
DialogController.instance.saveDialog(this.category.id, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.title = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return this.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuest(IQuest quest) {
|
||||||
|
if (quest == null) {
|
||||||
|
this.quest = -1;
|
||||||
|
} else {
|
||||||
|
if (quest.getId() < 0) {
|
||||||
|
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.quest = quest.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Quest getQuest() {
|
||||||
|
return QuestController.instance == null ? null : (Quest)QuestController.instance.quests.get(this.quest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommand() {
|
||||||
|
return this.command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommand(String command) {
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import noppes.npcs.scripted.handler.data.IDialog;
|
||||||
|
import noppes.npcs.scripted.handler.data.IDialogCategory;
|
||||||
|
|
||||||
public class DialogCategory {
|
public class DialogCategory implements IDialogCategory {
|
||||||
|
|
||||||
public int id = -1;
|
public int id = -1;
|
||||||
public String title = "";
|
public String title = "";
|
||||||
@@ -43,4 +47,18 @@ public class DialogCategory {
|
|||||||
nbtfactions.setTag("Dialogs", dialogs);
|
nbtfactions.setTag("Dialogs", dialogs);
|
||||||
return nbtfactions;
|
return nbtfactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IDialog> dialogs() {
|
||||||
|
return new ArrayList(this.dialogs.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDialog create() {
|
||||||
|
Dialog dialog = new Dialog();
|
||||||
|
dialog.category = this;
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,7 @@ package noppes.npcs.controllers;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -13,9 +11,12 @@ import noppes.npcs.CustomNpcs;
|
|||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.NoppesStringUtils;
|
import noppes.npcs.NoppesStringUtils;
|
||||||
import noppes.npcs.constants.EnumOptionType;
|
import noppes.npcs.constants.EnumOptionType;
|
||||||
|
import noppes.npcs.scripted.handler.IDialogHandler;
|
||||||
|
import noppes.npcs.scripted.handler.data.IDialog;
|
||||||
|
import noppes.npcs.scripted.handler.data.IDialogCategory;
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
public class DialogController {
|
public class DialogController implements IDialogHandler {
|
||||||
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
|
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
|
||||||
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||||
public static DialogController instance;
|
public static DialogController instance;
|
||||||
@@ -312,4 +313,12 @@ public class DialogController {
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IDialogCategory> categories() {
|
||||||
|
return new ArrayList(this.categories.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDialog get(int id) {
|
||||||
|
return (IDialog)this.dialogs.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
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.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
import noppes.npcs.scripted.handler.data.IFaction;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||||
|
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||||
|
|
||||||
public class Faction {
|
public class Faction implements IFaction {
|
||||||
public String name = "";
|
public String name = "";
|
||||||
public int color = Integer.parseInt("FF00", 16);
|
public int color = Integer.parseInt("FF00", 16);
|
||||||
|
|
||||||
@@ -85,4 +90,90 @@ public class Faction {
|
|||||||
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
|
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
|
||||||
return attackFactions.contains(entity.faction.id);
|
return attackFactions.contains(entity.faction.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultPoints() {
|
||||||
|
return this.defaultPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int playerStatus(IPlayer player) {
|
||||||
|
PlayerFactionData data = PlayerData.get((EntityPlayer) player.getMCEntity()).factionData;
|
||||||
|
int points = data.getFactionPoints(this.id);
|
||||||
|
if (points >= this.friendlyPoints) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return points < this.neutralPoints ? -1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hostileToNpc(ICustomNpc npc) {
|
||||||
|
return this.attackFactions.contains(npc.getFaction().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultPoints(int points) {
|
||||||
|
this.defaultPoints = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hostileToFaction(int factionId) {
|
||||||
|
return this.attackFactions.contains(factionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getHostileList() {
|
||||||
|
int[] a = new int[this.attackFactions.size()];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
Integer val;
|
||||||
|
for(Iterator var3 = this.attackFactions.iterator(); var3.hasNext(); a[i++] = val) {
|
||||||
|
val = (Integer)var3.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addHostile(int id) {
|
||||||
|
if (this.attackFactions.contains(id)) {
|
||||||
|
throw new CustomNPCsException("Faction " + this.id + " is already hostile to " + id, new Object[0]);
|
||||||
|
} else {
|
||||||
|
this.attackFactions.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeHostile(int id) {
|
||||||
|
this.attackFactions.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasHostile(int id) {
|
||||||
|
return this.attackFactions.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsHidden() {
|
||||||
|
return this.hideFaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsHidden(boolean bo) {
|
||||||
|
this.hideFaction = bo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAttackedByMobs() {
|
||||||
|
return this.getsAttacked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttackedByMobs(boolean bo) {
|
||||||
|
this.getsAttacked = bo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
FactionController.getInstance().saveFaction(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,9 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@@ -15,8 +17,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
|
import noppes.npcs.Server;
|
||||||
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
|
import noppes.npcs.scripted.handler.IFactionHandler;
|
||||||
|
import noppes.npcs.scripted.handler.data.IFaction;
|
||||||
|
|
||||||
public class FactionController {
|
public class FactionController implements IFactionHandler {
|
||||||
public HashMap<Integer,Faction> factions;
|
public HashMap<Integer,Faction> factions;
|
||||||
|
|
||||||
private static FactionController instance;
|
private static FactionController instance;
|
||||||
@@ -124,10 +130,14 @@ public class FactionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction(int faction) {
|
public Faction get(int faction) {
|
||||||
return factions.get(faction);
|
return factions.get(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<IFaction> list() {
|
||||||
|
return new ArrayList(this.factions.values());
|
||||||
|
}
|
||||||
|
|
||||||
public void saveFaction(Faction faction) {
|
public void saveFaction(Faction faction) {
|
||||||
|
|
||||||
if(faction.id < 0){
|
if(faction.id < 0){
|
||||||
@@ -146,6 +156,19 @@ public class FactionController {
|
|||||||
saveFactions();
|
saveFactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Faction create(Faction faction) {
|
||||||
|
this.saveFaction(faction);
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Faction create(String name, int color) {
|
||||||
|
Faction faction = new Faction();
|
||||||
|
faction.name = name;
|
||||||
|
faction.color = color;
|
||||||
|
this.saveFaction(faction);
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
|
||||||
public int getUnusedId(){
|
public int getUnusedId(){
|
||||||
if(lastUsedID == 0){
|
if(lastUsedID == 0){
|
||||||
for(int catid : factions.keySet())
|
for(int catid : factions.keySet())
|
||||||
@@ -155,11 +178,20 @@ public class FactionController {
|
|||||||
lastUsedID++;
|
lastUsedID++;
|
||||||
return lastUsedID;
|
return lastUsedID;
|
||||||
}
|
}
|
||||||
public void removeFaction(int id) {
|
public IFaction delete(int id) {
|
||||||
if(id < 0 || factions.size() <= 1)
|
if (id >= 0 && this.factions.size() > 1) {
|
||||||
return;
|
Faction faction = (Faction)this.factions.remove(id);
|
||||||
factions.remove(id);
|
saveFactions();
|
||||||
saveFactions();
|
if (faction == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
this.saveFactions();
|
||||||
|
faction.id = -1;
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstFactionId() {
|
public int getFirstFactionId() {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import noppes.npcs.EventHooks;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.FactionEvent;
|
||||||
|
|
||||||
public class FactionOptions {
|
public class FactionOptions {
|
||||||
|
|
||||||
@@ -52,7 +56,7 @@ public class FactionOptions {
|
|||||||
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
|
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
|
||||||
}
|
}
|
||||||
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
|
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
|
||||||
Faction faction = FactionController.getInstance().getFaction(factionId);
|
Faction faction = FactionController.getInstance().get(factionId);
|
||||||
if(faction == null)
|
if(faction == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -61,7 +65,7 @@ public class FactionOptions {
|
|||||||
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
|
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
|
||||||
}
|
}
|
||||||
|
|
||||||
data.increasePoints(factionId, decrease?-points:points);
|
data.increasePoints(factionId, decrease?-points:points,player);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,10 @@ package noppes.npcs.controllers;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import noppes.npcs.EventScriptContainer;
|
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
|
||||||
public interface IScriptHandler {
|
public interface IScriptHandler {
|
||||||
void callScript(EnumScriptType var1, Event var2, Object... obs);
|
void callScript(EnumScriptType var1, Event var2);
|
||||||
|
|
||||||
boolean isClient();
|
boolean isClient();
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ public interface IScriptHandler {
|
|||||||
|
|
||||||
void setLanguage(String var1);
|
void setLanguage(String var1);
|
||||||
|
|
||||||
List<EventScriptContainer> getScripts();
|
List<ScriptContainer> getScripts();
|
||||||
|
|
||||||
String noticeString();
|
String noticeString();
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
public PlayerFactionData factionData = new PlayerFactionData();
|
public PlayerFactionData factionData = new PlayerFactionData();
|
||||||
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData();
|
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData();
|
||||||
public PlayerMailData mailData = new PlayerMailData();
|
public PlayerMailData mailData = new PlayerMailData();
|
||||||
public PlayerDataScript scriptData;
|
|
||||||
public DataTimers timers = new DataTimers(this);
|
public DataTimers timers = new DataTimers(this);
|
||||||
|
|
||||||
public EntityNPCInterface editingNpc;
|
public EntityNPCInterface editingNpc;
|
||||||
@@ -232,7 +231,6 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
PlayerData data = new PlayerData();
|
PlayerData data = new PlayerData();
|
||||||
if (data.player == null) {
|
if (data.player == null) {
|
||||||
data.player = player;
|
data.player = player;
|
||||||
data.scriptData = new PlayerDataScript(player);
|
|
||||||
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
|
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
|
||||||
if (compound.hasNoTags()) {
|
if (compound.hasNoTags()) {
|
||||||
compound = loadPlayerDataOld(player.getCommandSenderName());
|
compound = loadPlayerDataOld(player.getCommandSenderName());
|
||||||
|
|||||||
Loaded 100 of 175 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user