mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 18:44:26 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5409e4e924 | ||
|
|
6573970840 | ||
|
|
efdd1d6679 | ||
|
|
4cca8e562c | ||
|
|
4c31236590 | ||
|
|
b62149d5f6 | ||
|
|
ff810cbc8d | ||
|
|
69d4fb20ff | ||
|
|
953f6e0459 | ||
|
|
1a78b2dad7 | ||
|
|
d46d0aba7e | ||
|
|
03ee733620 | ||
|
|
7d94e0e210 | ||
|
|
f03516b00f | ||
|
|
23384d1d67 | ||
|
|
6bdc68337c | ||
|
|
3a9789b3fd | ||
|
|
69b7a9aab4 | ||
|
|
9d9c481bdd | ||
|
|
98d2d943ae | ||
|
|
e9a4471cd2 | ||
|
|
934d5a69d6 | ||
|
|
12cb6a2937 | ||
|
|
cad275e845 | ||
|
|
816445bccd | ||
|
|
cf91d8638f | ||
|
|
03395ad750 | ||
|
|
f2da93451f | ||
|
|
00557df9a7 | ||
|
|
541958b630 | ||
|
|
eac3d2c214 | ||
|
|
ba0f21dc26 | ||
|
|
743cdb9db7 | ||
|
|
fc1c16032f | ||
|
|
b7d2dab905 | ||
|
|
9560228ba8 | ||
|
|
ba4bf107b5 | ||
|
|
81881e6e19 | ||
|
|
909f69575a | ||
|
|
34f6f670eb | ||
|
|
8c602c4d16 | ||
|
|
d66f532643 | ||
|
|
d37e986006 | ||
|
|
29db4bfe33 | ||
|
|
90eec7a57b | ||
|
|
94c7df410b | ||
|
|
c2564de470 | ||
|
|
2147bd00d0 | ||
|
|
922708bf97 | ||
|
|
43b3241801 | ||
|
|
12333de3a1 | ||
|
|
3cd1410c19 | ||
|
|
3c1bc30e44 | ||
|
|
cd5b4c0633 | ||
|
|
f14bc107d3 | ||
|
|
547f5ab82d | ||
|
|
23686dc3b8 | ||
|
|
44d4e74279 | ||
|
|
17eb612fb8 | ||
|
|
72869e6a78 | ||
|
|
e8dd3e7ddc | ||
|
|
3dd8a60702 | ||
|
|
71c81bce27 | ||
|
|
f39ed1fd37 | ||
|
|
f3ebf86b1e | ||
|
|
f64399e40d | ||
|
|
d79ec52994 | ||
|
|
3069488c54 | ||
|
|
24790b7952 | ||
|
|
edabe3890f | ||
|
|
ecbfd7dab0 | ||
|
|
d24422c3a1 | ||
|
|
8a7f40189e | ||
|
|
77c2897109 | ||
|
|
d5c13ae65f | ||
|
|
d2fe832508 | ||
|
|
03e4400b2e | ||
|
|
0d807b36d9 | ||
|
|
27b88c1fce | ||
|
|
40b39d3b20 | ||
|
|
70f1ff2613 | ||
|
|
6b2a9d92b1 | ||
|
|
2ffa9bfcfa | ||
|
|
27dce4a90a | ||
|
|
1478841098 | ||
|
|
6fcf566ef7 | ||
|
|
18aa2d099f | ||
|
|
b068c76fc8 | ||
|
|
a29058d696 | ||
|
|
d1c4adf371 | ||
|
|
4de969f6c9 | ||
|
|
a993c8feff | ||
|
|
5515f5ef83 | ||
|
|
8b710ed520 | ||
|
|
b15f5221fd | ||
|
|
40e738384f | ||
|
|
f88cbb8b51 | ||
|
|
c8f917d8fb | ||
|
|
bb1da8376d | ||
|
|
feeef71b5a | ||
|
|
15bfbcdbd1 | ||
|
|
72f2c3c60a | ||
|
|
c5ed7497c8 | ||
|
|
a9bce4a3e3 | ||
|
|
2d70b0091b | ||
|
|
047552d9e5 | ||
|
|
699182f4c0 | ||
|
|
6752f8baec | ||
|
|
6c8c7671b8 | ||
|
|
1ee14920ff | ||
|
|
6aa98aecf3 | ||
|
|
44bd1692d1 | ||
|
|
95d2814651 | ||
|
|
8b6e84a8d4 | ||
|
|
5a1c4757cf | ||
|
|
58a1ccc3e7 | ||
|
|
a5f9ec103f | ||
|
|
4ba0460a16 | ||
|
|
71e13a177f | ||
|
|
c39ebc4909 | ||
|
|
f6d9149038 | ||
|
|
50e3ae7f83 | ||
|
|
b43d89f91e | ||
|
|
1c2534bfc4 | ||
|
|
61ad3dc849 | ||
|
|
6e9c693d49 | ||
|
|
fbc22fdef2 | ||
|
|
9f4ab7f01e | ||
|
|
2a378190ae | ||
|
|
459976c54d |
No files matched your search
@@ -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.
+6
-1
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.2.2"
|
version = "1.4-beta"
|
||||||
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "CustomNPC-Plus"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
@@ -26,6 +26,9 @@ minecraft {
|
|||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// you may put jars on which you depend on in ./libs
|
// you may put jars on which you depend on in ./libs
|
||||||
// or you may define them like so..
|
// or you may define them like so..
|
||||||
@@ -61,3 +64,5 @@ processResources
|
|||||||
exclude 'mcmod.info'
|
exclude 'mcmod.info'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||||
@@ -4,7 +4,6 @@ import com.google.common.collect.AbstractIterator;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.util.Vec3i;
|
import net.minecraft.util.Vec3i;
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ import net.minecraft.util.Vec3i;
|
|||||||
public class BlockPos extends Vec3i{
|
public class BlockPos extends Vec3i{
|
||||||
/** The BlockPos with all coordinates 0 */
|
/** The BlockPos with all coordinates 0 */
|
||||||
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
||||||
private static final int NUM_X_BITS = 1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
|
private static final int NUM_X_BITS = 1 + 25;//MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
|
||||||
private static final int NUM_Z_BITS = NUM_X_BITS;
|
private static final int NUM_Z_BITS = NUM_X_BITS;
|
||||||
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
||||||
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
|
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.stats.Achievement;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.containers.ContainerCarpentryBench;
|
import noppes.npcs.containers.ContainerCarpentryBench;
|
||||||
@@ -28,8 +30,11 @@ import noppes.npcs.containers.ContainerNPCTraderSetup;
|
|||||||
import noppes.npcs.containers.ContainerNpcItemGiver;
|
import noppes.npcs.containers.ContainerNpcItemGiver;
|
||||||
import noppes.npcs.containers.ContainerNpcQuestReward;
|
import noppes.npcs.containers.ContainerNpcQuestReward;
|
||||||
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
||||||
|
import noppes.npcs.controllers.PlayerData;
|
||||||
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
|
||||||
public class CommonProxy implements IGuiHandler {
|
public class CommonProxy implements IGuiHandler {
|
||||||
|
|
||||||
@@ -41,6 +46,10 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerData getPlayerData(EntityPlayer player) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
if(ID > EnumGuiType.values().length)
|
if(ID > EnumGuiType.values().length)
|
||||||
@@ -55,31 +64,31 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
if(gui == EnumGuiType.PlayerBankSmall)
|
if(gui == EnumGuiType.PlayerBankSmall)
|
||||||
return new ContainerNPCBankSmall(player, x , y);
|
return new ContainerNPCBankSmall(player, x , y);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerBankUnlock)
|
if(gui == EnumGuiType.PlayerBankUnlock)
|
||||||
return new ContainerNPCBankUnlock(player, x , y);
|
return new ContainerNPCBankUnlock(player, x , y);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerBankUprade)
|
if(gui == EnumGuiType.PlayerBankUprade)
|
||||||
return new ContainerNPCBankUpgrade(player, x , y);
|
return new ContainerNPCBankUpgrade(player, x , y);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerBankLarge)
|
if(gui == EnumGuiType.PlayerBankLarge)
|
||||||
return new ContainerNPCBankLarge(player, x , y);
|
return new ContainerNPCBankLarge(player, x , y);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerFollowerHire)
|
if(gui == EnumGuiType.PlayerFollowerHire)
|
||||||
return new ContainerNPCFollowerHire(npc, player);
|
return new ContainerNPCFollowerHire(npc, player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerFollower)
|
if(gui == EnumGuiType.PlayerFollower)
|
||||||
return new ContainerNPCFollower(npc, player);
|
return new ContainerNPCFollower(npc, player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerTrader)
|
if(gui == EnumGuiType.PlayerTrader)
|
||||||
return new ContainerNPCTrader(npc, player);
|
return new ContainerNPCTrader(npc, player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerAnvil)
|
if(gui == EnumGuiType.PlayerAnvil)
|
||||||
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
|
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
|
||||||
|
|
||||||
if(gui == EnumGuiType.SetupItemGiver)
|
if(gui == EnumGuiType.SetupItemGiver)
|
||||||
return new ContainerNpcItemGiver(npc, player);
|
return new ContainerNpcItemGiver(npc, player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.SetupTrader)
|
if(gui == EnumGuiType.SetupTrader)
|
||||||
return new ContainerNPCTraderSetup(npc, player);
|
return new ContainerNPCTraderSetup(npc, player);
|
||||||
|
|
||||||
@@ -88,10 +97,10 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
if(gui == EnumGuiType.QuestReward)
|
if(gui == EnumGuiType.QuestReward)
|
||||||
return new ContainerNpcQuestReward(player);
|
return new ContainerNpcQuestReward(player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.QuestItem)
|
if(gui == EnumGuiType.QuestItem)
|
||||||
return new ContainerNpcQuestTypeItem(player);
|
return new ContainerNpcQuestTypeItem(player);
|
||||||
|
|
||||||
if(gui == EnumGuiType.ManageRecipes)
|
if(gui == EnumGuiType.ManageRecipes)
|
||||||
return new ContainerManageRecipes(player,x);
|
return new ContainerManageRecipes(player,x);
|
||||||
|
|
||||||
@@ -103,13 +112,13 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
if(gui == EnumGuiType.Crate)
|
if(gui == EnumGuiType.Crate)
|
||||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||||
|
|
||||||
if(gui == EnumGuiType.PlayerMailman)
|
if(gui == EnumGuiType.PlayerMailman)
|
||||||
return new ContainerMail(player, x == 1, y == 1);
|
return new ContainerMail(player, x == 1, y == 1);
|
||||||
|
|
||||||
if(gui == EnumGuiType.CompanionInv)
|
if(gui == EnumGuiType.CompanionInv)
|
||||||
return new ContainerNPCCompanion(npc, player);
|
return new ContainerNPCCompanion(npc, player);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,19 +138,21 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
|
|
||||||
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openGui(EntityPlayer player, Object guiscreen) {
|
public void openGui(EntityPlayer player, Object guiscreen) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
|
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FakePlayer getCommandPlayer(IWorld world) { return null; }
|
||||||
|
|
||||||
public boolean hasClient() {
|
public boolean hasClient() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -152,7 +163,7 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
|
|
||||||
public void registerItem(Item item) {
|
public void registerItem(Item item) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelBiped getSkirtModel() {
|
public ModelBiped getSkirtModel() {
|
||||||
@@ -160,8 +171,15 @@ public class CommonProxy implements IGuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawnParticle(String particle, double x, double y, double z,
|
public void spawnParticle(String particle, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float scale) {
|
double motionX, double motionY, double motionZ, float scale) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public String getAchievementDesc(Achievement achievement) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGUIOpen(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,8 +59,9 @@ import noppes.npcs.entity.old.EntityNpcMonsterMale;
|
|||||||
import noppes.npcs.entity.old.EntityNpcNagaFemale;
|
import noppes.npcs.entity.old.EntityNpcNagaFemale;
|
||||||
import noppes.npcs.entity.old.EntityNpcNagaMale;
|
import noppes.npcs.entity.old.EntityNpcNagaMale;
|
||||||
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.2.2")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.4-beta")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@ConfigProp(info = "Disable Chat Bubbles")
|
@ConfigProp(info = "Disable Chat Bubbles")
|
||||||
@@ -175,6 +176,11 @@ public class CustomNpcs {
|
|||||||
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
|
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new ScriptController());
|
MinecraftForge.EVENT_BUS.register(new ScriptController());
|
||||||
|
|
||||||
|
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
|
||||||
|
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
|
||||||
|
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler);
|
||||||
|
|
||||||
|
FMLCommonHandler.instance().bus().register(new ScriptForgeEventHandler().registerForgeEvents());
|
||||||
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
|
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
|
||||||
|
|
||||||
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
|
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
|
||||||
@@ -244,7 +250,10 @@ public class CustomNpcs {
|
|||||||
new SpawnController();
|
new SpawnController();
|
||||||
new LinkedNpcController();
|
new LinkedNpcController();
|
||||||
ScriptController.Instance.loadStoredData();
|
ScriptController.Instance.loadStoredData();
|
||||||
|
ScriptController.Instance.loadForgeScripts();
|
||||||
|
ScriptController.Instance.loadPlayerScripts();
|
||||||
ScriptController.HasStart = false;
|
ScriptController.HasStart = false;
|
||||||
|
WrapperNpcAPI.clearCache();
|
||||||
|
|
||||||
Set<String> names = Block.blockRegistry.getKeys();
|
Set<String> names = Block.blockRegistry.getKeys();
|
||||||
for(String name : names){
|
for(String name : names){
|
||||||
@@ -308,4 +317,33 @@ public class CustomNpcs {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File getWorldSaveDirectory(String s) {
|
||||||
|
try {
|
||||||
|
File dir = new File(".");
|
||||||
|
if (getServer() != null) {
|
||||||
|
if (!getServer().isDedicatedServer()) {
|
||||||
|
dir = new File(Minecraft.getMinecraft().mcDataDir, "saves");
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = new File(new File(dir, getServer().getFolderName()), "customnpcs");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s != null) {
|
||||||
|
dir = new File(dir, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
} catch (Exception var2) {
|
||||||
|
LogWriter.error("Error getting worldsave", var2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MinecraftServer getServer(){
|
||||||
|
return MinecraftServer.getServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,8 @@ 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 EnumAnimation animationType = EnumAnimation.NONE;
|
public EnumAnimation animationType = EnumAnimation.NONE;
|
||||||
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
||||||
@@ -96,8 +98,18 @@ 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");
|
||||||
|
|
||||||
startPos = compound.getIntArray("StartPosNew");
|
startPos = compound.getIntArray("StartPosNew");
|
||||||
if (startPos == null || startPos.length != 3){
|
if (startPos == null || startPos.length != 3){
|
||||||
startPos = new int[] {
|
startPos = new int[] {
|
||||||
@@ -143,8 +155,11 @@ 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);
|
||||||
|
|
||||||
npc.setAvoidWater(avoidsWater);
|
npc.setAvoidWater(avoidsWater);
|
||||||
|
|
||||||
compound.setIntArray("StartPosNew", npc.getStartPos());
|
compound.setIntArray("StartPosNew", npc.getStartPos());
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.nbt.NBTTagString;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
@@ -43,6 +50,8 @@ public class DataDisplay {
|
|||||||
|
|
||||||
public byte showBossBar = 0;
|
public byte showBossBar = 0;
|
||||||
|
|
||||||
|
public ArrayList<UUID> invisibleToList = new ArrayList<>();
|
||||||
|
|
||||||
public DataDisplay(EntityNPCInterface npc){
|
public DataDisplay(EntityNPCInterface npc){
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
|
|
||||||
@@ -78,7 +87,6 @@ public class DataDisplay {
|
|||||||
|
|
||||||
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() {
|
||||||
@@ -112,6 +120,13 @@ public class DataDisplay {
|
|||||||
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
||||||
nbttagcompound.setByte("BossBar", showBossBar);
|
nbttagcompound.setByte("BossBar", showBossBar);
|
||||||
|
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
for(UUID uuid : invisibleToList){
|
||||||
|
list.appendTag(new NBTTagString(uuid.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
nbttagcompound.setTag("InvisibleToList", list);
|
||||||
|
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
}
|
}
|
||||||
public void readToNBT(NBTTagCompound nbttagcompound) {
|
public void readToNBT(NBTTagCompound nbttagcompound) {
|
||||||
@@ -143,7 +158,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");
|
||||||
@@ -152,6 +167,18 @@ public class DataDisplay {
|
|||||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||||
showBossBar = nbttagcompound.getByte("BossBar");
|
showBossBar = nbttagcompound.getByte("BossBar");
|
||||||
|
|
||||||
|
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
|
||||||
|
if(tagList != null) {
|
||||||
|
invisibleToList.clear();
|
||||||
|
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||||
|
String nbtTagString = tagList.getStringTagAt(i);
|
||||||
|
invisibleToList.add(UUID.fromString(nbtTagString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
invisibleToList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
||||||
npc.textureLocation = null;
|
npc.textureLocation = null;
|
||||||
npc.textureGlowLocation = null;
|
npc.textureGlowLocation = null;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
@@ -12,18 +12,22 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.ScriptEvent;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.ScriptNpc;
|
import noppes.npcs.scripted.event.ScriptEvent;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
import noppes.npcs.scripted.ScriptWorld;
|
import noppes.npcs.scripted.ScriptWorld;
|
||||||
import noppes.npcs.scripted.constants.EntityType;
|
import noppes.npcs.scripted.constants.EntityType;
|
||||||
import noppes.npcs.scripted.constants.JobType;
|
import noppes.npcs.scripted.constants.JobType;
|
||||||
import noppes.npcs.scripted.constants.RoleType;
|
import noppes.npcs.scripted.constants.RoleType;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
public class DataScript {
|
public class DataScript implements IScriptHandler {
|
||||||
public Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
|
public List<ScriptContainer> scripts = new ArrayList();
|
||||||
private final static EntityType entities = new EntityType();
|
private final static EntityType entities = new EntityType();
|
||||||
private final static JobType jobs = new JobType();
|
private final static JobType jobs = new JobType();
|
||||||
private final static RoleType roles = new RoleType();
|
private final static RoleType roles = new RoleType();
|
||||||
@@ -33,17 +37,21 @@ public class DataScript {
|
|||||||
public boolean enabled = false;
|
public boolean enabled = false;
|
||||||
|
|
||||||
public ScriptNpc dummyNpc;
|
public ScriptNpc dummyNpc;
|
||||||
public ScriptWorld dummyWorld;
|
public IWorld dummyWorld;
|
||||||
public boolean clientNeedsUpdate = false;
|
public boolean clientNeedsUpdate = false;
|
||||||
public boolean aiNeedsUpdate = false;
|
public boolean aiNeedsUpdate = false;
|
||||||
public boolean hasInited = false;
|
public boolean hasInited = false;
|
||||||
|
|
||||||
public DataScript(EntityNPCInterface npc) {
|
public DataScript(EntityNPCInterface npc) {
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
scripts.add(new ScriptContainer(this));
|
||||||
|
}
|
||||||
|
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
if(npc instanceof EntityCustomNpc)
|
if(npc instanceof EntityCustomNpc)
|
||||||
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
|
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
|
||||||
if(npc.worldObj instanceof WorldServer)
|
if(npc.worldObj instanceof WorldServer)
|
||||||
dummyWorld = new ScriptWorld((WorldServer) npc.worldObj);
|
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
@@ -59,21 +67,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);
|
||||||
@@ -113,11 +125,7 @@ public class DataScript {
|
|||||||
|
|
||||||
return callScript(script);
|
return callScript(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled(){
|
|
||||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean callScript(ScriptContainer script){
|
private boolean callScript(ScriptContainer script){
|
||||||
ScriptEngine engine = script.engine;
|
ScriptEngine engine = script.engine;
|
||||||
engine.put("npc", dummyNpc);
|
engine.put("npc", dummyNpc);
|
||||||
@@ -125,11 +133,12 @@ public class DataScript {
|
|||||||
ScriptEvent result = (ScriptEvent) engine.get("event");
|
ScriptEvent result = (ScriptEvent) engine.get("event");
|
||||||
if(result == null)
|
if(result == null)
|
||||||
engine.put("event", result = new ScriptEvent());
|
engine.put("event", result = new ScriptEvent());
|
||||||
|
engine.put("API", new WrapperNpcAPI());
|
||||||
engine.put("EntityType", entities);
|
engine.put("EntityType", entities);
|
||||||
engine.put("RoleType", roles);
|
engine.put("RoleType", roles);
|
||||||
engine.put("JobType", jobs);
|
engine.put("JobType", jobs);
|
||||||
script.run(engine);
|
script.run(engine);
|
||||||
|
|
||||||
if(clientNeedsUpdate){
|
if(clientNeedsUpdate){
|
||||||
npc.updateClient = true;
|
npc.updateClient = true;
|
||||||
clientNeedsUpdate = false;
|
clientNeedsUpdate = false;
|
||||||
@@ -140,6 +149,78 @@ public class DataScript {
|
|||||||
}
|
}
|
||||||
return result.isCancelled();
|
return result.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled(){
|
||||||
|
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
Map<Long, String> map = new TreeMap();
|
||||||
|
int tab = 0;
|
||||||
|
Iterator var3 = this.getScripts().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var3.next();
|
||||||
|
++tab;
|
||||||
|
Iterator var5 = script.console.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var5.hasNext()) {
|
||||||
|
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
|
||||||
|
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearConsole() {
|
||||||
|
Iterator var1 = this.getScripts().iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var1.next();
|
||||||
|
script.console.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callScript(EnumScriptType var1, Event var2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClient() {
|
||||||
|
return this.npc.isRemote();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean bo) {
|
||||||
|
this.enabled = bo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return this.scriptLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLanguage(String lang) {
|
||||||
|
this.scriptLanguage = lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ScriptContainer> getScripts() {
|
||||||
|
return this.scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String noticeString() {
|
||||||
|
//BlockPos pos = this.npc.func_180425_c();
|
||||||
|
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public void setWorld(World world) {
|
public void setWorld(World world) {
|
||||||
if(world instanceof WorldServer)
|
if(world instanceof WorldServer)
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ import noppes.npcs.constants.EnumPotionType;
|
|||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.util.ValueUtil;
|
import noppes.npcs.util.ValueUtil;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class DataStats {
|
public class DataStats {
|
||||||
|
|
||||||
private int attackStrength = 5;
|
private float attackStrength = 5;
|
||||||
public int attackSpeed = 20, attackRange = 2, knockback = 0;
|
public int attackSpeed = 20, attackRange = 2, knockback = 0;
|
||||||
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
|
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
|
||||||
public int aggroRange = 16;
|
public int aggroRange = 16;
|
||||||
@@ -19,7 +22,7 @@ public class DataStats {
|
|||||||
public int potionDuration = 5; //20 = 1 second
|
public int potionDuration = 5; //20 = 1 second
|
||||||
public int potionAmp = 0;
|
public int potionAmp = 0;
|
||||||
|
|
||||||
public int maxHealth = 20;
|
public double maxHealth = 20;
|
||||||
public int respawnTime = 20;
|
public int respawnTime = 20;
|
||||||
public int spawnCycle = 0;
|
public int spawnCycle = 0;
|
||||||
public boolean hideKilledBody = false;
|
public boolean hideKilledBody = false;
|
||||||
@@ -32,10 +35,11 @@ public class DataStats {
|
|||||||
public boolean canDrown = true;
|
public boolean canDrown = true;
|
||||||
public boolean burnInSun = false;
|
public boolean burnInSun = false;
|
||||||
public boolean noFallDamage = false;
|
public boolean noFallDamage = false;
|
||||||
public int healthRegen = 1;
|
public float healthRegen = 1;
|
||||||
public int combatRegen = 0;
|
public float combatRegen = 0;
|
||||||
|
|
||||||
public int pDamage = 4, pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
|
public float pDamage = 4;
|
||||||
|
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
|
||||||
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
||||||
public boolean pRender3D = false, pSpin = false, pStick = false;
|
public boolean pRender3D = false, pSpin = false, pStick = false;
|
||||||
public EnumPotionType pEffect = EnumPotionType.None;
|
public EnumPotionType pEffect = EnumPotionType.None;
|
||||||
@@ -55,16 +59,16 @@ public class DataStats {
|
|||||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
compound.setTag("Resistances", resistances.writeToNBT());
|
compound.setTag("Resistances", resistances.writeToNBT());
|
||||||
compound.setInteger("MaxHealth", maxHealth);
|
compound.setDouble("MaxHealth", maxHealth);
|
||||||
compound.setInteger("AggroRange", aggroRange);
|
compound.setInteger("AggroRange", aggroRange);
|
||||||
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
|
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
|
||||||
compound.setInteger("RespawnTime", respawnTime);
|
compound.setInteger("RespawnTime", respawnTime);
|
||||||
compound.setInteger("SpawnCycle", spawnCycle);
|
compound.setInteger("SpawnCycle", spawnCycle);
|
||||||
compound.setInteger("CreatureType", creatureType.ordinal());
|
compound.setInteger("CreatureType", creatureType.ordinal());
|
||||||
compound.setInteger("HealthRegen", healthRegen);
|
compound.setFloat("HealthRegen", healthRegen);
|
||||||
compound.setInteger("CombatRegen", combatRegen);
|
compound.setFloat("CombatRegen", combatRegen);
|
||||||
|
|
||||||
compound.setInteger("AttackStrenght", attackStrength);
|
compound.setFloat("AttackStrenght", attackStrength);
|
||||||
compound.setInteger("AttackRange", attackRange);
|
compound.setInteger("AttackRange", attackRange);
|
||||||
compound.setInteger("AttackSpeed", attackSpeed);
|
compound.setInteger("AttackSpeed", attackSpeed);
|
||||||
compound.setInteger("KnockBack", knockback);
|
compound.setInteger("KnockBack", knockback);
|
||||||
@@ -80,7 +84,7 @@ public class DataStats {
|
|||||||
compound.setInteger("ShotCount", shotCount);
|
compound.setInteger("ShotCount", shotCount);
|
||||||
compound.setInteger("Accuracy", accuracy);
|
compound.setInteger("Accuracy", accuracy);
|
||||||
|
|
||||||
compound.setInteger("pDamage", pDamage);
|
compound.setFloat("pDamage", pDamage);
|
||||||
compound.setInteger("pImpact", pImpact);
|
compound.setInteger("pImpact", pImpact);
|
||||||
compound.setInteger("pSize", pSize);
|
compound.setInteger("pSize", pSize);
|
||||||
compound.setInteger("pSpeed", pSpeed);
|
compound.setInteger("pSpeed", pSpeed);
|
||||||
@@ -113,16 +117,16 @@ public class DataStats {
|
|||||||
public void readToNBT(NBTTagCompound compound)
|
public void readToNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
resistances.readToNBT(compound.getCompoundTag("Resistances"));
|
resistances.readToNBT(compound.getCompoundTag("Resistances"));
|
||||||
setMaxHealth(compound.getInteger("MaxHealth"));
|
setMaxHealth(compound.getDouble("MaxHealth"));
|
||||||
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
|
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
|
||||||
aggroRange = compound.getInteger("AggroRange");
|
aggroRange = compound.getInteger("AggroRange");
|
||||||
respawnTime = compound.getInteger("RespawnTime");
|
respawnTime = compound.getInteger("RespawnTime");
|
||||||
spawnCycle = compound.getInteger("SpawnCycle");
|
spawnCycle = compound.getInteger("SpawnCycle");
|
||||||
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
||||||
healthRegen = compound.getInteger("HealthRegen");
|
healthRegen = compound.getFloat("HealthRegen");
|
||||||
combatRegen = compound.getInteger("CombatRegen");
|
combatRegen = compound.getFloat("CombatRegen");
|
||||||
|
|
||||||
setAttackStrength(compound.getInteger("AttackStrenght"));
|
setAttackStrength(compound.getFloat("AttackStrenght"));
|
||||||
attackSpeed = compound.getInteger("AttackSpeed");
|
attackSpeed = compound.getInteger("AttackSpeed");
|
||||||
attackRange = compound.getInteger("AttackRange");
|
attackRange = compound.getInteger("AttackRange");
|
||||||
knockback = compound.getInteger("KnockBack");
|
knockback = compound.getInteger("KnockBack");
|
||||||
@@ -138,7 +142,7 @@ public class DataStats {
|
|||||||
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
|
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
|
||||||
accuracy = compound.getInteger("Accuracy");
|
accuracy = compound.getInteger("Accuracy");
|
||||||
|
|
||||||
pDamage = compound.getInteger("pDamage");
|
pDamage = compound.getFloat("pDamage");
|
||||||
pImpact = compound.getInteger("pImpact");
|
pImpact = compound.getInteger("pImpact");
|
||||||
pSize = compound.getInteger("pSize");
|
pSize = compound.getInteger("pSize");
|
||||||
pSpeed = compound.getInteger("pSpeed");
|
pSpeed = compound.getInteger("pSpeed");
|
||||||
@@ -168,16 +172,16 @@ public class DataStats {
|
|||||||
npc.setImmuneToFire(immuneToFire);
|
npc.setImmuneToFire(immuneToFire);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAttackStrength(){
|
public float getAttackStrength(){
|
||||||
return attackStrength;
|
return attackStrength;
|
||||||
}
|
}
|
||||||
public void setAttackStrength(int strength){
|
public void setAttackStrength(float strength){
|
||||||
attackStrength = strength;
|
attackStrength = (float)(Math.floor(strength));
|
||||||
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHealth(int maxHealth) {
|
public void setMaxHealth(double maxHealth) {
|
||||||
this.maxHealth = maxHealth;
|
this.maxHealth = Math.floor(maxHealth);
|
||||||
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
|
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.*;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.*;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.KeyPressedEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.LoginEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent.DropEvent;
|
||||||
|
import noppes.npcs.scripted.interfaces.IEntity;
|
||||||
|
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.controllers.PlayerData;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class EventHooks {
|
||||||
|
public EventHooks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
||||||
|
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||||
|
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||||
|
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.INIT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.TICK, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.INTERACT, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.START_USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
|
||||||
|
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
|
||||||
|
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
|
||||||
|
IItemStack[] items = new IItemStack[entityItems.size()];
|
||||||
|
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
|
||||||
|
|
||||||
|
DropEvent event = new DropEvent(player, items);
|
||||||
|
handler.callScript(EnumScriptType.DROP, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
|
||||||
|
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
|
||||||
|
handler.callScript(EnumScriptType.PICKUP_XP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
|
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
|
handler.callScript(EnumScriptType.TOSS, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
|
||||||
|
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
|
||||||
|
handler.callScript(EnumScriptType.PICKUP, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
|
||||||
|
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
|
||||||
|
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
|
||||||
|
handler.callScript(EnumScriptType.USE_HOE, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
|
||||||
|
handler.callScript(EnumScriptType.SLEEP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
|
||||||
|
handler.callScript(EnumScriptType.WAKE_UP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
|
||||||
|
handler.callScript(EnumScriptType.KILLED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
|
||||||
|
handler.callScript(EnumScriptType.KILLS, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.DAMAGED, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LIGHTNING, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
|
||||||
|
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
|
||||||
|
handler.callScript(EnumScriptType.PLAYSOUND, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
|
||||||
|
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
|
||||||
|
handler.callScript(EnumScriptType.FALL, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.JUMP, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
LoginEvent event = new LoginEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LOGIN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
|
||||||
|
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
|
||||||
|
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
|
||||||
|
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
|
||||||
|
handler.callScript(EnumScriptType.FILL_BUCKET, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
|
||||||
|
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
|
||||||
|
handler.callScript(EnumScriptType.BONEMEAL, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.RESPAWN, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
|
||||||
|
LogoutEvent event = new LogoutEvent(player);
|
||||||
|
handler.callScript(EnumScriptType.LOGOUT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.CHAT, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
|
||||||
|
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
|
||||||
|
handler.callScript(EnumScriptType.CHANGED_DIM, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
|
||||||
|
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown);
|
||||||
|
handler.callScript(EnumScriptType.KEY_PRESSED, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onPlayerTimer(PlayerData data, int id) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
|
||||||
|
handler.callScript(EnumScriptType.TIMER, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
|
||||||
|
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
|
||||||
|
return WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeEntityEvent(EntityEvent event) {
|
||||||
|
IEntity e = NpcAPI.Instance().getIEntity(event.entity);
|
||||||
|
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeWorldEvent(WorldEvent event) {
|
||||||
|
if(ScriptController.Instance.forgeScripts.isEnabled()) {
|
||||||
|
IWorld e = NpcAPI.Instance().getIWorld((WorldServer)event.world);
|
||||||
|
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeInit(ForgeDataScript handler) {
|
||||||
|
noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent();
|
||||||
|
handler.callScript("init", event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onForgeEvent(ForgeEvent ev, Event event) {
|
||||||
|
ForgeDataScript handler = ScriptController.Instance.forgeScripts;
|
||||||
|
if(handler.isEnabled()) {
|
||||||
|
String eventName = event.getClass().getName();
|
||||||
|
int i = eventName.lastIndexOf(".");
|
||||||
|
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
||||||
|
if(event.isCancelable()) {
|
||||||
|
ev.setCanceled(event.isCanceled());
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.callScript(eventName, event);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(ev);
|
||||||
|
if(event.isCancelable()) {
|
||||||
|
event.setCanceled(ev.isCanceled());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,9 @@ public class ModelPartData {
|
|||||||
public String texture;
|
public String texture;
|
||||||
public byte type = 0;
|
public byte type = 0;
|
||||||
public boolean playerTexture;
|
public boolean playerTexture;
|
||||||
|
|
||||||
private ResourceLocation location;
|
private ResourceLocation location;
|
||||||
|
|
||||||
public ModelPartData(){
|
public ModelPartData(){
|
||||||
playerTexture = true;
|
playerTexture = true;
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ public class ModelPartData {
|
|||||||
compound.setBoolean("PlayerTexture", playerTexture);
|
compound.setBoolean("PlayerTexture", playerTexture);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound){
|
public void readFromNBT(NBTTagCompound compound){
|
||||||
type = compound.getByte("Type");
|
type = compound.getByte("Type");
|
||||||
color = compound.getInteger("Color");
|
color = compound.getInteger("Color");
|
||||||
@@ -37,13 +37,13 @@ public class ModelPartData {
|
|||||||
playerTexture = compound.getBoolean("PlayerTexture");
|
playerTexture = compound.getBoolean("PlayerTexture");
|
||||||
location = null;
|
location = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getResource(){
|
public ResourceLocation getResource(){
|
||||||
if(texture.isEmpty())
|
if(texture.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
if(location != null)
|
if(location != null)
|
||||||
return location;
|
return location;
|
||||||
location = new ResourceLocation(texture);
|
location = new ResourceLocation(texture);
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class ModelPartData {
|
|||||||
playerTexture = false;
|
playerTexture = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Color: " + color + " Type: " + type;
|
return "Color: " + color + " Type: " + type;
|
||||||
}
|
}
|
||||||
@@ -67,9 +67,9 @@ public class ModelPartData {
|
|||||||
public String getColor() {
|
public String getColor() {
|
||||||
String str = Integer.toHexString(color);
|
String str = Integer.toHexString(color);
|
||||||
|
|
||||||
while(str.length() < 6)
|
while(str.length() < 6)
|
||||||
str = "0" + str;
|
str = "0" + str;
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagDouble;
|
import net.minecraft.nbt.NBTTagDouble;
|
||||||
import net.minecraft.nbt.NBTTagInt;
|
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
|
||||||
public class NBTTags {
|
public class NBTTags {
|
||||||
|
|
||||||
@@ -383,4 +379,60 @@ public class NBTTags {
|
|||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TreeMap<Long, String> GetLongStringMap(NBTTagList tagList) {
|
||||||
|
TreeMap list = new TreeMap();
|
||||||
|
|
||||||
|
for(int i = 0; i < tagList.tagCount(); ++i) {
|
||||||
|
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||||
|
list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagList NBTLongStringMap(Map<Long, String> map) {
|
||||||
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
|
if(map == null) {
|
||||||
|
return nbttaglist;
|
||||||
|
} else {
|
||||||
|
Iterator var2 = map.keySet().iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
long slot = ((Long)var2.next()).longValue();
|
||||||
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||||
|
nbttagcompound.setLong("Long", slot);
|
||||||
|
nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot)));
|
||||||
|
nbttaglist.appendTag(nbttagcompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nbttaglist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
|
||||||
|
ArrayList scripts = new ArrayList();
|
||||||
|
|
||||||
|
for(int i = 0; i < list.tagCount(); ++i) {
|
||||||
|
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||||
|
ScriptContainer script = new ScriptContainer(handler);
|
||||||
|
script.readFromNBT(compoundd);
|
||||||
|
scripts.add(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
return scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
Iterator var2 = scripts.iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var2.next();
|
||||||
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
script.writeToNBT(compound);
|
||||||
|
list.appendTag(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,28 @@ public class NoppesUtilPlayer {
|
|||||||
}
|
}
|
||||||
player.worldObj.updateEntityWithOptionalForce(player, false);
|
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, float yaw, float pitch, int dimension){
|
||||||
|
if(player.dimension != dimension){
|
||||||
|
int dim = player.dimension;
|
||||||
|
MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
WorldServer wor = server.worldServerForDimension(dimension);
|
||||||
|
if(wor == null){
|
||||||
|
player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.setLocationAndAngles(posX, posY, posZ, yaw, pitch);
|
||||||
|
server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor));
|
||||||
|
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
|
||||||
|
|
||||||
|
if(!wor.playerEntities.contains(player))
|
||||||
|
wor.spawnEntityInWorld(player);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, yaw, pitch);
|
||||||
|
}
|
||||||
|
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||||
|
}
|
||||||
|
|
||||||
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
||||||
ItemStack currency = currencyInv.getStackInSlot(0);
|
ItemStack currency = currencyInv.getStackInSlot(0);
|
||||||
@@ -375,5 +397,7 @@ public class NoppesUtilPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void isGUIOpen(EntityPlayerMP player){
|
||||||
|
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
import net.minecraft.command.server.CommandBlockLogic;
|
import net.minecraft.command.server.CommandBlockLogic;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
@@ -21,6 +22,8 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
|
import net.minecraft.entity.projectile.EntityThrowable;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -31,8 +34,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import noppes.npcs.constants.EnumGuiType;
|
import noppes.npcs.constants.EnumGuiType;
|
||||||
import noppes.npcs.constants.EnumPacketClient;
|
import noppes.npcs.constants.EnumPacketClient;
|
||||||
@@ -69,7 +72,7 @@ import noppes.npcs.controllers.TransportLocation;
|
|||||||
import noppes.npcs.entity.EntityDialogNpc;
|
import noppes.npcs.entity.EntityDialogNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.RoleTransporter;
|
import noppes.npcs.roles.RoleTransporter;
|
||||||
import noppes.npcs.scripted.ScriptEventDialog;
|
import noppes.npcs.scripted.event.ScriptEventDialog;
|
||||||
|
|
||||||
public class NoppesUtilServer {
|
public class NoppesUtilServer {
|
||||||
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
||||||
@@ -216,6 +219,19 @@ public class NoppesUtilServer {
|
|||||||
logic.func_145754_b("@"+name);
|
logic.func_145754_b("@"+name);
|
||||||
logic.func_145755_a(executer.worldObj);
|
logic.func_145755_a(executer.worldObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runCommand(World world, String name, String command) {
|
||||||
|
TileEntityCommandBlock tile = new TileEntityCommandBlock();
|
||||||
|
tile.setWorldObj(world.provider.worldObj);
|
||||||
|
tile.xCoord = 0;
|
||||||
|
tile.yCoord = 0;
|
||||||
|
tile.zCoord = 0;
|
||||||
|
|
||||||
|
CommandBlockLogic logic = tile.func_145993_a();
|
||||||
|
logic.func_145752_a(command);
|
||||||
|
logic.func_145754_b("@"+name);
|
||||||
|
logic.func_145755_a(world);
|
||||||
|
}
|
||||||
|
|
||||||
public static void consumeItemStack(int i, EntityPlayer player){
|
public static void consumeItemStack(int i, EntityPlayer player){
|
||||||
ItemStack item = player.inventory.getCurrentItem();
|
ItemStack item = player.inventory.getCurrentItem();
|
||||||
@@ -291,6 +307,22 @@ public class NoppesUtilServer {
|
|||||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void spawnScriptedParticle(Entity entity, String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
int entityID
|
||||||
|
){
|
||||||
|
Server.sendAssociatedData(entity, EnumPacketClient.SCRIPTED_PARTICLE,
|
||||||
|
directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
||||||
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
||||||
@@ -658,4 +690,25 @@ public class NoppesUtilServer {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Entity GetDamageSourcee(DamageSource damagesource) {
|
||||||
|
Object entity = damagesource.getEntity();
|
||||||
|
if(entity == null) {
|
||||||
|
entity = damagesource.getSourceOfDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity instanceof EntityLivingBase) {
|
||||||
|
entity = ((EntityArrow)entity).shootingEntity;
|
||||||
|
} else if(entity instanceof EntityThrowable) {
|
||||||
|
entity = ((EntityThrowable)entity).getThrower();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Entity)entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException {
|
||||||
|
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||||
|
boolean isGUIOpen = buffer.readBoolean();
|
||||||
|
playerdata.setGUIOpen(isGUIOpen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,13 +22,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
|||||||
import noppes.npcs.constants.EnumPlayerPacket;
|
import noppes.npcs.constants.EnumPlayerPacket;
|
||||||
import noppes.npcs.constants.EnumRoleType;
|
import noppes.npcs.constants.EnumRoleType;
|
||||||
import noppes.npcs.containers.ContainerMail;
|
import noppes.npcs.containers.ContainerMail;
|
||||||
import noppes.npcs.controllers.BankData;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.PlayerFactionData;
|
|
||||||
import noppes.npcs.controllers.PlayerMail;
|
|
||||||
import noppes.npcs.controllers.PlayerMailData;
|
|
||||||
import noppes.npcs.controllers.PlayerQuestController;
|
|
||||||
import noppes.npcs.controllers.PlayerQuestData;
|
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.RoleCompanion;
|
import noppes.npcs.roles.RoleCompanion;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -67,17 +61,31 @@ public class PacketHandlerPlayer{
|
|||||||
return;
|
return;
|
||||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPlayerPacket.KeyPressed) {
|
||||||
|
if(ScriptController.Instance.languages.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onPlayerKeyPressed(player, buffer.readInt(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean());
|
||||||
|
}
|
||||||
|
else if(type == EnumPlayerPacket.MouseClicked) {
|
||||||
|
if(ScriptController.Instance.languages.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onPlayerMouseClicked(player, buffer.readInt(), buffer.readInt(), buffer.readBoolean());
|
||||||
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerHire){
|
else if(type == EnumPlayerPacket.FollowerHire){
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||||
return;
|
return;
|
||||||
NoppesUtilPlayer.hireFollower(player,npc);
|
NoppesUtilPlayer.hireFollower(player, npc);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerExtend){
|
else if(type == EnumPlayerPacket.FollowerExtend){
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||||
return;
|
return;
|
||||||
NoppesUtilPlayer.extendFollower(player,npc);
|
NoppesUtilPlayer.extendFollower(player, npc);
|
||||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FollowerState){
|
else if(type == EnumPlayerPacket.FollowerState){
|
||||||
@@ -124,17 +132,17 @@ public class PacketHandlerPlayer{
|
|||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
if(npc == null)
|
if(npc == null)
|
||||||
return;
|
return;
|
||||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(),buffer.readInt(),player,npc);
|
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||||
playerdata.checkQuestCompletion(player,null);
|
playerdata.checkQuestCompletion(player, null);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.QuestLog){
|
else if(type == EnumPlayerPacket.QuestLog){
|
||||||
NoppesUtilPlayer.sendQuestLogData(player);
|
NoppesUtilPlayer.sendQuestLogData(player);
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.QuestCompletion){
|
else if(type == EnumPlayerPacket.QuestCompletion){
|
||||||
NoppesUtilPlayer.questCompletion(player,buffer.readInt());
|
NoppesUtilPlayer.questCompletion(player, buffer.readInt());
|
||||||
}
|
}
|
||||||
else if(type == EnumPlayerPacket.FactionsGet){
|
else if(type == EnumPlayerPacket.FactionsGet){
|
||||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
import net.minecraft.entity.passive.EntityVillager;
|
||||||
@@ -62,6 +61,8 @@ import noppes.npcs.controllers.SpawnController;
|
|||||||
import noppes.npcs.controllers.SpawnData;
|
import noppes.npcs.controllers.SpawnData;
|
||||||
import noppes.npcs.controllers.TransportController;
|
import noppes.npcs.controllers.TransportController;
|
||||||
import noppes.npcs.controllers.TransportLocation;
|
import noppes.npcs.controllers.TransportLocation;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.roles.JobSpawner;
|
import noppes.npcs.roles.JobSpawner;
|
||||||
@@ -88,13 +89,19 @@ public class PacketHandlerServer{
|
|||||||
ItemStack item = player.inventory.getCurrentItem();
|
ItemStack item = player.inventory.getCurrentItem();
|
||||||
|
|
||||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||||
|
|
||||||
|
if(type == EnumPacketServer.IsGuiOpen) {
|
||||||
|
isGuiOpenPacket(buffer, player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(type.needsNpc && npc == null){
|
if(type.needsNpc && npc == null){
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||||
//player doesnt have permission todo this
|
//player doesnt have permission to do this
|
||||||
}
|
}
|
||||||
else if(item == null )
|
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.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 if(item.getItem() == CustomItems.wand)
|
||||||
wandPackets(type, buffer, player, npc);
|
wandPackets(type, buffer, player, npc);
|
||||||
@@ -106,6 +113,10 @@ public class PacketHandlerServer{
|
|||||||
clonePackets(type, buffer, player);
|
clonePackets(type, buffer, player);
|
||||||
else if(item.getItem() == CustomItems.teleporter)
|
else if(item.getItem() == CustomItems.teleporter)
|
||||||
featherPackets(type, buffer, player);
|
featherPackets(type, buffer, player);
|
||||||
|
else if(type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||||
|
playerScriptPackets(type, buffer, player);
|
||||||
|
else if(type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||||
|
forgeScriptPackets(type, buffer, player);
|
||||||
else if(item.getItem() == CustomItems.scripter)
|
else if(item.getItem() == CustomItems.scripter)
|
||||||
scriptPackets(type, buffer, player, npc);
|
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))
|
else if(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
||||||
@@ -114,7 +125,11 @@ public class PacketHandlerServer{
|
|||||||
LogWriter.error("Error with EnumPacketServer." + type, e);
|
LogWriter.error("Error with EnumPacketServer." + type, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
|
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||||
|
}
|
||||||
|
|
||||||
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
||||||
if(type == EnumPacketServer.ScriptDataSave){
|
if(type == EnumPacketServer.ScriptDataSave){
|
||||||
npc.script.readFromNBT(Server.readNBT(buffer));
|
npc.script.readFromNBT(Server.readNBT(buffer));
|
||||||
@@ -128,6 +143,30 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playerScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if(type == EnumPacketServer.ScriptPlayerGet) {
|
||||||
|
PlayerDataScript data = ScriptController.Instance.playerScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
|
} else if(type == EnumPacketServer.ScriptPlayerSave) {
|
||||||
|
ScriptController.Instance.setPlayerScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forgeScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if (type == EnumPacketServer.ScriptForgeGet) {
|
||||||
|
ForgeDataScript data = ScriptController.Instance.forgeScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||||
|
} else if (type == EnumPacketServer.ScriptForgeSave) {
|
||||||
|
ScriptController.Instance.setForgeScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
if(type == EnumPacketServer.DimensionsGet){
|
if(type == EnumPacketServer.DimensionsGet){
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ public class Resistances {
|
|||||||
public float arrow = 1f;
|
public float arrow = 1f;
|
||||||
public float playermelee = 1f;
|
public float playermelee = 1f;
|
||||||
public float explosion = 1f;
|
public float explosion = 1f;
|
||||||
|
|
||||||
|
public boolean disableDamage = false;
|
||||||
|
|
||||||
public NBTTagCompound writeToNBT() {
|
public NBTTagCompound writeToNBT() {
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
@@ -16,6 +18,7 @@ public class Resistances {
|
|||||||
compound.setFloat("Arrow", arrow);
|
compound.setFloat("Arrow", arrow);
|
||||||
compound.setFloat("Melee", playermelee);
|
compound.setFloat("Melee", playermelee);
|
||||||
compound.setFloat("Explosion", explosion);
|
compound.setFloat("Explosion", explosion);
|
||||||
|
compound.setBoolean("disableDamage", disableDamage);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +27,14 @@ public class Resistances {
|
|||||||
arrow = compound.getFloat("Arrow");
|
arrow = compound.getFloat("Arrow");
|
||||||
playermelee = compound.getFloat("Melee");
|
playermelee = compound.getFloat("Melee");
|
||||||
explosion = compound.getFloat("Explosion");
|
explosion = compound.getFloat("Explosion");
|
||||||
|
disableDamage = compound.getBoolean("disableDamage");
|
||||||
}
|
}
|
||||||
|
|
||||||
public float applyResistance(DamageSource source, float damage) {
|
public float applyResistance(DamageSource source, float damage) {
|
||||||
|
if(disableDamage){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
|
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
|
||||||
damage *= (2 - arrow);
|
damage *= (2 - arrow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkEvent;
|
||||||
|
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import noppes.npcs.controllers.PixelmonHelper;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class ScriptForgeEventHandler {
|
||||||
|
public ScriptForgeEventHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void forgeEntity(Event event) {
|
||||||
|
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
|
||||||
|
if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event instanceof EntityEvent) {
|
||||||
|
EntityEvent ev2 = (EntityEvent)event;
|
||||||
|
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
|
||||||
|
EventHooks.onForgeEntityEvent(ev2);
|
||||||
|
}
|
||||||
|
} else if(event instanceof WorldEvent) {
|
||||||
|
WorldEvent ev1 = (WorldEvent)event;
|
||||||
|
if(ev1.world instanceof WorldServer) {
|
||||||
|
EventHooks.onForgeWorldEvent(ev1);
|
||||||
|
}
|
||||||
|
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
|
||||||
|
if (event instanceof PlayerEvent) {
|
||||||
|
PlayerEvent ev = (PlayerEvent) event;
|
||||||
|
if (!(ev.player.worldObj instanceof WorldServer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHooks.onForgeEvent(new ForgeEvent(event), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptForgeEventHandler registerForgeEvents() {
|
||||||
|
try {
|
||||||
|
Method e = this.getClass().getMethod("forgeEntity", new Class[]{Event.class});
|
||||||
|
Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class});
|
||||||
|
register.setAccessible(true);
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
|
||||||
|
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
|
||||||
|
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
|
||||||
|
Iterator e1 = list.iterator();
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
ClassPath.ClassInfo classLoader;
|
||||||
|
String classes;
|
||||||
|
do {
|
||||||
|
if(!e1.hasNext()) {
|
||||||
|
if(PixelmonHelper.Enabled) {
|
||||||
|
try {
|
||||||
|
Field e2 = ClassLoader.class.getDeclaredField("classes");
|
||||||
|
e2.setAccessible(true);
|
||||||
|
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
|
||||||
|
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
|
||||||
|
Iterator infoClass1 = classes1.iterator();
|
||||||
|
|
||||||
|
while(infoClass1.hasNext()) {
|
||||||
|
Class c2 = (Class)infoClass1.next();
|
||||||
|
}
|
||||||
|
} catch (Exception var12) {
|
||||||
|
var12.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
classLoader = (ClassPath.ClassInfo)e1.next();
|
||||||
|
classes = classLoader.getName();
|
||||||
|
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
|
||||||
|
|
||||||
|
Class infoClass = classLoader.load();
|
||||||
|
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
c.add(infoClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var10 = c.iterator();
|
||||||
|
while(var10.hasNext()) {
|
||||||
|
Class c1 = (Class)var10.next();
|
||||||
|
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
|
||||||
|
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception var13) {
|
||||||
|
var13.printStackTrace();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,390 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs;
|
||||||
|
|
||||||
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ContainerPlayer;
|
||||||
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
|
||||||
|
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||||
|
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.*;
|
||||||
|
import net.minecraftforge.event.world.*;
|
||||||
|
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
|
||||||
|
import noppes.npcs.controllers.PlayerData;
|
||||||
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.ForgeEvent;
|
||||||
|
import noppes.npcs.controllers.PixelmonHelper;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
public class ScriptPlayerEventHandler {
|
||||||
|
public ScriptPlayerEventHandler() {
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onServerTick(TickEvent.PlayerTickEvent event) {
|
||||||
|
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
||||||
|
EntityPlayer player = event.player;
|
||||||
|
|
||||||
|
if(player.ticksExisted%10 == 0) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
|
||||||
|
EventHooks.onPlayerTick(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(PlayerDataController.instance != null) {
|
||||||
|
if(PlayerDataController.instance.getPlayerData(player).timers.size() > 0)
|
||||||
|
PlayerDataController.instance.getPlayerData(player).timers.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(EntityInteractEvent event) {
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
|
||||||
|
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ArrowNockEvent event) {
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
|
||||||
|
EventHooks.onPlayerBowCharge(handler, ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ArrowLooseEvent event) {
|
||||||
|
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
|
||||||
|
EventHooks.onPlayerRanged(handler, ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(BlockEvent.BreakEvent event) {
|
||||||
|
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
|
||||||
|
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
|
||||||
|
event.setExpToDrop(ev.exp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Start event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Tick event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Stop event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerUseItemEvent.Finish event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerDropsEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerPickupXpEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.ItemPickupEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerOpenContainerEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(UseHoeEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerSleepInBedEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerWakeUpEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(FillBucketEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(BonemealEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(AchievementEvent event) {
|
||||||
|
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
|
||||||
|
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(ItemTossEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingFallEvent event) {
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingEvent.LivingJumpEvent event) {
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entityLiving instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerJump(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(EntityStruckByLightningEvent event) {
|
||||||
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entity instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerLightning(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlaySoundAtEntityEvent event) {
|
||||||
|
if(event.entity.worldObj instanceof WorldServer) {
|
||||||
|
if (event.entity instanceof EntityPlayer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
|
||||||
|
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingDeathEvent event) {
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
|
||||||
|
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source instanceof EntityPlayer) {
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
|
||||||
|
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(LivingHurtEvent event) {
|
||||||
|
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||||
|
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
if(event.entityLiving instanceof EntityPlayer) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
|
||||||
|
event.ammount = pevent.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source instanceof EntityPlayer) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||||
|
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
|
||||||
|
event.ammount = pevent1.damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerRespawn(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
EventHooks.onPlayerLogout(handler, scriptPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent(
|
||||||
|
priority = EventPriority.HIGHEST
|
||||||
|
)
|
||||||
|
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
|
||||||
|
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
|
||||||
|
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||||
|
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
|
||||||
|
String message = event.message;
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
|
||||||
|
EventHooks.onPlayerChat(handler, ev);
|
||||||
|
event.setCanceled(ev.isCanceled());
|
||||||
|
if(!message.equals(ev.message)) {
|
||||||
|
ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]);
|
||||||
|
chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message));
|
||||||
|
event.component = chat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,102 @@ 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.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){
|
|
||||||
this.field_179928_h += this.entity.getRNG().nextInt(5) + 2;
|
|
||||||
d3 = (double) MathHelper.sqrt_double(d3);
|
|
||||||
|
|
||||||
if (d3 > 1 && this.func_179926_b(this.posX, this.posY, this.posZ, d3)){
|
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
||||||
double speed = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() / 2.5;
|
if (this.posY != this.entity.posY) {
|
||||||
this.entity.motionX += d0 / d3 * speed;
|
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) {
|
||||||
this.entity.motionY += d1 / d3 * speed;
|
this.entity.motionY = 0.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;
|
|
||||||
}
|
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
||||||
else{
|
if(verticalSpeed > speed * speedMult)
|
||||||
this.update = false;
|
verticalSpeed = speed * speedMult;
|
||||||
|
verticalSpeed += this.entity.ai.flySpeed/2.0D;
|
||||||
|
|
||||||
|
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
|
||||||
|
verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
||||||
|
|
||||||
|
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,508 @@
|
|||||||
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;
|
||||||
protected PathFinder func_179679_a()
|
this.pathSearchRange = p_i45873_1_.getEntityAttribute(SharedMonsterAttributes.followRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
int i = (int)this.theEntity.boundingBox.minY;
|
||||||
|
Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (block != Blocks.air)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i;
|
||||||
|
block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
while (j <= 16);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.stats.Achievement;
|
||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import noppes.npcs.CommonProxy;
|
import noppes.npcs.CommonProxy;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
@@ -62,16 +64,7 @@ import noppes.npcs.client.controllers.PresetController;
|
|||||||
import noppes.npcs.client.fx.EntityElementalStaffFX;
|
import noppes.npcs.client.fx.EntityElementalStaffFX;
|
||||||
import noppes.npcs.client.fx.EntityEnderFX;
|
import noppes.npcs.client.fx.EntityEnderFX;
|
||||||
import noppes.npcs.client.fx.EntityRainbowFX;
|
import noppes.npcs.client.fx.EntityRainbowFX;
|
||||||
import noppes.npcs.client.gui.GuiBorderBlock;
|
import noppes.npcs.client.gui.*;
|
||||||
import noppes.npcs.client.gui.GuiMerchantAdd;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcDimension;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcMobSpawner;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerMounter;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcPather;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcRedstoneBlock;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcRemoteEditor;
|
|
||||||
import noppes.npcs.client.gui.GuiNpcWaypoint;
|
|
||||||
import noppes.npcs.client.gui.GuiScript;
|
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
|
import noppes.npcs.client.gui.global.GuiNPCManageBanks;
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
||||||
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
|
import noppes.npcs.client.gui.global.GuiNPCManageFactions;
|
||||||
@@ -105,6 +98,7 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerSetup;
|
|||||||
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
|
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
|
||||||
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
|
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
|
||||||
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
|
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
|
||||||
|
import noppes.npcs.client.gui.script.GuiScriptGlobal;
|
||||||
import noppes.npcs.client.model.*;
|
import noppes.npcs.client.model.*;
|
||||||
import noppes.npcs.client.renderer.*;
|
import noppes.npcs.client.renderer.*;
|
||||||
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
||||||
@@ -150,8 +144,10 @@ import noppes.npcs.containers.ContainerNPCTraderSetup;
|
|||||||
import noppes.npcs.containers.ContainerNpcItemGiver;
|
import noppes.npcs.containers.ContainerNpcItemGiver;
|
||||||
import noppes.npcs.containers.ContainerNpcQuestReward;
|
import noppes.npcs.containers.ContainerNpcQuestReward;
|
||||||
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
||||||
|
import noppes.npcs.controllers.PlayerData;
|
||||||
import noppes.npcs.entity.*;
|
import noppes.npcs.entity.*;
|
||||||
|
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import tconstruct.client.tabs.InventoryTabFactions;
|
import tconstruct.client.tabs.InventoryTabFactions;
|
||||||
@@ -165,9 +161,9 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
|||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
public static KeyBinding QuestLog;
|
public static KeyBinding QuestLog;
|
||||||
|
|
||||||
public static FontContainer Font;
|
public static FontContainer Font;
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
Font = new FontContainer(CustomNpcs.FontType, CustomNpcs.FontSize);
|
Font = new FontContainer(CustomNpcs.FontType, CustomNpcs.FontSize);
|
||||||
createFolders();
|
createFolders();
|
||||||
@@ -217,43 +213,47 @@ public class ClientProxy extends CommonProxy {
|
|||||||
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
|
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
|
||||||
}
|
}
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
QuestLog = new KeyBinding("Quest Log", Keyboard.KEY_L, "key.categories.gameplay");
|
QuestLog = new KeyBinding("Quest Log", Keyboard.KEY_L, "key.categories.gameplay");
|
||||||
|
|
||||||
ClientRegistry.registerKeyBinding(QuestLog);
|
ClientRegistry.registerKeyBinding(QuestLog);
|
||||||
mc.gameSettings.loadOptions();
|
mc.gameSettings.loadOptions();
|
||||||
|
|
||||||
new PresetController(CustomNpcs.Dir);
|
new PresetController(CustomNpcs.Dir);
|
||||||
|
|
||||||
if(CustomNpcs.EnableUpdateChecker){
|
if(CustomNpcs.EnableUpdateChecker){
|
||||||
VersionChecker checker = new VersionChecker();
|
VersionChecker checker = new VersionChecker();
|
||||||
checker.start();
|
checker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientCloneController.Instance = new ClientCloneController();
|
ClientCloneController.Instance = new ClientCloneController();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
||||||
|
|
||||||
if(CustomNpcs.InventoryGuiEnabled){
|
if(CustomNpcs.InventoryGuiEnabled){
|
||||||
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
||||||
|
|
||||||
if (TabRegistry.getTabList().size() < 2){
|
if (TabRegistry.getTabList().size() < 2){
|
||||||
TabRegistry.registerTab(new InventoryTabVanilla());
|
TabRegistry.registerTab(new InventoryTabVanilla());
|
||||||
}
|
}
|
||||||
TabRegistry.registerTab(new InventoryTabFactions());
|
TabRegistry.registerTab(new InventoryTabFactions());
|
||||||
TabRegistry.registerTab(new InventoryTabQuests());
|
TabRegistry.registerTab(new InventoryTabQuests());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakePlayer getCommandPlayer(IWorld world) {
|
||||||
|
return (FakePlayer)(new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createFolders() {
|
private void createFolders() {
|
||||||
File file = new File(CustomNpcs.Dir,"assets/customnpcs");
|
File file = new File(CustomNpcs.Dir,"assets/customnpcs");
|
||||||
if(!file.exists())
|
if(!file.exists())
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
|
|
||||||
File check = new File(file,"sounds");
|
File check = new File(file,"sounds");
|
||||||
if(!check.exists())
|
if(!check.exists())
|
||||||
check.mkdir();
|
check.mkdir();
|
||||||
|
|
||||||
File json = new File(file, "sounds.json");
|
File json = new File(file, "sounds.json");
|
||||||
if(!json.exists()){
|
if(!json.exists()){
|
||||||
try {
|
try {
|
||||||
@@ -268,16 +268,30 @@ public class ClientProxy extends CommonProxy {
|
|||||||
check = new File(file,"textures");
|
check = new File(file,"textures");
|
||||||
if(!check.exists())
|
if(!check.exists())
|
||||||
check.mkdir();
|
check.mkdir();
|
||||||
|
|
||||||
File cache = new File(check,"cache");
|
File cache = new File(check,"cache");
|
||||||
if(!cache.exists())
|
if(!cache.exists())
|
||||||
cache.mkdir();
|
cache.mkdir();
|
||||||
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
|
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new CustomNpcResourceListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerData playerData = new PlayerData();
|
||||||
|
@Override
|
||||||
|
public PlayerData getPlayerData(EntityPlayer player) {
|
||||||
|
if (player.getUniqueID() == Minecraft.getMinecraft().thePlayer.getUniqueID()) {
|
||||||
|
if (playerData.player != player) {
|
||||||
|
playerData.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerData;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
|
||||||
if (ID > EnumGuiType.values().length)
|
if (ID > EnumGuiType.values().length)
|
||||||
return null;
|
return null;
|
||||||
EnumGuiType gui = EnumGuiType.values()[ID];
|
EnumGuiType gui = EnumGuiType.values()[ID];
|
||||||
@@ -286,6 +300,8 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return getGui(npc, gui, container, x, y, z);
|
return getGui(npc, gui, container, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
|
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
|
||||||
if (gui == EnumGuiType.MainMenuDisplay){
|
if (gui == EnumGuiType.MainMenuDisplay){
|
||||||
if(npc != null)
|
if(npc != null)
|
||||||
@@ -304,16 +320,16 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
else if(gui == EnumGuiType.QuestReward)
|
else if(gui == EnumGuiType.QuestReward)
|
||||||
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
|
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.QuestItem)
|
else if(gui == EnumGuiType.QuestItem)
|
||||||
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
|
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.MovingPath)
|
else if (gui == EnumGuiType.MovingPath)
|
||||||
return new GuiNpcPather(npc);
|
return new GuiNpcPather(npc);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.ManageFactions)
|
else if (gui == EnumGuiType.ManageFactions)
|
||||||
return new GuiNPCManageFactions(npc);
|
return new GuiNPCManageFactions(npc);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.ManageLinked)
|
else if (gui == EnumGuiType.ManageLinked)
|
||||||
return new GuiNPCManageLinkedNpc(npc);
|
return new GuiNPCManageLinkedNpc(npc);
|
||||||
|
|
||||||
@@ -322,15 +338,15 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
else if (gui == EnumGuiType.ManageRecipes)
|
else if (gui == EnumGuiType.ManageRecipes)
|
||||||
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
|
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.ManageDialogs)
|
else if (gui == EnumGuiType.ManageDialogs)
|
||||||
return new GuiNPCManageDialogs(npc);
|
return new GuiNPCManageDialogs(npc);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.ManageQuests)
|
else if (gui == EnumGuiType.ManageQuests)
|
||||||
return new GuiNPCManageQuest(npc);
|
return new GuiNPCManageQuest(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.ManageBanks)
|
else if(gui == EnumGuiType.ManageBanks)
|
||||||
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
|
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.MainMenuGlobal)
|
else if (gui == EnumGuiType.MainMenuGlobal)
|
||||||
return new GuiNPCGlobalMainMenu(npc);
|
return new GuiNPCGlobalMainMenu(npc);
|
||||||
@@ -343,84 +359,87 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
else if (gui == EnumGuiType.PlayerFollower)
|
else if (gui == EnumGuiType.PlayerFollower)
|
||||||
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
|
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerTrader)
|
else if(gui == EnumGuiType.PlayerTrader)
|
||||||
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
|
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
|
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
|
||||||
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
|
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerTransporter)
|
else if(gui == EnumGuiType.PlayerTransporter)
|
||||||
return new GuiTransportSelection(npc);
|
return new GuiTransportSelection(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.Script)
|
else if(gui == EnumGuiType.Script)
|
||||||
return new GuiScript(npc);
|
return new GuiScript(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerAnvil)
|
else if(gui == EnumGuiType.PlayerAnvil)
|
||||||
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
|
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.SetupFollower)
|
else if (gui == EnumGuiType.SetupFollower)
|
||||||
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
|
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.SetupItemGiver)
|
else if (gui == EnumGuiType.SetupItemGiver)
|
||||||
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
|
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.SetupTrader)
|
else if(gui == EnumGuiType.SetupTrader)
|
||||||
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
|
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.SetupTransporter)
|
else if(gui == EnumGuiType.SetupTransporter)
|
||||||
return new GuiNpcTransporter(npc);
|
return new GuiNpcTransporter(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.SetupBank)
|
else if(gui == EnumGuiType.SetupBank)
|
||||||
return new GuiNpcBankSetup(npc);
|
return new GuiNpcBankSetup(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
||||||
return new GuiNpcRemoteEditor();
|
return new GuiNpcRemoteEditor();
|
||||||
|
|
||||||
|
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
|
||||||
|
return new GuiScriptGlobal();
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerMailman)
|
else if(gui == EnumGuiType.PlayerMailman)
|
||||||
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
|
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerMailbox)
|
else if(gui == EnumGuiType.PlayerMailbox)
|
||||||
return new GuiMailbox();
|
return new GuiMailbox();
|
||||||
|
|
||||||
else if(gui == EnumGuiType.MerchantAdd)
|
else if(gui == EnumGuiType.MerchantAdd)
|
||||||
return new GuiMerchantAdd();
|
return new GuiMerchantAdd();
|
||||||
|
|
||||||
else if(gui == EnumGuiType.Crate)
|
else if(gui == EnumGuiType.Crate)
|
||||||
return new GuiCrate((ContainerCrate)container);
|
return new GuiCrate((ContainerCrate)container);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.NpcDimensions)
|
else if(gui == EnumGuiType.NpcDimensions)
|
||||||
return new GuiNpcDimension();
|
return new GuiNpcDimension();
|
||||||
|
|
||||||
else if(gui == EnumGuiType.Border)
|
else if(gui == EnumGuiType.Border)
|
||||||
return new GuiBorderBlock(x, y, z);
|
return new GuiBorderBlock(x, y, z);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.BigSign)
|
else if(gui == EnumGuiType.BigSign)
|
||||||
return new GuiBigSign(x, y, z);
|
return new GuiBigSign(x, y, z);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.RedstoneBlock)
|
else if (gui == EnumGuiType.RedstoneBlock)
|
||||||
return new GuiNpcRedstoneBlock(x, y, z);
|
return new GuiNpcRedstoneBlock(x, y, z);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.MobSpawner)
|
else if(gui == EnumGuiType.MobSpawner)
|
||||||
return new GuiNpcMobSpawner(x, y, z);
|
return new GuiNpcMobSpawner(x, y, z);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.MobSpawnerMounter)
|
else if(gui == EnumGuiType.MobSpawnerMounter)
|
||||||
return new GuiNpcMobSpawnerMounter(x, y, z);
|
return new GuiNpcMobSpawnerMounter(x, y, z);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.Waypoint)
|
else if (gui == EnumGuiType.Waypoint)
|
||||||
return new GuiNpcWaypoint(x, y, z);
|
return new GuiNpcWaypoint(x, y, z);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.Companion)
|
else if (gui == EnumGuiType.Companion)
|
||||||
return new GuiNpcCompanionStats(npc);
|
return new GuiNpcCompanionStats(npc);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.CompanionTalent)
|
else if (gui == EnumGuiType.CompanionTalent)
|
||||||
return new GuiNpcCompanionTalents(npc);
|
return new GuiNpcCompanionTalents(npc);
|
||||||
|
|
||||||
else if (gui == EnumGuiType.CompanionInv)
|
else if (gui == EnumGuiType.CompanionInv)
|
||||||
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
|
return new GuiNpcCompanionInv(npc, (ContainerNPCCompanion) container);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
@@ -428,7 +447,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
|
GuiScreen guiscreen = getGui(null, gui, null, i, j, k);
|
||||||
|
|
||||||
|
|
||||||
if (guiscreen != null) {
|
if (guiscreen != null) {
|
||||||
minecraft.displayGuiScreen(guiscreen);
|
minecraft.displayGuiScreen(guiscreen);
|
||||||
@@ -459,7 +478,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
if (guiscreen != null) {
|
if (guiscreen != null) {
|
||||||
minecraft.displayGuiScreen((GuiScreen)guiscreen);
|
minecraft.displayGuiScreen((GuiScreen)guiscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -467,18 +486,18 @@ public class ClientProxy extends CommonProxy {
|
|||||||
if(string.equals("Spell")){
|
if(string.equals("Spell")){
|
||||||
int color = (Integer) ob[0];
|
int color = (Integer) ob[0];
|
||||||
int number = (Integer) ob[1];
|
int number = (Integer) ob[1];
|
||||||
for(int i = 0; i < number; i++){
|
for(int i = 0; i < number; i++){
|
||||||
Random rand = player.worldObj.rand;
|
Random rand = player.worldObj.rand;
|
||||||
double x = (rand.nextDouble() - 0.5D) * (double)player.width;
|
double x = (rand.nextDouble() - 0.5D) * (double)player.width;
|
||||||
double y = player.getEyeHeight();
|
double y = player.getEyeHeight();
|
||||||
double z = (rand.nextDouble() - 0.5D) * (double)player.width;
|
double z = (rand.nextDouble() - 0.5D) * (double)player.width;
|
||||||
|
|
||||||
double f = (rand.nextDouble() - 0.5D) * 2D;
|
double f = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
double f1 = -rand.nextDouble();
|
double f1 = -rand.nextDouble();
|
||||||
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
|
|
||||||
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
|
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityElementalStaffFX(player, x, y, z, f, f1, f2, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(string.equals("ModelData")){
|
else if(string.equals("ModelData")){
|
||||||
ModelData data = (ModelData) ob[0];
|
ModelData data = (ModelData) ob[0];
|
||||||
@@ -492,21 +511,21 @@ public class ClientProxy extends CommonProxy {
|
|||||||
EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() * (double)player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles);
|
EntityEnderFX fx = new EntityEnderFX(npc, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() * (double)player.height) - height - 0.25D, (rand.nextDouble() - 0.5D) * (double)player.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, particles);
|
||||||
minecraft.effectRenderer.addEffect(fx);
|
minecraft.effectRenderer.addEffect(fx);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(particles.type == 1){
|
else if(particles.type == 1){
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
|
double x = player.posX + (rand.nextDouble() - 0.5D) * 0.9;
|
||||||
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
|
double y = (player.posY + rand.nextDouble() * 1.9) - 0.25D - height;
|
||||||
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
|
double z = player.posZ + (rand.nextDouble() - 0.5D) * 0.9;
|
||||||
|
|
||||||
|
|
||||||
double f = (rand.nextDouble() - 0.5D) * 2D;
|
double f = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
double f1 = -rand.nextDouble();
|
double f1 = -rand.nextDouble();
|
||||||
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
double f2 = (rand.nextDouble() - 0.5D) * 2D;
|
||||||
|
|
||||||
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
|
minecraft.effectRenderer.addEffect(new EntityRainbowFX(player.worldObj, x, y, z, f, f1, f2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,7 +538,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
public boolean hasClient() {
|
public boolean hasClient() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer getPlayer() {
|
public EntityPlayer getPlayer() {
|
||||||
return Minecraft.getMinecraft().thePlayer;
|
return Minecraft.getMinecraft().thePlayer;
|
||||||
}
|
}
|
||||||
@@ -534,54 +553,63 @@ public class ClientProxy extends CommonProxy {
|
|||||||
try{
|
try{
|
||||||
if(location == null)
|
if(location == null)
|
||||||
return;
|
return;
|
||||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||||
if(location != null)
|
if(location != null)
|
||||||
texturemanager.bindTexture((ResourceLocation) location);
|
texturemanager.bindTexture((ResourceLocation) location);
|
||||||
}
|
}
|
||||||
catch(NullPointerException ex){
|
catch(NullPointerException ex){
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(ReportedException ex){
|
catch(ReportedException ex){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnParticle(String particle, double x, double y, double z,
|
public void spawnParticle(String particle, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float scale) {
|
double motionX, double motionY, double motionZ, float scale) {
|
||||||
|
|
||||||
RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
|
RenderGlobal render = Minecraft.getMinecraft().renderGlobal;
|
||||||
|
|
||||||
EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ);
|
EntityFX fx = render.doSpawnParticle(particle, x, y, z, motionX, motionY, motionZ);
|
||||||
if(fx == null)
|
if(fx == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (particle.equals("flame")){
|
if (particle.equals("flame")){
|
||||||
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0);
|
ObfuscationReflectionHelper.setPrivateValue(EntityFlameFX.class, (EntityFlameFX)fx, scale, 0);
|
||||||
}
|
}
|
||||||
else if (particle.equals("smoke")){
|
else if (particle.equals("smoke")){
|
||||||
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0);
|
ObfuscationReflectionHelper.setPrivateValue(EntitySmokeFX.class, (EntitySmokeFX)fx, scale, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAchievementDesc(Achievement achievement) {
|
||||||
|
return achievement.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGUIOpen(){
|
||||||
|
return Minecraft.getMinecraft().currentScreen != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class FontContainer {
|
public static class FontContainer {
|
||||||
private StringCache textFont = null;
|
private StringCache textFont = null;
|
||||||
public boolean useCustomFont = true;
|
public boolean useCustomFont = true;
|
||||||
|
|
||||||
private FontContainer(){
|
private FontContainer(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FontContainer(String fontType, int fontSize) {
|
public FontContainer(String fontType, int fontSize) {
|
||||||
textFont = new StringCache();
|
textFont = new StringCache();
|
||||||
textFont.setDefaultFont("Arial", fontSize, true);
|
textFont.setDefaultFont("Arial", fontSize, true);
|
||||||
useCustomFont = !fontType.equalsIgnoreCase("minecraft");
|
useCustomFont = !fontType.equalsIgnoreCase("minecraft");
|
||||||
try {
|
try {
|
||||||
if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
|
if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default"))
|
||||||
textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true);
|
textFont.setCustomFont(new ResourceLocation("customnpcs","OpenSans.ttf"), fontSize, true);
|
||||||
else
|
else
|
||||||
textFont.setDefaultFont(fontType, fontSize, true);
|
textFont.setDefaultFont(fontType, fontSize, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.info("Failed loading font so using Arial");
|
LogWriter.info("Failed loading font so using Arial");
|
||||||
}
|
}
|
||||||
@@ -592,7 +620,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return textFont.fontHeight;
|
return textFont.fontHeight;
|
||||||
return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
|
return Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int width(String text){
|
public int width(String text){
|
||||||
if(useCustomFont)
|
if(useCustomFont)
|
||||||
return textFont.getStringWidth(text);
|
return textFont.getStringWidth(text);
|
||||||
@@ -622,4 +650,4 @@ public class ClientProxy extends CommonProxy {
|
|||||||
return textFont.usedFont().getFontName();
|
return textFont.usedFont().getFontName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,11 +14,15 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
public class ClientTickHandler{
|
public class ClientTickHandler{
|
||||||
|
|
||||||
private World prevWorld;
|
private World prevWorld;
|
||||||
private boolean otherContainer = false;
|
private boolean otherContainer = false;
|
||||||
|
private int buttonPressed = -1;
|
||||||
|
private long buttonTime = 0L;
|
||||||
|
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
public void onClientTick(TickEvent.ClientTickEvent event){
|
public void onClientTick(TickEvent.ClientTickEvent event){
|
||||||
@@ -41,6 +45,14 @@ public class ClientTickHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onMouse(InputEvent.MouseInputEvent event){
|
||||||
|
if(Mouse.getEventButton() == -1 && Mouse.getDWheel() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, new Object[]{Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton())});
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onKey(InputEvent.KeyInputEvent event){
|
public void onKey(InputEvent.KeyInputEvent event){
|
||||||
if(ClientProxy.QuestLog.isPressed()){
|
if(ClientProxy.QuestLog.isPressed()){
|
||||||
@@ -50,6 +62,37 @@ public class ClientTickHandler{
|
|||||||
else if(mc.currentScreen instanceof GuiQuestLog)
|
else if(mc.currentScreen instanceof GuiQuestLog)
|
||||||
mc.setIngameFocus();
|
mc.setIngameFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int key = Keyboard.getEventKey();
|
||||||
|
long time = Keyboard.getEventNanoseconds();
|
||||||
|
|
||||||
|
if(Keyboard.getEventKeyState()) {
|
||||||
|
if(!this.isIgnoredKey(key)) {
|
||||||
|
this.buttonTime = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) {
|
||||||
|
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||||
|
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||||
|
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||||
|
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||||
|
boolean keyDown = Keyboard.isKeyDown(key);
|
||||||
|
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown)});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isIgnoredKey(int key) {
|
||||||
|
int[] var2 = this.ignoreKeys;
|
||||||
|
int var3 = var2.length;
|
||||||
|
|
||||||
|
for(int var4 = 0; var4 < var3; ++var4) {
|
||||||
|
int i = var2[var4];
|
||||||
|
if(i == key) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,14 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -21,6 +23,7 @@ import net.minecraft.world.World;
|
|||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.NoppesUtilPlayer;
|
import noppes.npcs.NoppesUtilPlayer;
|
||||||
import noppes.npcs.Server;
|
import noppes.npcs.Server;
|
||||||
|
import noppes.npcs.client.fx.EntityCustomFX;
|
||||||
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||||
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
||||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
||||||
@@ -67,6 +70,57 @@ public class NoppesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void spawnScriptedParticle(ByteBuf buffer){
|
||||||
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
String directory = Server.readString(buffer);
|
||||||
|
|
||||||
|
int HEXcolor = buffer.readInt();
|
||||||
|
int amount = buffer.readInt();
|
||||||
|
int maxAge = buffer.readInt();
|
||||||
|
|
||||||
|
double x = buffer.readDouble();
|
||||||
|
double y = buffer.readDouble();
|
||||||
|
double z = buffer.readDouble();
|
||||||
|
|
||||||
|
double motionX = buffer.readDouble();
|
||||||
|
double motionY = buffer.readDouble();
|
||||||
|
double motionZ = buffer.readDouble();
|
||||||
|
float gravity = buffer.readFloat();
|
||||||
|
|
||||||
|
float scale1 = buffer.readFloat();
|
||||||
|
float scale2 = buffer.readFloat();
|
||||||
|
float scaleRate = buffer.readFloat();
|
||||||
|
int scaleRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float alpha1 = buffer.readFloat();
|
||||||
|
float alpha2 = buffer.readFloat();
|
||||||
|
float alphaRate = buffer.readFloat();
|
||||||
|
int alphaRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
int entityID = buffer.readInt();
|
||||||
|
|
||||||
|
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||||
|
Entity entity = worldObj.getEntityByID(entityID);
|
||||||
|
|
||||||
|
if(entity == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EntityCustomFX fx = new EntityCustomFX(
|
||||||
|
entity,
|
||||||
|
directory, HEXcolor,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
maxAge
|
||||||
|
);
|
||||||
|
|
||||||
|
for(int i = 0; i < amount; i++){
|
||||||
|
minecraft.effectRenderer.addEffect(fx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void clickSound() {
|
public static void clickSound() {
|
||||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
}
|
}
|
||||||
@@ -237,4 +291,7 @@ public class NoppesUtil {
|
|||||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
|
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void isGUIOpen(boolean isGUIOpen) {
|
||||||
|
Client.sendData(EnumPacketServer.IsGuiOpen, isGUIOpen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +151,9 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
|||||||
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
||||||
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
|
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketClient.SCRIPTED_PARTICLE){
|
||||||
|
NoppesUtil.spawnScriptedParticle(buffer);
|
||||||
|
}
|
||||||
else if(type == EnumPacketClient.PARTICLE){
|
else if(type == EnumPacketClient.PARTICLE){
|
||||||
NoppesUtil.spawnParticle(buffer);
|
NoppesUtil.spawnParticle(buffer);
|
||||||
}
|
}
|
||||||
@@ -251,8 +254,10 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
|||||||
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
|
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(type == EnumPacketClient.ISGUIOPEN){
|
||||||
|
boolean isGUIOpen = Minecraft.getMinecraft().currentScreen != null;
|
||||||
|
|
||||||
|
NoppesUtil.isGUIOpen(isGUIOpen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package noppes.npcs.client.fx;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.particle.EntityFX;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.ClientProxy;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class EntityCustomFX extends EntityFX {
|
||||||
|
private Entity entity;
|
||||||
|
private final ResourceLocation location;
|
||||||
|
private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png");
|
||||||
|
private boolean move = true;
|
||||||
|
private float startX = 0, startY = 0, startZ = 0;
|
||||||
|
|
||||||
|
public float scale1 = 1.0F;
|
||||||
|
public float scale2 = 1.0F;
|
||||||
|
public float scaleRate = 1.0F;
|
||||||
|
public int scaleRateStart = 0;
|
||||||
|
|
||||||
|
public float alpha1 = 1.0F;
|
||||||
|
public float alpha2 = 0;
|
||||||
|
public float alphaRate = 0.0F;
|
||||||
|
public int alphaRateStart = 0;
|
||||||
|
|
||||||
|
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
int age) {
|
||||||
|
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||||
|
|
||||||
|
this.scale1 = scale1;
|
||||||
|
this.scale2 = scale2;
|
||||||
|
this.scaleRate = Math.abs(scaleRate);
|
||||||
|
this.scaleRateStart = scaleRateStart;
|
||||||
|
particleScale = scale1;
|
||||||
|
if(scale1 > scale2)
|
||||||
|
this.scaleRate *= -1;
|
||||||
|
|
||||||
|
this.alpha1 = alpha1;
|
||||||
|
this.alpha2 = alpha2;
|
||||||
|
this.alphaRate = Math.abs(alphaRate);
|
||||||
|
this.alphaRateStart = alphaRateStart;
|
||||||
|
particleAlpha = alpha1;
|
||||||
|
if(alpha1 > alpha2)
|
||||||
|
this.alphaRate *= -1;
|
||||||
|
|
||||||
|
particleGravity = gravity/0.04F;
|
||||||
|
particleMaxAge = age;
|
||||||
|
|
||||||
|
this.motionX = motionX;
|
||||||
|
this.motionY = motionY;
|
||||||
|
this.motionZ = motionZ;
|
||||||
|
|
||||||
|
this.entity = entity;
|
||||||
|
noClip = true;
|
||||||
|
|
||||||
|
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||||
|
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||||
|
particleBlue = (HEXColor & 255) / 255f;
|
||||||
|
|
||||||
|
if(Math.floor(Math.random()*3) == 1){
|
||||||
|
move = false;
|
||||||
|
this.startX = (float) entity.posX;
|
||||||
|
this.startY = (float) entity.posY;
|
||||||
|
this.startZ = (float) entity.posZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = new ResourceLocation(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||||
|
{
|
||||||
|
if(move){
|
||||||
|
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)par2);
|
||||||
|
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)par2);
|
||||||
|
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)par2);
|
||||||
|
}
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
float scale = this.scaleRate / (float)particleMaxAge;
|
||||||
|
if((this.scaleRate < 0 && particleScale+scale < this.scale2) || (this.scaleRate > 0 && particleScale+scale > this.scale2))
|
||||||
|
particleScale = this.scale2;
|
||||||
|
else if(particleAge >= this.scaleRateStart)
|
||||||
|
particleScale += scale;
|
||||||
|
|
||||||
|
float alpha = this.alphaRate / (float)particleMaxAge;
|
||||||
|
if((this.alphaRate < 0 && particleAlpha+alpha < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alpha > this.alpha2))
|
||||||
|
particleAlpha = this.alpha2;
|
||||||
|
else if(particleAge >= this.alphaRateStart)
|
||||||
|
particleAlpha += alpha;
|
||||||
|
|
||||||
|
ClientProxy.bindTexture(location);
|
||||||
|
|
||||||
|
float f = 0.0f;
|
||||||
|
float f1 = 1.0f;
|
||||||
|
float f2 = 0.0f;
|
||||||
|
float f3 = 1.0f;
|
||||||
|
float f4 = 0.1F * particleScale;
|
||||||
|
float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX);
|
||||||
|
float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY);
|
||||||
|
float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ);
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(240);
|
||||||
|
par1Tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
par1Tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||||
|
par1Tessellator.addVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f1, f3);
|
||||||
|
par1Tessellator.addVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f1, f2);
|
||||||
|
par1Tessellator.addVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f, f2);
|
||||||
|
par1Tessellator.addVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f, f3);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
|
EntityPlayer player = minecraft.thePlayer;
|
||||||
|
|
||||||
|
double yaw = (player.rotationYaw/180)*Math.PI;
|
||||||
|
double pitch = (player.rotationPitch/180)*Math.PI;
|
||||||
|
|
||||||
|
double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
|
||||||
|
double angleRad = (angle/180)*Math.PI;
|
||||||
|
|
||||||
|
double angleX = Math.sin(yaw)*Math.cos(pitch);
|
||||||
|
if(Math.abs(angleX) < 0.0001){
|
||||||
|
angleX = 0.0D;
|
||||||
|
}
|
||||||
|
double angleY = Math.sin(pitch);
|
||||||
|
if(Math.abs(angleY) < 0.0001){
|
||||||
|
angleY = 0.0D;
|
||||||
|
}
|
||||||
|
double angleZ = -Math.cos(yaw)*Math.cos(pitch);
|
||||||
|
if(Math.abs(angleZ) < 0.0001){
|
||||||
|
angleZ = 0.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
double translateX = 0;
|
||||||
|
double translateY = 0;
|
||||||
|
double translateZ = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||||
|
//GL11.glTranslated(translateX,translateY,translateZ);
|
||||||
|
//GL11.glRotated(angle, angleX, angleY, angleZ);
|
||||||
|
|
||||||
|
tessellator.draw();
|
||||||
|
ClientProxy.bindTexture(resource);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFXLayer(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package noppes.npcs.client.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
|
|
||||||
|
public class EventGuiScriptList extends SubGuiInterface{
|
||||||
|
private GuiCustomScroll scroll1;
|
||||||
|
private GuiCustomScroll scroll2;
|
||||||
|
private ScriptContainer container;
|
||||||
|
private List<String> scripts;
|
||||||
|
|
||||||
|
public EventGuiScriptList(List<String> scripts, ScriptContainer container){
|
||||||
|
this.container = container;
|
||||||
|
setBackground("menubg.png");
|
||||||
|
xSize = 346;
|
||||||
|
ySize = 216;
|
||||||
|
if(scripts == null)
|
||||||
|
scripts = new ArrayList<String>();
|
||||||
|
this.scripts = scripts;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void initGui(){
|
||||||
|
super.initGui();
|
||||||
|
if(scroll1 == null){
|
||||||
|
scroll1 = new GuiCustomScroll(this,0);
|
||||||
|
scroll1.setSize(140, 180);
|
||||||
|
}
|
||||||
|
scroll1.guiLeft = guiLeft + 4;
|
||||||
|
scroll1.guiTop = guiTop + 14;
|
||||||
|
this.addScroll(scroll1);
|
||||||
|
addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4));
|
||||||
|
|
||||||
|
if(scroll2 == null){
|
||||||
|
scroll2 = new GuiCustomScroll(this,1);
|
||||||
|
scroll2.setSize(140, 180);
|
||||||
|
}
|
||||||
|
scroll2.guiLeft = guiLeft + 200;
|
||||||
|
scroll2.guiTop = guiTop + 14;
|
||||||
|
this.addScroll(scroll2);
|
||||||
|
addLabel(new GuiNpcLabel(2, "script.loadedScripts", guiLeft + 200, guiTop + 4));
|
||||||
|
List<String> temp = new ArrayList<String>(scripts);
|
||||||
|
temp.removeAll(container.scripts);
|
||||||
|
scroll1.setList(temp);
|
||||||
|
scroll2.setList(container.scripts);
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(1, guiLeft + 145, guiTop + 40, 55, 20, ">"));
|
||||||
|
addButton(new GuiNpcButton(2, guiLeft + 145, guiTop + 62, 55, 20, "<"));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>"));
|
||||||
|
addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<"));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done"));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton guibutton){
|
||||||
|
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||||
|
if(button.id == 1){
|
||||||
|
if(scroll1.hasSelected()){
|
||||||
|
container.scripts.add(scroll1.getSelected());
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(button.id == 2){
|
||||||
|
if(scroll2.hasSelected()){
|
||||||
|
container.scripts.remove(scroll2.getSelected());
|
||||||
|
scroll2.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(button.id == 3){
|
||||||
|
container.scripts.clear();
|
||||||
|
for(String script : scripts){
|
||||||
|
container.scripts.add(script);
|
||||||
|
}
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
if(button.id == 4){
|
||||||
|
container.scripts.clear();
|
||||||
|
scroll1.selected = -1;
|
||||||
|
scroll1.selected = -1;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
if(button.id == 66){
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.blocks.tiles.TileBorder;
|
import noppes.npcs.blocks.tiles.TileBorder;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
@@ -30,7 +29,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
|
|||||||
|
|
||||||
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
|
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
|
||||||
getTextField(0).numbersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, 500, 6);
|
getTextField(0).setMinMaxDefault(0, 500, 6);
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -30,23 +27,23 @@ import noppes.npcs.controllers.ScriptContainer;
|
|||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
|
public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
|
||||||
public boolean showScript = false;
|
public boolean showScript = false;
|
||||||
private int activeTab = 0;
|
private int activeTab = 0;
|
||||||
public DataScript script;
|
public DataScript script;
|
||||||
public Map<String,List<String>> languages = new HashMap<String,List<String>>();
|
public Map<String,List<String>> languages = new HashMap<String,List<String>>();
|
||||||
|
|
||||||
private static int activeConsole = 0;
|
private static int activeConsole = 0;
|
||||||
|
|
||||||
public GuiScript(EntityNPCInterface npc) {
|
public GuiScript(EntityNPCInterface npc) {
|
||||||
super(npc);
|
super(npc);
|
||||||
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,37 +56,38 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
top.active = !showScript;
|
top.active = !showScript;
|
||||||
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
|
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
|
||||||
|
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
list.add("script.init");
|
list.add("script.init");
|
||||||
list.add("script.update");
|
list.add("script.update");
|
||||||
list.add("script.interact");
|
list.add("script.interact");
|
||||||
list.add("dialog.dialog");
|
list.add("dialog.dialog");
|
||||||
list.add("script.damaged");
|
list.add("script.damaged");
|
||||||
list.add("script.killed");
|
list.add("script.killed");
|
||||||
list.add("script.attack");
|
list.add("script.attack");
|
||||||
list.add("script.target");
|
list.add("script.target");
|
||||||
list.add("script.collide");
|
list.add("script.collide");
|
||||||
list.add("script.kills");
|
list.add("script.kills");
|
||||||
list.add("script.dialog_closed");
|
list.add("script.dialog_closed");
|
||||||
|
list.add("script.timer");
|
||||||
|
|
||||||
if(showScript){
|
if(showScript){
|
||||||
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
|
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
|
||||||
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
|
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
|
||||||
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);
|
||||||
|
|
||||||
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
|
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
|
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
|
||||||
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
|
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
|
||||||
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
|
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor"));
|
addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor"));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript"));
|
addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript"));
|
||||||
@@ -114,14 +112,14 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
l.add("All");
|
l.add("All");
|
||||||
l.addAll(list);
|
l.addAll(list);
|
||||||
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole));
|
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole));
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
|
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
|
||||||
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex()));
|
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex()));
|
||||||
getButton(103).enabled = languages.size() > 0;
|
getButton(103).enabled = languages.size() > 0;
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
|
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
|
||||||
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0));
|
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0));
|
||||||
|
|
||||||
if(MinecraftServer.getServer() != null)
|
if(MinecraftServer.getServer() != null)
|
||||||
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
|
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
|
||||||
}
|
}
|
||||||
@@ -138,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) {
|
||||||
@@ -173,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());
|
||||||
@@ -185,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,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) {
|
||||||
@@ -222,12 +217,12 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScript(){
|
private void setScript(){
|
||||||
if(showScript){
|
if(showScript){
|
||||||
ScriptContainer container = script.scripts.get(activeTab);
|
ScriptContainer container = script.scripts.get(activeTab);
|
||||||
if(container == null)
|
if(container == null)
|
||||||
script.scripts.put(activeTab, container = new ScriptContainer());
|
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
|
||||||
String text = getTextField(2).getText();
|
String text = getTextField(2).getText();
|
||||||
text = text.replace("\r\n", "\n");
|
text = text.replace("\r\n", "\n");
|
||||||
text = text.replace("\r", "\n");
|
text = text.replace("\r", "\n");
|
||||||
@@ -256,7 +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
|
||||||
@@ -277,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"));
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -28,29 +28,29 @@ 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, 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,24 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
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 +57,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 +77,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 +104,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,6 +158,7 @@ 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 == 66){
|
else if(button.id == 66){
|
||||||
close();
|
close();
|
||||||
@@ -172,6 +185,12 @@ 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
@@ -30,20 +29,20 @@ 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, 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));
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ public class SubGuiNpcResistanceProperties extends SubGuiInterface implements IS
|
|||||||
addLabel(new GuiNpcLabel(3,"stats.explosion", guiLeft + 4, guiTop + 81));
|
addLabel(new GuiNpcLabel(3,"stats.explosion", guiLeft + 4, guiTop + 81));
|
||||||
addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, guiTop + 76, (int)(resistances.explosion * 100 - 100) + "%", resistances.explosion / 2));
|
addSlider(new GuiNpcSlider(this, 3, guiLeft + 94, guiTop + 76, (int)(resistances.explosion * 100 - 100) + "%", resistances.explosion / 2));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
if(resistances.disableDamage){
|
||||||
|
addLabel(new GuiNpcLabel(4,"stats.disabletrue", guiLeft + 4, guiTop + 103));
|
||||||
|
}
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void actionPerformed(GuiButton guibutton)
|
protected void actionPerformed(GuiButton guibutton)
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.mainmenu;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.EnumCreatureAttribute;
|
import net.minecraft.entity.EnumCreatureAttribute;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.DataStats;
|
import noppes.npcs.DataStats;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
@@ -34,18 +35,17 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
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, 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, Integer.MAX_VALUE, 2);
|
||||||
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()));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(0,guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
|
addButton(new GuiNpcButton(0,guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
|
||||||
addLabel(new GuiNpcLabel(2,"stats.respawn", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(2,"stats.respawn", guiLeft + 5, y + 5));
|
||||||
|
|
||||||
|
|
||||||
this.addButton(new GuiNpcButton(2, guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
|
this.addButton(new GuiNpcButton(2, guiLeft + 82, y+=22, 56, 20, "selectServer.edit"));
|
||||||
addLabel(new GuiNpcLabel(5,"stats.meleeproperties", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(5,"stats.meleeproperties", guiLeft + 5, y + 5));
|
||||||
@@ -53,19 +53,21 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
addLabel(new GuiNpcLabel(6,"stats.rangedproperties", guiLeft + 5, y + 5));
|
addLabel(new GuiNpcLabel(6,"stats.rangedproperties", guiLeft + 5, y + 5));
|
||||||
this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit"));
|
this.addButton(new GuiNpcButton(9, guiLeft + 217, y, 56, 20, "selectServer.edit"));
|
||||||
addLabel(new GuiNpcLabel(7,"stats.projectileproperties", guiLeft + 140, y + 5));
|
addLabel(new GuiNpcLabel(7,"stats.projectileproperties", guiLeft + 140, y + 5));
|
||||||
|
|
||||||
this.addButton(new GuiNpcButton(15, guiLeft + 82, y+=34, 56, 20, "selectServer.edit"));
|
|
||||||
addLabel(new GuiNpcLabel(15,"potion.resistance", guiLeft + 5, y + 5));
|
|
||||||
|
|
||||||
|
this.addButton(new GuiNpcButton(15, guiLeft + 82, y+=34, 56, 20, "selectServer.edit"));
|
||||||
addButton(new GuiNpcButton(4,guiLeft + 82, y+=34, 56, 20, new String[]{"gui.no","gui.yes"} ,npc.isImmuneToFire()? 1:0));
|
addLabel(new GuiNpcLabel(15,"potion.resistance", guiLeft + 5, y + 5));
|
||||||
|
|
||||||
|
this.addButton(new GuiNpcButton(21, guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"}, this.stats.resistances.disableDamage? 1:0));
|
||||||
|
addLabel(new GuiNpcLabel(21,"stats.disabledamage", guiLeft + 140, y + 5));
|
||||||
|
|
||||||
|
addButton(new GuiNpcButton(4,guiLeft + 82, y+=34, 56, 20, new String[]{"gui.no","gui.yes"} ,npc.isImmuneToFire()? 1:0));
|
||||||
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, 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, 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));
|
||||||
@@ -81,17 +83,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())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +136,9 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
|||||||
else if (button.id == 18) {
|
else if (button.id == 18) {
|
||||||
stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
stats.potionImmune = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||||
}
|
}
|
||||||
|
else if(button.id == 21){
|
||||||
|
stats.resistances.disableDamage = ((GuiNpcButton)guibutton).getValue() == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ public class GuiMailmanWrite extends GuiContainerNPCInterface implements ITextfi
|
|||||||
*/
|
*/
|
||||||
public void keyTyped(char par1, int par2)
|
public void keyTyped(char par1, int par2)
|
||||||
{
|
{
|
||||||
if(!GuiNpcTextField.isActive() && canEdit)
|
if(!GuiNpcTextField.isFieldActive() && canEdit)
|
||||||
this.keyTypedInBook(par1, par2);
|
this.keyTypedInBook(par1, par2);
|
||||||
else
|
else
|
||||||
super.keyTyped(par1, par2);
|
super.keyTyped(par1, par2);
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ import net.minecraft.client.gui.GuiScreen;
|
|||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import noppes.npcs.client.NoppesUtil;
|
|
||||||
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;
|
||||||
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.GuiNpcTextField;
|
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||||
@@ -52,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++;
|
||||||
}
|
}
|
||||||
@@ -60,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;
|
||||||
@@ -84,7 +82,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
addScroll(scroll);
|
addScroll(scroll);
|
||||||
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back"));
|
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 140, 98, 20, "gui.back"));
|
||||||
|
|
||||||
scroll.visible = GuiNpcTextField.isActive();
|
scroll.visible = GuiNpcTextField.isFieldActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void actionPerformed(GuiButton guibutton) {
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
@@ -96,7 +94,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
public void mouseClicked(int i, int j, int k)
|
public void mouseClicked(int i, int j, int k)
|
||||||
{
|
{
|
||||||
super.mouseClicked(i, j, k);
|
super.mouseClicked(i, j, k);
|
||||||
scroll.visible = GuiNpcTextField.isActive();
|
scroll.visible = GuiNpcTextField.isFieldActive();
|
||||||
}
|
}
|
||||||
public void save() {
|
public void save() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
|
|
||||||
|
public class EventGuiScriptList extends SubGuiInterface {
|
||||||
|
private GuiCustomScroll scroll1;
|
||||||
|
private GuiCustomScroll scroll2;
|
||||||
|
private ScriptContainer container;
|
||||||
|
private List<String> scripts;
|
||||||
|
|
||||||
|
public EventGuiScriptList(List<String> scripts, ScriptContainer container) {
|
||||||
|
this.container = container;
|
||||||
|
this.setBackground("menubg.png");
|
||||||
|
this.xSize = 346;
|
||||||
|
this.ySize = 216;
|
||||||
|
if(scripts == null) {
|
||||||
|
scripts = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scripts = (List)scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
if(this.scroll1 == null) {
|
||||||
|
this.scroll1 = new GuiCustomScroll(this, 0);
|
||||||
|
this.scroll1.setSize(140, 180);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scroll1.guiLeft = this.guiLeft + 4;
|
||||||
|
this.scroll1.guiTop = this.guiTop + 14;
|
||||||
|
this.addScroll(this.scroll1);
|
||||||
|
this.addLabel(new GuiNpcLabel(1, "script.availableScripts", this.guiLeft + 4, this.guiTop + 4));
|
||||||
|
if(this.scroll2 == null) {
|
||||||
|
this.scroll2 = new GuiCustomScroll(this, 1);
|
||||||
|
this.scroll2.setSize(140, 180);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scroll2.guiLeft = this.guiLeft + 200;
|
||||||
|
this.scroll2.guiTop = this.guiTop + 14;
|
||||||
|
this.addScroll(this.scroll2);
|
||||||
|
this.addLabel(new GuiNpcLabel(2, "script.loadedScripts", this.guiLeft + 200, this.guiTop + 4));
|
||||||
|
ArrayList temp = new ArrayList(this.scripts);
|
||||||
|
temp.removeAll(this.container.scripts);
|
||||||
|
this.scroll1.setList(temp);
|
||||||
|
this.scroll2.setList(this.container.scripts);
|
||||||
|
this.addButton(new GuiNpcButton(1, this.guiLeft + 145, this.guiTop + 40, 55, 20, ">"));
|
||||||
|
this.addButton(new GuiNpcButton(2, this.guiLeft + 145, this.guiTop + 62, 55, 20, "<"));
|
||||||
|
this.addButton(new GuiNpcButton(3, this.guiLeft + 145, this.guiTop + 90, 55, 20, ">>"));
|
||||||
|
this.addButton(new GuiNpcButton(4, this.guiLeft + 145, this.guiTop + 112, 55, 20, "<<"));
|
||||||
|
this.addButton(new GuiNpcButton(66, this.guiLeft + 260, this.guiTop + 194, 60, 20, "gui.done"));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
|
GuiNpcButton button = (GuiNpcButton)guibutton;
|
||||||
|
if(button.id == 1 && this.scroll1.hasSelected()) {
|
||||||
|
this.container.scripts.add(this.scroll1.getSelected());
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(button.id == 2 && this.scroll2.hasSelected()) {
|
||||||
|
this.container.scripts.remove(this.scroll2.getSelected());
|
||||||
|
this.scroll2.selected = -1;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(button.id == 3) {
|
||||||
|
this.container.scripts.clear();
|
||||||
|
Iterator var3 = this.scripts.iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
String script = (String)var3.next();
|
||||||
|
this.container.scripts.add(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(button.id == 4) {
|
||||||
|
this.container.scripts.clear();
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.scroll1.selected = -1;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(button.id == 66) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
|
||||||
|
public class GuiScriptForge extends GuiScriptInterface {
|
||||||
|
private ForgeDataScript script = new ForgeDataScript();
|
||||||
|
|
||||||
|
public GuiScriptForge() {
|
||||||
|
this.handler = this.script;
|
||||||
|
Client.sendData(EnumPacketServer.ScriptForgeGet, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
this.script.readFromNBT(compound);
|
||||||
|
super.setGuiData(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
super.save();
|
||||||
|
Client.sendData(EnumPacketServer.ScriptForgeSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class GuiScriptGlobal extends GuiNPCInterface {
|
||||||
|
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png");
|
||||||
|
|
||||||
|
public GuiScriptGlobal() {
|
||||||
|
this.xSize = 176;
|
||||||
|
this.ySize = 222;
|
||||||
|
this.drawDefaultBackground = false;
|
||||||
|
this.title = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
this.addButton(new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players"));
|
||||||
|
this.addButton(new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreen(int i, int j, float f) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.mc.renderEngine.bindTexture(this.resource);
|
||||||
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||||
|
super.drawScreen(i, j, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
|
if (guibutton.id == 0) {
|
||||||
|
this.displayGuiScreen(new GuiScriptPlayers());
|
||||||
|
}
|
||||||
|
if (guibutton.id == 1) {
|
||||||
|
this.displayGuiScreen(new GuiScriptForge());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyTyped(char c, int i) {
|
||||||
|
if (i == 1 || this.isInventoryKey(i)) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.google.common.reflect.ClassPath;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiConfirmOpenLink;
|
||||||
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
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.ScriptContainer;
|
||||||
|
import noppes.npcs.NoppesStringUtils;
|
||||||
|
import noppes.npcs.client.NoppesUtil;
|
||||||
|
import noppes.npcs.client.gui.swing.GuiJTextArea;
|
||||||
|
import noppes.npcs.client.gui.util.*;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener {
|
||||||
|
private int activeTab = 0;
|
||||||
|
public IScriptHandler handler;
|
||||||
|
public Map<String, List<String>> languages = new HashMap();
|
||||||
|
private int scriptLimit = 1;
|
||||||
|
|
||||||
|
public GuiScriptInterface() {
|
||||||
|
this.drawDefaultBackground = true;
|
||||||
|
this.closeOnEsc = true;
|
||||||
|
this.xSize = 420;
|
||||||
|
this.setBackground("menubg.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGui() {
|
||||||
|
//this.xSize = (int)((double)this.width * 0.88D);
|
||||||
|
this.ySize = (int)((double)this.xSize * 0.56D);
|
||||||
|
if((double)this.ySize > (double)this.height * 0.95D) {
|
||||||
|
this.ySize = (int)((double)this.height * 0.95D);
|
||||||
|
this.xSize = (int)((double)this.ySize / 0.56D);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bgScale = (float)this.xSize / 400.0F;
|
||||||
|
super.initGui();
|
||||||
|
this.guiTop += 10;
|
||||||
|
int yoffset = (int)((double)this.ySize * 0.02D);
|
||||||
|
GuiMenuTopButton top;
|
||||||
|
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
|
||||||
|
|
||||||
|
int topXoffset = 0;
|
||||||
|
int topYoffset = 0;
|
||||||
|
for(int ta = 0; ta < this.handler.getScripts().size(); ++ta) {
|
||||||
|
if(ta%20 == 0 && ta > 0) {
|
||||||
|
topYoffset -= 20;
|
||||||
|
topXoffset -= top.width+20*22;
|
||||||
|
}
|
||||||
|
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition+top.width + topXoffset, top.yPosition + topYoffset, ta + 1 + ""));
|
||||||
|
topXoffset = 0;
|
||||||
|
topYoffset = 0;
|
||||||
|
scriptLimit = ta + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.handler.getScripts().size() < 100)
|
||||||
|
this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition+top.width, top.yPosition, "+"));
|
||||||
|
|
||||||
|
top = this.getTopButton(this.activeTab);
|
||||||
|
if(top == null) {
|
||||||
|
this.activeTab = 0;
|
||||||
|
top = this.getTopButton(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
top.active = true;
|
||||||
|
if(this.activeTab > 0) {
|
||||||
|
List<String> hookList = new ArrayList<String>();
|
||||||
|
|
||||||
|
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
|
||||||
|
hooks.allowUserInput = false;
|
||||||
|
hooks.setSize(108, 198);
|
||||||
|
hooks.guiLeft = guiLeft - 110;
|
||||||
|
hooks.guiTop = guiTop + 14;
|
||||||
|
|
||||||
|
if(handler instanceof PlayerDataScript) {
|
||||||
|
hookList.add("init");
|
||||||
|
hookList.add("tick");
|
||||||
|
hookList.add("interact");
|
||||||
|
hookList.add("damagedEntity");
|
||||||
|
hookList.add("damaged");
|
||||||
|
hookList.add("kills");
|
||||||
|
hookList.add("killed");
|
||||||
|
hookList.add("drop");
|
||||||
|
hookList.add("respawn");
|
||||||
|
hookList.add("breakBlock");
|
||||||
|
hookList.add("chat");
|
||||||
|
hookList.add("login");
|
||||||
|
hookList.add("logout");
|
||||||
|
hookList.add("keyPressed");
|
||||||
|
hookList.add("mouseClicked");
|
||||||
|
hookList.add("toss");
|
||||||
|
hookList.add("pickUp");
|
||||||
|
hookList.add("pickupXP");
|
||||||
|
hookList.add("rangedCharge");
|
||||||
|
hookList.add("rangedLaunched");
|
||||||
|
hookList.add("timer");
|
||||||
|
hookList.add("startItem");
|
||||||
|
hookList.add("usingItem");
|
||||||
|
hookList.add("stopItem");
|
||||||
|
hookList.add("finishItem");
|
||||||
|
hookList.add("containerOpen");
|
||||||
|
hookList.add("useHoe");
|
||||||
|
hookList.add("bonemeal");
|
||||||
|
hookList.add("fillBucket");
|
||||||
|
hookList.add("jump");
|
||||||
|
hookList.add("fall");
|
||||||
|
hookList.add("wakeUp");
|
||||||
|
hookList.add("sleep");
|
||||||
|
hookList.add("playSound");
|
||||||
|
hookList.add("lightning");
|
||||||
|
hookList.add("changedDim");
|
||||||
|
}
|
||||||
|
else if(handler instanceof ForgeDataScript) {
|
||||||
|
hooks.setSize(238, 198);
|
||||||
|
hooks.guiLeft = guiLeft - 240;
|
||||||
|
|
||||||
|
hookList.add("init");
|
||||||
|
|
||||||
|
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
|
||||||
|
try {
|
||||||
|
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"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ClassPath.ClassInfo e1 : list){
|
||||||
|
ClassPath.ClassInfo classLoader = e1;
|
||||||
|
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)) {
|
||||||
|
String eventName = c1.getName();
|
||||||
|
int i = eventName.lastIndexOf(".");
|
||||||
|
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
|
||||||
|
|
||||||
|
hookList.add(eventName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hooks.setUnsortedList(hookList);
|
||||||
|
addScroll(hooks);
|
||||||
|
|
||||||
|
GuiNpcLabel hookLabel = new GuiNpcLabel(0, "script.hooks", hooks.guiLeft, guiTop + 5);
|
||||||
|
hookLabel.color = 0xaaaaaa;
|
||||||
|
addLabel(hookLabel);
|
||||||
|
|
||||||
|
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);
|
||||||
|
this.addTextField(left);
|
||||||
|
int left1 = this.guiLeft + this.xSize - 104;
|
||||||
|
this.addButton(new GuiNpcButton(102, left1, this.guiTop + yoffset, 60, 20, "gui.clear"));
|
||||||
|
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
|
||||||
|
this.addButton(new GuiNpcButton(100, left1, this.guiTop + 21 + yoffset, 60, 20, "gui.copy"));
|
||||||
|
this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove"));
|
||||||
|
this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript"));
|
||||||
|
GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable();
|
||||||
|
scroll.setSize(100, (int)((double)this.ySize * 0.54D) - yoffset * 2);
|
||||||
|
scroll.guiLeft = left1;
|
||||||
|
scroll.guiTop = this.guiTop + 88 + yoffset;
|
||||||
|
if(var7 != null) {
|
||||||
|
scroll.setList(var7.scripts);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addScroll(scroll);
|
||||||
|
} else {
|
||||||
|
GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
|
||||||
|
var8.enabled = false;
|
||||||
|
this.addTextField(var8);
|
||||||
|
int var9 = this.guiLeft + this.xSize - 150;
|
||||||
|
this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy"));
|
||||||
|
this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear"));
|
||||||
|
this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15));
|
||||||
|
this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, (String[])this.languages.keySet().toArray(new String[this.languages.keySet().size()]), this.getScriptIndex()));
|
||||||
|
this.getButton(103).enabled = this.languages.size() > 0;
|
||||||
|
this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36));
|
||||||
|
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled()?1:0));
|
||||||
|
if(this.player.worldObj.isRemote) {
|
||||||
|
this.addButton(new GuiNpcButton(106, var9, this.guiTop + 55, 150, 20, "script.openfolder"));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addButton(new GuiNpcButton(109, var9, this.guiTop + 78, 80, 20, "gui.website"));
|
||||||
|
this.addButton(new GuiNpcButton(112, var9 + 81, this.guiTop + 78, 80, 20, "gui.forum"));
|
||||||
|
this.addButton(new GuiNpcButton(110, var9, this.guiTop + 99, 80, 20, "script.apidoc"));
|
||||||
|
this.addButton(new GuiNpcButton(111, var9 + 81, this.guiTop + 99, 80, 20, "script.apisrc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.xSize = 420;
|
||||||
|
this.ySize = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String previousHookClicked = "";
|
||||||
|
@Override
|
||||||
|
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||||
|
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
|
||||||
|
public void unFocused(GuiNpcTextField textfield) {
|
||||||
|
/*if(textfield.id == 1){
|
||||||
|
this.handler.getScripts().get(this.activeTab - 1).setType(textfield.getText());
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getConsoleText() {
|
||||||
|
Map<Long, String> map = this.handler.getConsoleText();
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Iterator var3 = map.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
Entry<Long, String> entry = (Entry)var3.next();
|
||||||
|
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getScriptIndex() {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) {
|
||||||
|
String language = (String)var2.next();
|
||||||
|
if(language.equalsIgnoreCase(this.handler.getLanguage())) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void confirmClicked(boolean flag, int i) {
|
||||||
|
if(flag) {
|
||||||
|
if(i == 0) {
|
||||||
|
this.openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 1) {
|
||||||
|
this.openLink("http://www.kodevelopment.nl/customnpcs/api/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 2) {
|
||||||
|
this.openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 3) {
|
||||||
|
this.openLink("http://www.minecraftforge.net/forum/index.php/board,122.0.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 10) {
|
||||||
|
this.handler.getScripts().remove(this.activeTab - 1);
|
||||||
|
this.activeTab = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayGuiScreen(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton) {
|
||||||
|
if(guibutton.id >= 0 && guibutton.id < scriptLimit) {
|
||||||
|
this.setScript();
|
||||||
|
this.activeTab = guibutton.id;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == scriptLimit) {
|
||||||
|
this.handler.getScripts().add(new ScriptContainer(this.handler));
|
||||||
|
this.activeTab = this.handler.getScripts().size();
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 109) {
|
||||||
|
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 110) {
|
||||||
|
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/customnpcs/api/", 1, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 111) {
|
||||||
|
this.displayGuiScreen(new GuiConfirmOpenLink(this, "https://github.com/Noppes/CustomNPCsAPI", 2, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 112) {
|
||||||
|
this.displayGuiScreen(new GuiConfirmOpenLink(this, "http://www.minecraftforge.net/forum/index.php/board,122.0.html", 3, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 100) {
|
||||||
|
NoppesStringUtils.setClipboardContents((this.getTextField(2)).getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 101) {
|
||||||
|
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptContainer container;
|
||||||
|
if(guibutton.id == 102) {
|
||||||
|
if(this.activeTab > 0) {
|
||||||
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
|
container.script = "";
|
||||||
|
} else {
|
||||||
|
this.handler.clearConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 103) {
|
||||||
|
this.handler.setLanguage(((GuiNpcButton)guibutton).displayString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 104) {
|
||||||
|
this.handler.setEnabled((((GuiNpcButton)guibutton).getValue() == 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 105) {
|
||||||
|
GuiYesNo container1 = new GuiYesNo(this, "", ((GuiNpcButton)guibutton).displayString, 10);
|
||||||
|
this.displayGuiScreen(container1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 106) {
|
||||||
|
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 107) {
|
||||||
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
|
if(container == null) {
|
||||||
|
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guibutton.id == 108) {
|
||||||
|
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
|
if(container != null) {
|
||||||
|
this.setScript();
|
||||||
|
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setScript() {
|
||||||
|
if(this.activeTab > 0) {
|
||||||
|
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
|
if(container == null) {
|
||||||
|
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = (this.getTextField(2)).getText();
|
||||||
|
text = text.replace("\r\n", "\n");
|
||||||
|
text = text.replace("\r", "\n");
|
||||||
|
container.script = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
NBTTagList data = compound.getTagList("Languages", 10);
|
||||||
|
HashMap languages = new HashMap();
|
||||||
|
|
||||||
|
for(int i = 0; i < data.tagCount(); ++i) {
|
||||||
|
NBTTagCompound comp = data.getCompoundTagAt(i);
|
||||||
|
ArrayList scripts = new ArrayList();
|
||||||
|
NBTTagList list = comp.getTagList("Scripts", 8);
|
||||||
|
|
||||||
|
for(int j = 0; j < list.tagCount(); ++j) {
|
||||||
|
scripts.add(list.getStringTagAt(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
languages.put(comp.getString("Language"), scripts);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.languages = languages;
|
||||||
|
this.initGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
this.setScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void textUpdate(String text) {
|
||||||
|
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||||
|
if(container != null) {
|
||||||
|
container.script = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveText(String text) {
|
||||||
|
ScriptContainer container = handler.getScripts().get(activeTab);
|
||||||
|
if(container != null)
|
||||||
|
container.script = text;
|
||||||
|
initGui();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
|
|
||||||
|
public class GuiScriptPlayers extends GuiScriptInterface {
|
||||||
|
private PlayerDataScript script = new PlayerDataScript((EntityPlayer)null);
|
||||||
|
|
||||||
|
public GuiScriptPlayers() {
|
||||||
|
this.handler = this.script;
|
||||||
|
Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
this.script.readFromNBT(compound);
|
||||||
|
super.setGuiData(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
super.save();
|
||||||
|
Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
ScriptController.Instance.playerScripts.errored.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,7 +109,7 @@ public abstract class GuiContainerNPCInterface extends GuiContainer
|
|||||||
for(GuiNpcTextField tf : new ArrayList<GuiNpcTextField>(textfields.values()))
|
for(GuiNpcTextField tf : new ArrayList<GuiNpcTextField>(textfields.values()))
|
||||||
tf.textboxKeyTyped(c, i);
|
tf.textboxKeyTyped(c, i);
|
||||||
|
|
||||||
if (closeOnEsc && (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode() && !GuiNpcTextField.isActive()))
|
if (closeOnEsc && (i == 1 || i == mc.gameSettings.keyBindInventory.getKeyCode() && !GuiNpcTextField.isFieldActive()))
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,4 +280,7 @@ public class GuiCustomScroll extends GuiScreen
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMouseOver(int x, int y) {
|
||||||
|
return x >= this.guiLeft && x <= this.guiLeft + this.xSize && y >= this.guiTop && y <= this.guiTop + this.ySize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public abstract class GuiNPCInterface extends GuiScreen
|
|||||||
for(GuiNpcTextField tf : textfields.values())
|
for(GuiNpcTextField tf : textfields.values())
|
||||||
tf.textboxKeyTyped(c, i);
|
tf.textboxKeyTyped(c, i);
|
||||||
|
|
||||||
if (closeOnEsc && (i == 1 || !GuiNpcTextField.isActive() && isInventoryKey(i))){
|
if (closeOnEsc && (i == 1 || !GuiNpcTextField.isFieldActive() && isInventoryKey(i))){
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
public class GuiNpcTextArea extends GuiNpcTextField{
|
public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
|
||||||
public boolean inMenu = true;
|
public boolean inMenu = true;
|
||||||
public boolean numbersOnly = false;
|
public boolean numbersOnly = false;
|
||||||
private int posX,posY,width,height;
|
private int posX,posY,width,height;
|
||||||
@@ -307,4 +307,24 @@ public class GuiNpcTextArea extends GuiNpcTextField{
|
|||||||
}
|
}
|
||||||
drawTexturedModalRect(x, y, width, 11, 5, 1);
|
drawTexturedModalRect(x, y, width, 11, 5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getID() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int var1, int var2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return isFieldActive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
@@ -27,7 +31,7 @@ public class GuiNpcTextField extends GuiTextField{
|
|||||||
listener = (ITextfieldListener) parent;
|
listener = (ITextfieldListener) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActive(){
|
public static boolean isFieldActive(){
|
||||||
return activeTextfield != null;
|
return activeTextfield != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,473 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Gui;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.util.ChatAllowedCharacters;
|
||||||
|
import net.minecraftforge.client.GuiIngameForge;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.NoppesStringUtils;
|
||||||
|
import noppes.npcs.client.gui.util.TextContainer.LineData;
|
||||||
|
import noppes.npcs.config.TrueTypeFont;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
public class GuiTextArea extends Gui implements IGui, IKeyListener, IMouseListener {
|
||||||
|
public int id;
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
private int cursorCounter;
|
||||||
|
private ITextChangeListener listener;
|
||||||
|
private static TrueTypeFont font;
|
||||||
|
public String text = null;
|
||||||
|
private TextContainer container = null;
|
||||||
|
public boolean active = false;
|
||||||
|
public boolean enabled = true;
|
||||||
|
public boolean visible = true;
|
||||||
|
public boolean clicked = false;
|
||||||
|
public boolean doubleClicked = false;
|
||||||
|
public boolean clickScrolling = false;
|
||||||
|
private int startSelection;
|
||||||
|
private int endSelection;
|
||||||
|
private int cursorPosition;
|
||||||
|
private int scrolledLine = 0;
|
||||||
|
private boolean enableCodeHighlighting = false;
|
||||||
|
private static final char colorChar = '\uffff';
|
||||||
|
public List<GuiTextArea.UndoData> undoList = new ArrayList();
|
||||||
|
public List<GuiTextArea.UndoData> redoList = new ArrayList();
|
||||||
|
public boolean undoing = false;
|
||||||
|
private long lastClicked = 0L;
|
||||||
|
|
||||||
|
public GuiTextArea(int id, int x, int y, int width, int height, String text) {
|
||||||
|
this.id = id;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.undoing = true;
|
||||||
|
this.setText(text);
|
||||||
|
this.undoing = false;
|
||||||
|
font.setSpecial('\uffff');
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreen(int xMouse, int yMouse) {
|
||||||
|
if(this.visible) {
|
||||||
|
drawRect(this.x - 1, this.y - 1, this.x + this.width + 1, this.y + this.height + 1, -6250336);
|
||||||
|
drawRect(this.x, this.y, this.x + this.width, this.y + this.height, -16777216);
|
||||||
|
this.container.visibleLines = this.height / this.container.lineHeight;
|
||||||
|
int startBracket;
|
||||||
|
if(this.clicked) {
|
||||||
|
this.clicked = Mouse.isButtonDown(0);
|
||||||
|
startBracket = this.getSelectionPos(xMouse, yMouse);
|
||||||
|
if(startBracket != this.cursorPosition) {
|
||||||
|
if(this.doubleClicked) {
|
||||||
|
this.startSelection = this.endSelection = this.cursorPosition;
|
||||||
|
this.doubleClicked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setCursor(startBracket, true);
|
||||||
|
}
|
||||||
|
} else if(this.doubleClicked) {
|
||||||
|
this.doubleClicked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.clickScrolling) {
|
||||||
|
this.clickScrolling = Mouse.isButtonDown(0);
|
||||||
|
startBracket = this.container.linesCount - this.container.visibleLines;
|
||||||
|
this.scrolledLine = Math.min(Math.max((int)(1.0F * (float)startBracket * (float)(yMouse - this.y) / (float)this.height), 0), startBracket);
|
||||||
|
}
|
||||||
|
|
||||||
|
startBracket = 0;
|
||||||
|
int endBracket = 0;
|
||||||
|
if(this.endSelection - this.startSelection == 1 || this.startSelection == this.endSelection && this.startSelection < this.text.length()) {
|
||||||
|
char list = this.text.charAt(this.startSelection);
|
||||||
|
int wordHightLight = 0;
|
||||||
|
if(list == 123) {
|
||||||
|
wordHightLight = this.findClosingBracket(this.text.substring(this.startSelection), '{', '}');
|
||||||
|
} else if(list == 91) {
|
||||||
|
wordHightLight = this.findClosingBracket(this.text.substring(this.startSelection), '[', ']');
|
||||||
|
} else if(list == 40) {
|
||||||
|
wordHightLight = this.findClosingBracket(this.text.substring(this.startSelection), '(', ')');
|
||||||
|
} else if(list == 125) {
|
||||||
|
wordHightLight = this.findOpeningBracket(this.text.substring(0, this.startSelection + 1), '{', '}');
|
||||||
|
} else if(list == 93) {
|
||||||
|
wordHightLight = this.findOpeningBracket(this.text.substring(0, this.startSelection + 1), '[', ']');
|
||||||
|
} else if(list == 41) {
|
||||||
|
wordHightLight = this.findOpeningBracket(this.text.substring(0, this.startSelection + 1), '(', ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wordHightLight != 0) {
|
||||||
|
startBracket = this.startSelection;
|
||||||
|
endBracket = this.startSelection + wordHightLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList var15 = new ArrayList(this.container.lines);
|
||||||
|
String var18 = null;
|
||||||
|
if(this.startSelection != this.endSelection) {
|
||||||
|
Matcher sbSize = this.container.regexWord.matcher(this.text);
|
||||||
|
|
||||||
|
while(sbSize.find()) {
|
||||||
|
if(sbSize.start() == this.startSelection && sbSize.end() == this.endSelection) {
|
||||||
|
var18 = this.text.substring(this.startSelection, this.endSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int var16;
|
||||||
|
for(var16 = 0; var16 < var15.size(); ++var16) {
|
||||||
|
LineData posX = (LineData)var15.get(var16);
|
||||||
|
String posY = posX.text;
|
||||||
|
int w = posY.length();
|
||||||
|
int yPos;
|
||||||
|
int posX1;
|
||||||
|
int posY1;
|
||||||
|
if(startBracket != endBracket) {
|
||||||
|
if(startBracket >= posX.start && startBracket < posX.end) {
|
||||||
|
yPos = font.width(posY.substring(0, startBracket - posX.start));
|
||||||
|
posX1 = font.width(posY.substring(0, startBracket - posX.start + 1)) + 1;
|
||||||
|
posY1 = this.y + 1 + (var16 - this.scrolledLine) * this.container.lineHeight;
|
||||||
|
drawRect(this.x + 1 + yPos, posY1, this.x + 1 + posX1, posY1 + this.container.lineHeight + 1, -1728001024);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(endBracket >= posX.start && endBracket < posX.end) {
|
||||||
|
yPos = font.width(posY.substring(0, endBracket - posX.start));
|
||||||
|
posX1 = font.width(posY.substring(0, endBracket - posX.start + 1)) + 1;
|
||||||
|
posY1 = this.y + 1 + (var16 - this.scrolledLine) * this.container.lineHeight;
|
||||||
|
drawRect(this.x + 1 + yPos, posY1, this.x + 1 + posX1, posY1 + this.container.lineHeight + 1, -1728001024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var16 >= this.scrolledLine && var16 < this.scrolledLine + this.container.visibleLines) {
|
||||||
|
if(var18 != null) {
|
||||||
|
Matcher var20 = this.container.regexWord.matcher(posY);
|
||||||
|
|
||||||
|
while(var20.find()) {
|
||||||
|
if(posY.substring(var20.start(), var20.end()).equals(var18)) {
|
||||||
|
posX1 = font.width(posY.substring(0, var20.start()));
|
||||||
|
posY1 = font.width(posY.substring(0, var20.end())) + 1;
|
||||||
|
int posY2 = this.y + 1 + (var16 - this.scrolledLine) * this.container.lineHeight;
|
||||||
|
drawRect(this.x + 1 + posX1, posY2, this.x + 1 + posY1, posY2 + this.container.lineHeight + 1, -1728033792);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.startSelection != this.endSelection && this.endSelection > posX.start && this.startSelection <= posX.end && this.startSelection < posX.end) {
|
||||||
|
yPos = font.width(posY.substring(0, Math.max(this.startSelection - posX.start, 0)));
|
||||||
|
posX1 = font.width(posY.substring(0, Math.min(this.endSelection - posX.start, w))) + 1;
|
||||||
|
posY1 = this.y + 1 + (var16 - this.scrolledLine) * this.container.lineHeight;
|
||||||
|
drawRect(this.x + 1 + yPos, posY1, this.x + 1 + posX1, posY1 + this.container.lineHeight + 1, -1728052993);
|
||||||
|
}
|
||||||
|
|
||||||
|
yPos = this.y + (var16 - this.scrolledLine) * this.container.lineHeight + 1;
|
||||||
|
font.draw(posX.getFormattedString(), (float)(this.x + 1), (float)yPos, -2039584);
|
||||||
|
if(this.active && this.isEnabled() && this.cursorCounter / 6 % 2 == 0 && this.cursorPosition >= posX.start && this.cursorPosition < posX.end) {
|
||||||
|
posX1 = this.x + font.width(posY.substring(0, this.cursorPosition - posX.start));
|
||||||
|
drawRect(posX1 + 1, yPos, posX1 + 2, yPos + 1 + this.container.lineHeight, -3092272);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.hasVerticalScrollbar()) {
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource);
|
||||||
|
|
||||||
|
var16 = Math.max((int)(1.0F * (float)this.container.visibleLines / (float)this.container.linesCount * (float)this.height), 2);
|
||||||
|
int var17 = this.x + this.width - 6;
|
||||||
|
int var19 = (int)((float)this.y + 1.0F * (float)this.scrolledLine / (float)this.container.linesCount * (float)(this.height - 4)) + 1;
|
||||||
|
drawRect(var17, var19, var17 + 5, var19 + var16, -2039584);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findClosingBracket(String str, char s, char e) {
|
||||||
|
int found = 0;
|
||||||
|
char[] chars = str.toCharArray();
|
||||||
|
|
||||||
|
for(int i = 0; i < chars.length; ++i) {
|
||||||
|
char c = chars[i];
|
||||||
|
if(c == s) {
|
||||||
|
++found;
|
||||||
|
} else if(c == e) {
|
||||||
|
--found;
|
||||||
|
if(found == 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findOpeningBracket(String str, char s, char e) {
|
||||||
|
int found = 0;
|
||||||
|
char[] chars = str.toCharArray();
|
||||||
|
|
||||||
|
for(int i = chars.length - 1; i >= 0; --i) {
|
||||||
|
char c = chars[i];
|
||||||
|
if(c == e) {
|
||||||
|
++found;
|
||||||
|
} else if(c == s) {
|
||||||
|
--found;
|
||||||
|
if(found == 0) {
|
||||||
|
return i - chars.length + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSelectionPos(int xMouse, int yMouse) {
|
||||||
|
xMouse -= this.x + 1;
|
||||||
|
yMouse -= this.y + 1;
|
||||||
|
ArrayList list = new ArrayList(this.container.lines);
|
||||||
|
|
||||||
|
for(int i = 0; i < list.size(); ++i) {
|
||||||
|
LineData data = (LineData)list.get(i);
|
||||||
|
if(i >= this.scrolledLine && i < this.scrolledLine + this.container.visibleLines) {
|
||||||
|
int yPos = (i - this.scrolledLine) * this.container.lineHeight;
|
||||||
|
if(yMouse >= yPos && yMouse < yPos + this.container.lineHeight) {
|
||||||
|
int lineWidth = 0;
|
||||||
|
char[] chars = data.text.toCharArray();
|
||||||
|
|
||||||
|
for(int j = 1; j <= chars.length; ++j) {
|
||||||
|
int w = font.width(data.text.substring(0, j));
|
||||||
|
if(xMouse < lineWidth + (w - lineWidth) / 2) {
|
||||||
|
return data.start + j - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lineWidth = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.end - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.container.text.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void keyTyped(char c, int i) {
|
||||||
|
if(this.active && this.isEnabled()) {
|
||||||
|
if(i == 15) {
|
||||||
|
this.addText(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 28) {
|
||||||
|
this.addText(Character.toString('\n') + this.getIndentCurrentLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ChatAllowedCharacters.isAllowedCharacter(c)) {
|
||||||
|
this.addText(Character.toString(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getIndentCurrentLine() {
|
||||||
|
Iterator var1 = this.container.lines.iterator();
|
||||||
|
|
||||||
|
LineData data;
|
||||||
|
do {
|
||||||
|
if(!var1.hasNext()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
data = (LineData)var1.next();
|
||||||
|
} while(this.cursorPosition <= data.start || this.cursorPosition > data.end);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < data.text.length() && data.text.charAt(i) == 32; ++i) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.text.substring(0, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCursor(int i, boolean select) {
|
||||||
|
i = Math.min(Math.max(i, 0), this.text.length());
|
||||||
|
if(i != this.cursorPosition) {
|
||||||
|
if(!select) {
|
||||||
|
this.endSelection = this.startSelection = this.cursorPosition = i;
|
||||||
|
} else {
|
||||||
|
int diff = this.cursorPosition - i;
|
||||||
|
if(this.cursorPosition == this.startSelection) {
|
||||||
|
this.startSelection -= diff;
|
||||||
|
} else if(this.cursorPosition == this.endSelection) {
|
||||||
|
this.endSelection -= diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.startSelection > this.endSelection) {
|
||||||
|
int j = this.endSelection;
|
||||||
|
this.endSelection = this.startSelection;
|
||||||
|
this.startSelection = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cursorPosition = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addText(String s) {
|
||||||
|
this.setText(this.getSelectionBeforeText() + s + this.getSelectionAfterText());
|
||||||
|
this.endSelection = this.startSelection = this.cursorPosition = this.startSelection + s.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int cursorUp() {
|
||||||
|
for(int i = 0; i < this.container.lines.size(); ++i) {
|
||||||
|
LineData data = (LineData)this.container.lines.get(i);
|
||||||
|
if(this.cursorPosition >= data.start && this.cursorPosition < data.end) {
|
||||||
|
if(i == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int var10000 = this.cursorPosition - data.start;
|
||||||
|
return this.getSelectionPos(this.x + 1 + font.width(data.text.substring(0, this.cursorPosition - data.start)), this.y + 1 + (i - 1 - this.scrolledLine) * this.container.lineHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int cursorDown() {
|
||||||
|
for(int i = 0; i < this.container.lines.size(); ++i) {
|
||||||
|
LineData data = (LineData)this.container.lines.get(i);
|
||||||
|
if(this.cursorPosition >= data.start && this.cursorPosition < data.end) {
|
||||||
|
int var10000 = this.cursorPosition - data.start;
|
||||||
|
return this.getSelectionPos(this.x + 1 + font.width(data.text.substring(0, this.cursorPosition - data.start)), this.y + 1 + (i + 1 - this.scrolledLine) * this.container.lineHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.text.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionBeforeText() {
|
||||||
|
return this.startSelection == 0?"":this.text.substring(0, this.startSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionAfterText() {
|
||||||
|
return this.text.substring(this.endSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mouseClicked(int xMouse, int yMouse, int mouseButton) {
|
||||||
|
this.active = xMouse >= this.x && xMouse < this.x + this.width && yMouse >= this.y && yMouse < this.y + this.height;
|
||||||
|
if(this.active) {
|
||||||
|
this.startSelection = this.endSelection = this.cursorPosition = this.getSelectionPos(xMouse, yMouse);
|
||||||
|
this.clicked = mouseButton == 0;
|
||||||
|
this.doubleClicked = false;
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
if(this.clicked && this.container.linesCount * this.container.lineHeight > this.height && xMouse > this.x + this.width - 8) {
|
||||||
|
this.clicked = false;
|
||||||
|
this.clickScrolling = true;
|
||||||
|
} else if(time - this.lastClicked < 500L) {
|
||||||
|
this.doubleClicked = true;
|
||||||
|
Matcher m = this.container.regexWord.matcher(this.text);
|
||||||
|
|
||||||
|
while(m.find()) {
|
||||||
|
if(this.cursorPosition > m.start() && this.cursorPosition < m.end()) {
|
||||||
|
this.startSelection = m.start();
|
||||||
|
this.endSelection = m.end();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastClicked = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateScreen() {
|
||||||
|
++this.cursorCounter;
|
||||||
|
int k2 = Mouse.getDWheel();
|
||||||
|
if(k2 != 0) {
|
||||||
|
this.scrolledLine += k2 > 0?-1:1;
|
||||||
|
this.scrolledLine = Math.max(Math.min(this.scrolledLine, this.container.linesCount - this.height / this.container.lineHeight), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
text = text.replace("\r", "");
|
||||||
|
if(this.text == null || !this.text.equals(text)) {
|
||||||
|
if(this.listener != null) {
|
||||||
|
this.listener.textUpdate(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.undoing) {
|
||||||
|
this.undoList.add(new GuiTextArea.UndoData(this.text, this.cursorPosition));
|
||||||
|
this.redoList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.text = text;
|
||||||
|
this.container = new TextContainer(text);
|
||||||
|
this.container.init(font, this.width, this.height);
|
||||||
|
if(this.enableCodeHighlighting) {
|
||||||
|
this.container.formatCodeText();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.scrolledLine > this.container.linesCount - this.container.visibleLines) {
|
||||||
|
this.scrolledLine = Math.max(0, this.container.linesCount - this.container.visibleLines);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return this.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return this.enabled && this.visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasVerticalScrollbar() {
|
||||||
|
return this.container.visibleLines < this.container.linesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableCodeHighlighting() {
|
||||||
|
this.enableCodeHighlighting = true;
|
||||||
|
this.container.formatCodeText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListener(ITextChangeListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return this.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
font = new TrueTypeFont(new Font("Arial Unicode MS", 0, CustomNpcs.FontSize), 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UndoData {
|
||||||
|
public String text;
|
||||||
|
public int cursorPosition;
|
||||||
|
|
||||||
|
public UndoData(String text, int cursorPosition) {
|
||||||
|
this.text = text;
|
||||||
|
this.cursorPosition = cursorPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
public interface IGui {
|
||||||
|
int getID();
|
||||||
|
|
||||||
|
void drawScreen(int var1, int var2);
|
||||||
|
|
||||||
|
void updateScreen();
|
||||||
|
|
||||||
|
boolean isActive();
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
public interface IKeyListener {
|
||||||
|
void keyTyped(char var1, int var2);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
public interface IMouseListener {
|
||||||
|
boolean mouseClicked(int var1, int var2, int var3);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
public interface ITextChangeListener {
|
||||||
|
void textUpdate(String var1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.client.gui.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import noppes.npcs.config.TrueTypeFont;
|
||||||
|
|
||||||
|
public class TextContainer {
|
||||||
|
private static final char colorChar = '\uffff';
|
||||||
|
private static final Comparator<TextContainer.MarkUp> MarkUpComparator = (o1, o2) -> {
|
||||||
|
return o1.start > o2.start?1:(o1.start < o2.start?-1:0);
|
||||||
|
};
|
||||||
|
public final Pattern regexString = Pattern.compile("([\"\'])(?:(?=(\\\\?))\\2.)*?\\1", 8);
|
||||||
|
public final Pattern regexFunction = Pattern.compile("\\b(if|else|switch|with|for|while|in|var|const|let|throw|then|function|continue|break|foreach|return|try|catch|finally|do|this|typeof|instanceof|new)(?=[^\\w])");
|
||||||
|
public final Pattern regexWord = Pattern.compile("[\\p{L}-]+|\\n|$");
|
||||||
|
public final Pattern regexNumber = Pattern.compile("\\b-?(?:0[xX][\\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?(?:[fFbBdDlLsS])?|NaN|null|Infinity|unidentified|true|false)\\b");
|
||||||
|
public final Pattern regexComment = Pattern.compile("\\/\\*[\\s\\S]*?(?:\\*\\/|$)|\\/\\/.*|#.*");
|
||||||
|
public String text;
|
||||||
|
public List<TextContainer.MarkUp> makeup = new ArrayList();
|
||||||
|
public List<TextContainer.LineData> lines = new ArrayList();
|
||||||
|
private TrueTypeFont font;
|
||||||
|
public int lineHeight;
|
||||||
|
public int totalHeight;
|
||||||
|
public int visibleLines = 1;
|
||||||
|
public int linesCount;
|
||||||
|
|
||||||
|
public TextContainer(String text) {
|
||||||
|
this.text = text;
|
||||||
|
text.replaceAll("\\r?\\n|\\r", "\n");
|
||||||
|
double l = 1.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(TrueTypeFont font, int width, int height) {
|
||||||
|
this.font = font;
|
||||||
|
this.lineHeight = font.height(this.text);
|
||||||
|
if(this.lineHeight == 0) {
|
||||||
|
this.lineHeight = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] split = this.text.split("\n");
|
||||||
|
int totalChars = 0;
|
||||||
|
String[] var6 = split;
|
||||||
|
int var7 = split.length;
|
||||||
|
|
||||||
|
for(int var8 = 0; var8 < var7; ++var8) {
|
||||||
|
String l = var6[var8];
|
||||||
|
StringBuilder line = new StringBuilder();
|
||||||
|
Matcher m = this.regexWord.matcher(l);
|
||||||
|
|
||||||
|
for(int i = 0; m.find(); i = m.start()) {
|
||||||
|
String word = l.substring(i, m.start());
|
||||||
|
if(font.width(line + word) > width - 10) {
|
||||||
|
this.lines.add(new TextContainer.LineData(line.toString(), totalChars, totalChars + line.length()));
|
||||||
|
totalChars += line.length();
|
||||||
|
line = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
line.append(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lines.add(new TextContainer.LineData(line.toString(), totalChars, totalChars + line.length() + 1));
|
||||||
|
totalChars += line.length() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.linesCount = this.lines.size();
|
||||||
|
this.totalHeight = this.linesCount * this.lineHeight;
|
||||||
|
this.visibleLines = Math.max(height / this.lineHeight, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void formatCodeText() {
|
||||||
|
TextContainer.MarkUp markup = null;
|
||||||
|
|
||||||
|
for(int start = 0; (markup = this.getNextMatching(start)) != null; start = markup.end) {
|
||||||
|
this.makeup.add(markup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextContainer.MarkUp getNextMatching(int start) {
|
||||||
|
TextContainer.MarkUp markup = null;
|
||||||
|
String s = this.text.substring(start);
|
||||||
|
Matcher matcher = this.regexNumber.matcher(s);
|
||||||
|
if(matcher.find()) {
|
||||||
|
markup = new TextContainer.MarkUp(matcher.start(), matcher.end(), '6', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher = this.regexFunction.matcher(s);
|
||||||
|
TextContainer.MarkUp markup2;
|
||||||
|
if(matcher.find()) {
|
||||||
|
markup2 = new TextContainer.MarkUp(matcher.start(), matcher.end(), '2', 0);
|
||||||
|
if(this.compareMarkUps(markup, markup2)) {
|
||||||
|
markup = markup2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher = this.regexString.matcher(s);
|
||||||
|
if(matcher.find()) {
|
||||||
|
markup2 = new TextContainer.MarkUp(matcher.start(), matcher.end(), '4', 7);
|
||||||
|
if(this.compareMarkUps(markup, markup2)) {
|
||||||
|
markup = markup2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher = this.regexComment.matcher(s);
|
||||||
|
if(matcher.find()) {
|
||||||
|
markup2 = new TextContainer.MarkUp(matcher.start(), matcher.end(), '8', 7);
|
||||||
|
if(this.compareMarkUps(markup, markup2)) {
|
||||||
|
markup = markup2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(markup != null) {
|
||||||
|
markup.start += start;
|
||||||
|
markup.end += start;
|
||||||
|
}
|
||||||
|
|
||||||
|
return markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean compareMarkUps(TextContainer.MarkUp mu1, TextContainer.MarkUp mu2) {
|
||||||
|
return mu1 == null?true:mu1.start > mu2.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMakeUp(int start, int end, char c, int level) {
|
||||||
|
if(this.removeConflictingMarkUp(start, end, level)) {
|
||||||
|
this.makeup.add(new TextContainer.MarkUp(start, end, c, level));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean removeConflictingMarkUp(int start, int end, int level) {
|
||||||
|
ArrayList conflicting = new ArrayList();
|
||||||
|
Iterator var5 = this.makeup.iterator();
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
TextContainer.MarkUp m;
|
||||||
|
do {
|
||||||
|
if(!var5.hasNext()) {
|
||||||
|
this.makeup.removeAll(conflicting);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m = (TextContainer.MarkUp)var5.next();
|
||||||
|
} while((start < m.start || start > m.end) && (end < m.start || end > m.end) && (start >= m.start || end <= m.start));
|
||||||
|
|
||||||
|
if(level < m.level || level == m.level && m.start <= start) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
conflicting.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormattedString() {
|
||||||
|
StringBuilder builder = new StringBuilder(this.text);
|
||||||
|
Iterator var2 = this.makeup.iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
TextContainer.MarkUp entry = (TextContainer.MarkUp)var2.next();
|
||||||
|
builder.insert(entry.start, Character.toString('\uffff') + Character.toString(entry.c));
|
||||||
|
builder.insert(entry.end, Character.toString('\uffff') + Character.toString('r'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MarkUp {
|
||||||
|
public int start;
|
||||||
|
public int end;
|
||||||
|
public int level;
|
||||||
|
public char c;
|
||||||
|
|
||||||
|
public MarkUp(int start, int end, char c, int level) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.c = c;
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LineData {
|
||||||
|
public String text;
|
||||||
|
public int start;
|
||||||
|
public int end;
|
||||||
|
|
||||||
|
public LineData(String text, int start, int end) {
|
||||||
|
this.text = text;
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormattedString() {
|
||||||
|
StringBuilder builder = new StringBuilder(this.text);
|
||||||
|
int found = 0;
|
||||||
|
Iterator var3 = TextContainer.this.makeup.iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
TextContainer.MarkUp entry = (TextContainer.MarkUp)var3.next();
|
||||||
|
if(entry.start >= this.start && entry.start < this.end) {
|
||||||
|
builder.insert(entry.start - this.start + found * 2, Character.toString('\uffff') + Character.toString(entry.c));
|
||||||
|
++found;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entry.start < this.start && entry.end > this.start) {
|
||||||
|
builder.insert(0, Character.toString('\uffff') + Character.toString(entry.c));
|
||||||
|
++found;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entry.end >= this.start && entry.end < this.end) {
|
||||||
|
builder.insert(entry.end - this.start + found * 2, Character.toString('\uffff') + Character.toString('r'));
|
||||||
|
++found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,9 @@ import net.minecraft.client.model.ModelBiped;
|
|||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import noppes.npcs.CustomItems;
|
||||||
import noppes.npcs.ModelPartConfig;
|
import noppes.npcs.ModelPartConfig;
|
||||||
import noppes.npcs.ModelPartData;
|
import noppes.npcs.ModelPartData;
|
||||||
import noppes.npcs.client.ClientProxy;
|
import noppes.npcs.client.ClientProxy;
|
||||||
@@ -294,6 +296,9 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
@Override
|
@Override
|
||||||
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7){
|
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7){
|
||||||
EntityCustomNpc npc = (EntityCustomNpc) par1Entity;
|
EntityCustomNpc npc = (EntityCustomNpc) par1Entity;
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
if(npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && (player.getHeldItem() == null || player.getHeldItem().getItem() != CustomItems.wand))
|
||||||
|
return;
|
||||||
|
|
||||||
if(entityModel != null){
|
if(entityModel != null){
|
||||||
if(!isArmor){
|
if(!isArmor){
|
||||||
@@ -311,7 +316,8 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
alpha = npc.isInvisible() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)?0.15f:1;
|
alpha = npc.isInvisible() && !npc.isInvisibleToPlayer(player) ? 0.15f : 1;
|
||||||
|
|
||||||
setPlayerData(npc);
|
setPlayerData(npc);
|
||||||
currentlyPlayerTexture = true;
|
currentlyPlayerTexture = true;
|
||||||
setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
|
setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
|
||||||
|
|||||||
@@ -348,11 +348,11 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
||||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
||||||
|
|
||||||
if(itemstack2.getItem() instanceof ItemShield || itemstack2.getItem() instanceof ItemClaw)
|
Class<?> clazz = itemstack2.getItem().getClass();
|
||||||
|
if(clazz.getSimpleName().equals("ItemShield") || clazz.getSimpleName().equals("ItemRotatedShield") || clazz.getSimpleName().equals("ItemClaw"))
|
||||||
GL11.glTranslatef(0.30f, 0, 0f);
|
GL11.glTranslatef(0.30f, 0, 0f);
|
||||||
|
|
||||||
|
|
||||||
if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType())))
|
if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType())))
|
||||||
{
|
{
|
||||||
var6 = 0.5F;
|
var6 = 0.5F;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,340 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.config;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.util.LRUHashMap;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class TrueTypeFont {
|
||||||
|
private static final int MaxWidth = 512;
|
||||||
|
private static final List<Font> allFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts());
|
||||||
|
private List<Font> usedFonts = new ArrayList();
|
||||||
|
private LinkedHashMap<String, TrueTypeFont.GlyphCache> textcache = new LRUHashMap(100);
|
||||||
|
private Map<Character, TrueTypeFont.Glyph> glyphcache = new HashMap();
|
||||||
|
private List<TrueTypeFont.TextureCache> textures = new ArrayList();
|
||||||
|
private Font font;
|
||||||
|
private int lineHeight = 1;
|
||||||
|
private Graphics2D globalG = (Graphics2D)(new BufferedImage(1, 1, 2)).getGraphics();
|
||||||
|
public float scale = 1.0F;
|
||||||
|
private int specialChar = 167;
|
||||||
|
|
||||||
|
public TrueTypeFont(Font font, float scale) {
|
||||||
|
this.font = font;
|
||||||
|
this.scale = scale;
|
||||||
|
this.globalG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
this.lineHeight = this.globalG.getFontMetrics(font).getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrueTypeFont(ResourceLocation resource, int fontSize, float scale) throws IOException, FontFormatException {
|
||||||
|
InputStream stream = Minecraft.getMinecraft().getResourceManager().getResource(resource).getInputStream();
|
||||||
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
Font font = Font.createFont(0, stream);
|
||||||
|
ge.registerFont(font);
|
||||||
|
this.font = font.deriveFont(0, (float)fontSize);
|
||||||
|
this.scale = scale;
|
||||||
|
this.globalG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
this.lineHeight = this.globalG.getFontMetrics(font).getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecial(char c) {
|
||||||
|
this.specialChar = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(String text, float x, float y, int color) {
|
||||||
|
TrueTypeFont.GlyphCache cache = this.getOrCreateCache(text);
|
||||||
|
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||||
|
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||||
|
float b = (float)(color & 255) / 255.0F;
|
||||||
|
GL11.glColor4f(r, g, b, 1.0F);
|
||||||
|
//GlStateManager.func_179147_l();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef(x, y, 0.0F);
|
||||||
|
GL11.glScalef(this.scale, this.scale, 1.0F);
|
||||||
|
float i = 0.0F;
|
||||||
|
Iterator var10 = cache.glyphs.iterator();
|
||||||
|
|
||||||
|
while(var10.hasNext()) {
|
||||||
|
TrueTypeFont.Glyph gl = (TrueTypeFont.Glyph)var10.next();
|
||||||
|
if(gl.type != TrueTypeFont.GlyphType.NORMAL) {
|
||||||
|
if(gl.type == TrueTypeFont.GlyphType.RESET) {
|
||||||
|
GL11.glColor4f(r, g, b, 1.0F);
|
||||||
|
} else if(gl.type == TrueTypeFont.GlyphType.COLOR) {
|
||||||
|
GL11.glColor4f((float) (gl.color >> 16 & 255) / 255.0F, (float) (gl.color >> 8 & 255) / 255.0F, (float) (gl.color & 255) / 255.0F, 1.0F);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GL11.glBindTexture(gl.texture, gl.texture);
|
||||||
|
this.drawTexturedModalRect(i, 0.0F, (float)gl.x * this.textureScale(), (float)gl.y * this.textureScale(), (float)gl.width * this.textureScale(), (float)gl.height * this.textureScale());
|
||||||
|
i += (float)gl.width * this.textureScale();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//GlStateManager.func_179084_k();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrueTypeFont.GlyphCache getOrCreateCache(String text) {
|
||||||
|
TrueTypeFont.GlyphCache cache = (TrueTypeFont.GlyphCache)this.textcache.get(text);
|
||||||
|
if(cache != null) {
|
||||||
|
return cache;
|
||||||
|
} else {
|
||||||
|
cache = new TrueTypeFont.GlyphCache();
|
||||||
|
|
||||||
|
for(int i = 0; i < text.length(); ++i) {
|
||||||
|
char c = text.charAt(i);
|
||||||
|
if(c == this.specialChar && i + 1 < text.length()) {
|
||||||
|
char g = text.toLowerCase(Locale.ENGLISH).charAt(i + 1);
|
||||||
|
int index = "0123456789abcdefklmnor".indexOf(g);
|
||||||
|
if(index >= 0) {
|
||||||
|
TrueTypeFont.Glyph g1 = new TrueTypeFont.Glyph();
|
||||||
|
if(index < 16) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.COLOR;
|
||||||
|
//g1.color = Minecraft.getMinecraft().fontRenderer.func_175064_b(g);
|
||||||
|
g1.color = 0;
|
||||||
|
} else if(index == 16) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.RANDOM;
|
||||||
|
} else if(index == 17) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.BOLD;
|
||||||
|
} else if(index == 18) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.STRIKETHROUGH;
|
||||||
|
} else if(index == 19) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.UNDERLINE;
|
||||||
|
} else if(index == 20) {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.ITALIC;
|
||||||
|
} else {
|
||||||
|
g1.type = TrueTypeFont.GlyphType.RESET;
|
||||||
|
}
|
||||||
|
|
||||||
|
cache.glyphs.add(g1);
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TrueTypeFont.Glyph var8 = this.getOrCreateGlyph(c);
|
||||||
|
cache.glyphs.add(var8);
|
||||||
|
cache.width += var8.width;
|
||||||
|
cache.height = Math.max(cache.height, var8.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.textcache.put(text, cache);
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrueTypeFont.Glyph getOrCreateGlyph(char c) {
|
||||||
|
TrueTypeFont.Glyph g = (TrueTypeFont.Glyph)this.glyphcache.get(Character.valueOf(c));
|
||||||
|
if(g != null) {
|
||||||
|
return g;
|
||||||
|
} else {
|
||||||
|
TrueTypeFont.TextureCache cache = this.getCurrentTexture();
|
||||||
|
Font font = this.getFontForChar(c);
|
||||||
|
FontMetrics metrics = this.globalG.getFontMetrics(font);
|
||||||
|
g = new TrueTypeFont.Glyph();
|
||||||
|
g.width = Math.max(metrics.charWidth(c), 1);
|
||||||
|
g.height = Math.max(metrics.getHeight(), 1);
|
||||||
|
if(cache.x + g.width >= 512) {
|
||||||
|
cache.x = 0;
|
||||||
|
cache.y += this.lineHeight + 1;
|
||||||
|
if(cache.y >= 512) {
|
||||||
|
cache.full = true;
|
||||||
|
cache = this.getCurrentTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g.x = cache.x;
|
||||||
|
g.y = cache.y;
|
||||||
|
cache.x += g.width + 3;
|
||||||
|
this.lineHeight = Math.max(this.lineHeight, g.height);
|
||||||
|
cache.g.setFont(font);
|
||||||
|
cache.g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
cache.g.drawString(c + "", g.x, g.y + metrics.getAscent());
|
||||||
|
g.texture = cache.textureId;
|
||||||
|
TextureUtil.uploadTextureImage(cache.textureId, cache.bufferedImage);
|
||||||
|
this.glyphcache.put(Character.valueOf(c), g);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TrueTypeFont.TextureCache getCurrentTexture() {
|
||||||
|
TrueTypeFont.TextureCache cache = null;
|
||||||
|
Iterator var2 = this.textures.iterator();
|
||||||
|
|
||||||
|
while(var2.hasNext()) {
|
||||||
|
TrueTypeFont.TextureCache t = (TrueTypeFont.TextureCache)var2.next();
|
||||||
|
if(!t.full) {
|
||||||
|
cache = t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cache == null) {
|
||||||
|
this.textures.add(cache = new TrueTypeFont.TextureCache());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCentered(String text, float x, float y, int color) {
|
||||||
|
this.draw(text, x - (float)this.width(text) / 2.0F, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Font getFontForChar(char c) {
|
||||||
|
if(this.font.canDisplay(c)) {
|
||||||
|
return this.font;
|
||||||
|
} else {
|
||||||
|
Iterator fa = this.usedFonts.iterator();
|
||||||
|
|
||||||
|
Font f;
|
||||||
|
do {
|
||||||
|
if(!fa.hasNext()) {
|
||||||
|
Font fa1 = new Font("Arial Unicode MS", 0, this.font.getSize());
|
||||||
|
if(fa1.canDisplay(c)) {
|
||||||
|
return fa1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator f2 = allFonts.iterator();
|
||||||
|
|
||||||
|
Font f1;
|
||||||
|
do {
|
||||||
|
if(!f2.hasNext()) {
|
||||||
|
return this.font;
|
||||||
|
}
|
||||||
|
|
||||||
|
f1 = (Font)f2.next();
|
||||||
|
} while(!f1.canDisplay(c));
|
||||||
|
|
||||||
|
this.usedFonts.add(f1 = f1.deriveFont(0, (float)this.font.getSize()));
|
||||||
|
return f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = (Font)fa.next();
|
||||||
|
} while(!f.canDisplay(c));
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawTexturedModalRect(float p_73729_1_, float p_73729_2_, float p_73729_3_, float p_73729_4_, float p_73729_5_, float p_73729_6_)
|
||||||
|
{
|
||||||
|
float f = 0.00390625F;
|
||||||
|
float f1 = 0.00390625F;
|
||||||
|
byte zLevel = 0;
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||||
|
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||||
|
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||||
|
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||||
|
tessellator.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int width(String text) {
|
||||||
|
TrueTypeFont.GlyphCache cache = this.getOrCreateCache(text);
|
||||||
|
return (int)((float)cache.width * this.scale * this.textureScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int height(String text) {
|
||||||
|
if(text != null && !text.trim().isEmpty()) {
|
||||||
|
TrueTypeFont.GlyphCache cache = this.getOrCreateCache(text);
|
||||||
|
return Math.max(1, (int)((float)cache.height * this.scale * this.textureScale()));
|
||||||
|
} else {
|
||||||
|
return (int)((float)this.lineHeight * this.scale * this.textureScale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float textureScale() {
|
||||||
|
return 0.5F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
Iterator var1 = this.textures.iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
TrueTypeFont.TextureCache cache = (TrueTypeFont.TextureCache)var1.next();
|
||||||
|
GL11.glDeleteTextures(cache.textureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.textcache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFontName() {
|
||||||
|
return this.font.getFontName();
|
||||||
|
}
|
||||||
|
|
||||||
|
class GlyphCache {
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
List<TrueTypeFont.Glyph> glyphs = new ArrayList();
|
||||||
|
|
||||||
|
GlyphCache() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Glyph {
|
||||||
|
TrueTypeFont.GlyphType type;
|
||||||
|
int color;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int height;
|
||||||
|
int width;
|
||||||
|
int texture;
|
||||||
|
|
||||||
|
Glyph() {
|
||||||
|
this.type = TrueTypeFont.GlyphType.NORMAL;
|
||||||
|
this.color = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TextureCache {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int textureId = GL11.glGenTextures();
|
||||||
|
BufferedImage bufferedImage = new BufferedImage(512, 512, 2);
|
||||||
|
Graphics2D g;
|
||||||
|
boolean full;
|
||||||
|
|
||||||
|
TextureCache() {
|
||||||
|
this.g = (Graphics2D)this.bufferedImage.getGraphics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum GlyphType {
|
||||||
|
NORMAL,
|
||||||
|
COLOR,
|
||||||
|
RANDOM,
|
||||||
|
BOLD,
|
||||||
|
STRIKETHROUGH,
|
||||||
|
UNDERLINE,
|
||||||
|
ITALIC,
|
||||||
|
RESET,
|
||||||
|
OTHER;
|
||||||
|
|
||||||
|
private GlyphType() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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, 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
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package noppes.npcs.constants;
|
package noppes.npcs.constants;
|
||||||
|
|
||||||
public enum EnumPacketClient {
|
public enum EnumPacketClient {
|
||||||
CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG
|
CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,12 @@ public enum EnumPacketServer {
|
|||||||
|
|
||||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList,
|
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList,
|
||||||
|
|
||||||
|
ScriptPlayerSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
|
ScriptPlayerGet(false),
|
||||||
|
|
||||||
|
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
|
ScriptForgeGet(false),
|
||||||
|
|
||||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||||
@@ -70,7 +76,7 @@ public enum EnumPacketServer {
|
|||||||
RemoteTpToNpc,QuestGet, QuestCategoryGet,
|
RemoteTpToNpc,QuestGet, QuestCategoryGet,
|
||||||
SaveTileEntity,
|
SaveTileEntity,
|
||||||
NaturalSpawnGetAll, MailOpenSetup,
|
NaturalSpawnGetAll, MailOpenSetup,
|
||||||
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, ;
|
DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen;
|
||||||
|
|
||||||
public CustomNpcsPermissions.Permission permission = null;
|
public CustomNpcsPermissions.Permission permission = null;
|
||||||
public boolean needsNpc = false;
|
public boolean needsNpc = false;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package noppes.npcs.constants;
|
package noppes.npcs.constants;
|
||||||
|
|
||||||
public enum EnumPlayerPacket {
|
public enum EnumPlayerPacket {
|
||||||
FollowerHire,FollowerExtend,Trader, FollowerState, Transport, BankUnlock, BankUpgrade, Dialog, QuestLog, QuestCompletion, CheckQuestCompletion, BankSlotOpen, FactionsGet, MailGet, MailDelete, MailSend, MailRead, MailboxOpenMail, SignSave, SaveBook, CompanionOpenInv, RoleGet, CompanionTalentExp
|
FollowerHire,FollowerExtend,Trader, FollowerState, Transport, BankUnlock, BankUpgrade, Dialog, QuestLog, QuestCompletion, CheckQuestCompletion, BankSlotOpen, FactionsGet, MailGet, MailDelete, MailSend, MailRead, MailboxOpenMail, SignSave, SaveBook, CompanionOpenInv, RoleGet, KeyPressed, MouseClicked, CompanionTalentExp
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,86 @@
|
|||||||
package noppes.npcs.constants;
|
package noppes.npcs.constants;
|
||||||
|
|
||||||
public enum EnumScriptType {
|
public enum EnumScriptType {
|
||||||
INIT, TICK, INTERACT, DIALOG, DAMAGED, KILLED, ATTACK, TARGET, COLLIDE, KILLS, DIALOG_OPTION
|
INIT("init"),
|
||||||
}
|
TICK("tick"),
|
||||||
|
INTERACT("interact"),
|
||||||
|
DIALOG("dialog"),
|
||||||
|
DAMAGED("damaged"),
|
||||||
|
KILLED("killed"),
|
||||||
|
ATTACK("attack"),
|
||||||
|
TARGET("target"),
|
||||||
|
COLLIDE("collide"),
|
||||||
|
KILLS("kills"),
|
||||||
|
DIALOG_OPTION("dialogOption"),
|
||||||
|
TIMER("timer"),
|
||||||
|
|
||||||
|
ATTACK_MELEE("meleeAttack"),
|
||||||
|
TARGET_LOST("targetLost"),
|
||||||
|
ROLE("role"),
|
||||||
|
RANGED_CHARGE("rangedCharge"),
|
||||||
|
RANGED_LAUNCHED("rangedLaunched"),
|
||||||
|
CLICKED("clicked"),
|
||||||
|
FALLEN_UPON("fallenUpon"),
|
||||||
|
RAIN_FILLED("rainFilled"),
|
||||||
|
BROKEN("broken"),
|
||||||
|
HARVESTED("harvested"),
|
||||||
|
EXPLODED("exploded"),
|
||||||
|
NEIGHBOR_CHANGED("neighborChanged"),
|
||||||
|
REDSTONE("redstone"),
|
||||||
|
DOOR_TOGGLE("doorToggle"),
|
||||||
|
TOSS("toss"),
|
||||||
|
DROP("drop"),
|
||||||
|
CONTAINER_OPEN("containerOpen"),
|
||||||
|
CONTAINER_CLOSED("containerClosed"),
|
||||||
|
LOGIN("login"),
|
||||||
|
LOGOUT("logout"),
|
||||||
|
CHAT("chat"),
|
||||||
|
DAMAGED_ENTITY("damagedEntity"),
|
||||||
|
DIALOG_CLOSE("dialogClose"),
|
||||||
|
SPAWN("spawn"),
|
||||||
|
TOSSED("tossed"),
|
||||||
|
PICKEDUP("pickedUp"),
|
||||||
|
PICKUP("pickUp"),
|
||||||
|
PROJECTILE_TICK("projectileTick"),
|
||||||
|
PROJECTILE_IMPACT("projectileImpact"),
|
||||||
|
LEVEL_UP("levelUp"),
|
||||||
|
QUEST_START("questStart"),
|
||||||
|
QUEST_COMPLETED("questCompleted"),
|
||||||
|
QUEST_TURNIN("questTurnIn"),
|
||||||
|
KEY_PRESSED("keyPressed"),
|
||||||
|
CUSTOM_CHEST_CLOSED("customChestClosed"),
|
||||||
|
CUSTOM_CHEST_CLICKED("customChestClicked"),
|
||||||
|
SCRIPT_COMMAND("scriptCommand"),
|
||||||
|
CUSTOM_GUI_CLOSED("customGuiClosed"),
|
||||||
|
CUSTOM_GUI_BUTTON("customGuiButton"),
|
||||||
|
CUSTOM_GUI_SLOT("customGuiSlot"),
|
||||||
|
CUSTOM_GUI_SCROLL("customGuiScroll"),
|
||||||
|
PICKUP_XP("pickupXP"),
|
||||||
|
MOUSE_CLICKED("mouseClicked"),
|
||||||
|
START_USING_ITEM("startItem"),
|
||||||
|
USING_ITEM("usingItem"),
|
||||||
|
STOP_USING_ITEM("stopItem"),
|
||||||
|
FINISH_USING_ITEM("finishItem"),
|
||||||
|
USE_HOE("useHoe"),
|
||||||
|
SLEEP("sleep"),
|
||||||
|
WAKE_UP("wakeUp"),
|
||||||
|
FILL_BUCKET("fillBucket"),
|
||||||
|
BONEMEAL("bonemeal"),
|
||||||
|
ACHIEVEMENT("achievement"),
|
||||||
|
FALL("fall"),
|
||||||
|
JUMP("jump"),
|
||||||
|
LIGHTNING("lightning"),
|
||||||
|
PLAYSOUND("playSound"),
|
||||||
|
RESPAWN("respawn"),
|
||||||
|
CHANGED_DIM("changedDim"),
|
||||||
|
BREAK_BLOCK("breakBlock"),
|
||||||
|
FORGE_INIT("forgeInit"),
|
||||||
|
FORGE_ENTITY("forgeEntity"),
|
||||||
|
FORGE_WORLD("forgeWorld");
|
||||||
|
|
||||||
|
public String function;
|
||||||
|
|
||||||
|
private EnumScriptType(String function) {
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,13 @@ package noppes.npcs.containers;
|
|||||||
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.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import noppes.npcs.scripted.interfaces.IContainer;
|
||||||
|
import noppes.npcs.scripted.ScriptContainer;
|
||||||
|
|
||||||
public class ContainerNpcInterface extends Container{
|
public class ContainerNpcInterface extends Container{
|
||||||
private int posX, posZ;
|
private int posX, posZ;
|
||||||
|
public EntityPlayer player;
|
||||||
|
public IContainer scriptContainer;
|
||||||
|
|
||||||
public ContainerNpcInterface(EntityPlayer player){
|
public ContainerNpcInterface(EntityPlayer player){
|
||||||
posX = MathHelper.floor_double(player.posX);
|
posX = MathHelper.floor_double(player.posX);
|
||||||
@@ -18,4 +22,11 @@ public class ContainerNpcInterface extends Container{
|
|||||||
return !player.isDead && posX == MathHelper.floor_double(player.posX) && posZ == MathHelper.floor_double(player.posZ);
|
return !player.isDead && posX == MathHelper.floor_double(player.posX) && posZ == MathHelper.floor_double(player.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IContainer getOrCreateIContainer(ContainerNpcInterface container) {
|
||||||
|
if (container.scriptContainer != null) {
|
||||||
|
return container.scriptContainer;
|
||||||
|
} else {
|
||||||
|
return container.scriptContainer = new ScriptContainer(container);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
|
||||||
|
public interface IScriptHandler {
|
||||||
|
void callScript(EnumScriptType var1, Event var2);
|
||||||
|
|
||||||
|
boolean isClient();
|
||||||
|
|
||||||
|
boolean getEnabled();
|
||||||
|
|
||||||
|
void setEnabled(boolean var1);
|
||||||
|
|
||||||
|
String getLanguage();
|
||||||
|
|
||||||
|
void setLanguage(String var1);
|
||||||
|
|
||||||
|
List<ScriptContainer> getScripts();
|
||||||
|
|
||||||
|
String noticeString();
|
||||||
|
|
||||||
|
Map<Long, String> getConsoleText();
|
||||||
|
|
||||||
|
void clearConsole();
|
||||||
|
}
|
||||||
@@ -2,13 +2,23 @@ package noppes.npcs.controllers;
|
|||||||
|
|
||||||
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.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.constants.EnumRoleType;
|
import noppes.npcs.constants.EnumRoleType;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.entity.data.DataTimers;
|
||||||
import noppes.npcs.roles.RoleCompanion;
|
import noppes.npcs.roles.RoleCompanion;
|
||||||
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
public class PlayerData implements IExtendedEntityProperties{
|
public class PlayerData implements IExtendedEntityProperties{
|
||||||
public PlayerDialogData dialogData = new PlayerDialogData();
|
public PlayerDialogData dialogData = new PlayerDialogData();
|
||||||
@@ -18,7 +28,8 @@ 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 DataTimers timers = new DataTimers(this);
|
||||||
|
|
||||||
public EntityNPCInterface editingNpc;
|
public EntityNPCInterface editingNpc;
|
||||||
public NBTTagCompound cloned;
|
public NBTTagCompound cloned;
|
||||||
|
|
||||||
@@ -26,10 +37,12 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
|
|
||||||
public String playername = "";
|
public String playername = "";
|
||||||
public String uuid = "";
|
public String uuid = "";
|
||||||
|
|
||||||
private EntityNPCInterface activeCompanion = null;
|
private EntityNPCInterface activeCompanion = null;
|
||||||
public int companionID = 0;
|
public int companionID = 0;
|
||||||
|
|
||||||
|
public boolean isGUIOpen = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveNBTData(NBTTagCompound compound) {
|
public void saveNBTData(NBTTagCompound compound) {
|
||||||
PlayerDataController.instance.savePlayerData(this);
|
PlayerDataController.instance.savePlayerData(this);
|
||||||
@@ -51,8 +64,8 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
transportData.loadNBTData(data);
|
transportData.loadNBTData(data);
|
||||||
factionData.loadNBTData(data);
|
factionData.loadNBTData(data);
|
||||||
itemgiverData.loadNBTData(data);
|
itemgiverData.loadNBTData(data);
|
||||||
mailData.loadNBTData(data);
|
mailData.loadNBTData(data);
|
||||||
|
timers.readFromNBT(data);
|
||||||
|
|
||||||
if(player != null){
|
if(player != null){
|
||||||
playername = player.getCommandSenderName();
|
playername = player.getCommandSenderName();
|
||||||
@@ -73,6 +86,7 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
player.worldObj.spawnEntityInWorld(npc);
|
player.worldObj.spawnEntityInWorld(npc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isGUIOpen = data.getBoolean("isGUIOpen");
|
||||||
}
|
}
|
||||||
public NBTTagCompound getNBT() {
|
public NBTTagCompound getNBT() {
|
||||||
if(player != null){
|
if(player != null){
|
||||||
@@ -87,10 +101,12 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
factionData.saveNBTData(compound);
|
factionData.saveNBTData(compound);
|
||||||
itemgiverData.saveNBTData(compound);
|
itemgiverData.saveNBTData(compound);
|
||||||
mailData.saveNBTData(compound);
|
mailData.saveNBTData(compound);
|
||||||
|
timers.writeToNBT(compound);
|
||||||
|
|
||||||
compound.setString("PlayerName", playername);
|
compound.setString("PlayerName", playername);
|
||||||
compound.setString("UUID", uuid);
|
compound.setString("UUID", uuid);
|
||||||
compound.setInteger("PlayerCompanionId", companionID);
|
compound.setInteger("PlayerCompanionId", companionID);
|
||||||
|
compound.setBoolean("isGUIOpen",isGUIOpen);
|
||||||
|
|
||||||
if(hasCompanion()){
|
if(hasCompanion()){
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
@@ -104,7 +120,17 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
public void init(Entity entity, World world) {
|
public void init(Entity entity, World world) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGUIOpen(boolean bool) {
|
||||||
|
isGUIOpen = bool;
|
||||||
|
saveNBTData(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getGUIOpen() {
|
||||||
|
loadNBTData(null);
|
||||||
|
return isGUIOpen;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasCompanion(){
|
public boolean hasCompanion(){
|
||||||
return activeCompanion != null && !activeCompanion.isDead;
|
return activeCompanion != null && !activeCompanion.isDead;
|
||||||
}
|
}
|
||||||
@@ -138,4 +164,82 @@ public class PlayerData implements IExtendedEntityProperties{
|
|||||||
world.spawnEntityInWorld(npc);
|
world.spawnEntityInWorld(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NBTTagCompound loadPlayerDataOld(String player) {
|
||||||
|
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
|
||||||
|
String filename = player;
|
||||||
|
if (player.isEmpty()) {
|
||||||
|
filename = "noplayername";
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = filename + ".dat";
|
||||||
|
|
||||||
|
File file;
|
||||||
|
try {
|
||||||
|
file = new File(saveDir, filename);
|
||||||
|
if (file.exists()) {
|
||||||
|
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||||
|
file.delete();
|
||||||
|
file = new File(saveDir, filename + "_old");
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
} catch (Exception var6) {
|
||||||
|
LogWriter.except(var6);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
file = new File(saveDir, filename + "_old");
|
||||||
|
if (file.exists()) {
|
||||||
|
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||||
|
}
|
||||||
|
} catch (Exception var5) {
|
||||||
|
LogWriter.except(var5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NBTTagCompound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagCompound loadPlayerData(String player) {
|
||||||
|
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
|
||||||
|
String filename = player;
|
||||||
|
if (player.isEmpty()) {
|
||||||
|
filename = "noplayername";
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = filename + ".json";
|
||||||
|
File file = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
file = new File(saveDir, filename);
|
||||||
|
if (file.exists()) {
|
||||||
|
return NBTJsonUtil.LoadFile(file);
|
||||||
|
}
|
||||||
|
} catch (Exception var5) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), var5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NBTTagCompound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerData get(EntityPlayer player) {
|
||||||
|
if(player.worldObj.isRemote) {
|
||||||
|
return CustomNpcs.proxy.getPlayerData(player);
|
||||||
|
} else {
|
||||||
|
PlayerData data = new PlayerData();
|
||||||
|
if (data.player == null) {
|
||||||
|
data.player = player;
|
||||||
|
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
|
||||||
|
if (compound.hasNoTags()) {
|
||||||
|
compound = loadPlayerDataOld(player.getCommandSenderName());
|
||||||
|
}
|
||||||
|
|
||||||
|
data.setNBT(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,94 +1,181 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.script.Compilable;
|
import javax.script.Compilable;
|
||||||
import javax.script.CompiledScript;
|
import javax.script.CompiledScript;
|
||||||
|
import javax.script.Invocable;
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptException;
|
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
|
import noppes.npcs.NoppesUtilServer;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import scala.Char;
|
||||||
|
|
||||||
public class ScriptContainer {
|
public class ScriptContainer {
|
||||||
public String fullscript = "";
|
private static final String lock = "lock";
|
||||||
public String script = "";
|
public static ScriptContainer Current;
|
||||||
public String console = "";
|
private static String CurrentType;
|
||||||
public boolean errored = false;
|
private static final HashMap<String, Object> Data = new HashMap();
|
||||||
public List<String> scripts = new ArrayList<String>();
|
public String fullscript = "";
|
||||||
private long lastCreated = 0;
|
public String script = "";
|
||||||
private CompiledScript compScript = null;
|
public TreeMap<Long, String> console = new TreeMap();
|
||||||
private String currentScriptLanguage = null;
|
public boolean errored = false;
|
||||||
public ScriptEngine engine = null;
|
public List<String> scripts = new ArrayList();
|
||||||
|
private HashSet<String> unknownFunctions = new HashSet();
|
||||||
|
public long lastCreated = 0L;
|
||||||
|
private String currentScriptLanguage = null;
|
||||||
|
public ScriptEngine engine = null;
|
||||||
|
private IScriptHandler handler = null;
|
||||||
|
private boolean init = false;
|
||||||
|
private static Method luaCoerce;
|
||||||
|
private static Method luaCall;
|
||||||
|
private CompiledScript compScript = null;
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public ScriptContainer(IScriptHandler handler) {
|
||||||
script = compound.getString("Script");
|
this.handler = handler;
|
||||||
console = compound.getString("ScriptConsole");
|
}
|
||||||
scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
|
|
||||||
lastCreated = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
compound.setString("Script", script);
|
this.script = compound.getString("Script");
|
||||||
compound.setString("ScriptConsole", console);
|
//this.type = compound.getString("Type");
|
||||||
compound.setTag("ScriptList", NBTTags.nbtStringList(scripts));
|
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
|
||||||
}
|
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
|
||||||
|
this.lastCreated = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||||
if(ScriptController.Instance.lastLoaded > lastCreated){
|
compound.setString("Script", this.script);
|
||||||
lastCreated = ScriptController.Instance.lastLoaded;
|
//compound.setString("Type", this.type);
|
||||||
fullscript = script;
|
compound.setTag("Console", NBTTags.NBTLongStringMap(this.console));
|
||||||
if(!fullscript.isEmpty())
|
compound.setTag("ScriptList", NBTTags.nbtStringList(this.scripts));
|
||||||
fullscript += "\n";
|
return compound;
|
||||||
for(String loc : scripts){
|
}
|
||||||
String code = ScriptController.Instance.scripts.get(loc);
|
|
||||||
if(code != null && !code.isEmpty())
|
|
||||||
fullscript += code + "\n";
|
|
||||||
}
|
|
||||||
compScript = null;
|
|
||||||
}
|
|
||||||
return 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(getCode());
|
|
||||||
|
|
||||||
if(compScript != null){
|
|
||||||
compScript.eval(engine.getContext());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
engine.eval(getCode());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
errored = true;
|
|
||||||
appandConsole(e.getMessage());
|
|
||||||
}
|
|
||||||
appandConsole(sw.getBuffer().toString().trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void appandConsole(String message) {
|
private String getFullCode() {
|
||||||
if(message == null || message.isEmpty())
|
if(!this.init) {
|
||||||
return;
|
this.fullscript = this.script;
|
||||||
console = message + "\n" + console;
|
if(!this.fullscript.isEmpty()) {
|
||||||
}
|
this.fullscript = this.fullscript + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasCode() {
|
Iterator var1 = this.scripts.iterator();
|
||||||
return !getCode().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEngine(String scriptLanguage) {
|
while(var1.hasNext()) {
|
||||||
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
|
String loc = (String)var1.next();
|
||||||
return;
|
String code = (String)ScriptController.Instance.scripts.get(loc);
|
||||||
engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
if(code != null && !code.isEmpty()) {
|
||||||
currentScriptLanguage = scriptLanguage;
|
this.fullscript = this.fullscript + code + "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.fullscript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(ScriptEngine engine){
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
this.engine.getContext().setWriter(pw);
|
||||||
|
this.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 (Throwable var14) {
|
||||||
|
this.errored = true;
|
||||||
|
var14.printStackTrace(pw);
|
||||||
|
} finally {
|
||||||
|
String errorString = sw.getBuffer().toString().trim();
|
||||||
|
this.appandConsole(errorString);
|
||||||
|
pw.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.put("API", NpcAPI.Instance());
|
||||||
|
|
||||||
|
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 {
|
||||||
|
String errorString = sw.getBuffer().toString().trim();
|
||||||
|
this.appandConsole(errorString);
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||||||
import net.minecraft.entity.monster.EntityMob;
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
import net.minecraft.entity.passive.EntityAnimal;
|
import net.minecraft.entity.passive.EntityAnimal;
|
||||||
import net.minecraft.entity.passive.EntityTameable;
|
import net.minecraft.entity.passive.EntityTameable;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
@@ -27,20 +28,23 @@ import net.minecraft.server.MinecraftServer;
|
|||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.ScriptAnimal;
|
import noppes.npcs.scripted.entity.ScriptAnimal;
|
||||||
import noppes.npcs.scripted.ScriptEntity;
|
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||||
import noppes.npcs.scripted.ScriptLiving;
|
import noppes.npcs.scripted.entity.ScriptLiving;
|
||||||
import noppes.npcs.scripted.ScriptLivingBase;
|
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||||
import noppes.npcs.scripted.ScriptMonster;
|
import noppes.npcs.scripted.entity.ScriptMonster;
|
||||||
import noppes.npcs.scripted.ScriptPixelmon;
|
import noppes.npcs.scripted.entity.ScriptPixelmon;
|
||||||
import noppes.npcs.scripted.ScriptPlayer;
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
import noppes.npcs.scripted.ScriptWorld;
|
import noppes.npcs.scripted.ScriptWorld;
|
||||||
|
import noppes.npcs.util.JsonException;
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
public class ScriptController {
|
public class ScriptController {
|
||||||
|
|
||||||
public static ScriptController Instance;
|
public static ScriptController Instance;
|
||||||
public static boolean HasStart = false;
|
public static boolean HasStart = false;
|
||||||
private ScriptEngineManager manager;
|
private ScriptEngineManager manager;
|
||||||
@@ -49,10 +53,15 @@ public class ScriptController {
|
|||||||
public long lastLoaded = 0;
|
public long lastLoaded = 0;
|
||||||
public File dir;
|
public File dir;
|
||||||
public NBTTagCompound compound = new NBTTagCompound();
|
public NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
public boolean shouldSave = false;
|
public boolean shouldSave = false;
|
||||||
|
|
||||||
|
public PlayerDataScript playerScripts = new PlayerDataScript((EntityPlayer)null);
|
||||||
|
public long lastPlayerUpdate = 0L;
|
||||||
|
|
||||||
|
public ForgeDataScript forgeScripts = new ForgeDataScript();
|
||||||
|
|
||||||
public ScriptController(){
|
public ScriptController(){
|
||||||
loaded = false;
|
loaded = false;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@@ -68,6 +77,78 @@ public class ScriptController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File forgeScriptsFile() {
|
||||||
|
return new File(this.dir, "forge_scripts.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean loadForgeScripts() {
|
||||||
|
this.forgeScripts.clear();
|
||||||
|
File file = this.forgeScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(!file.exists()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.forgeScripts.readFromNBT(NBTJsonUtil.LoadFile(file));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception var3) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), var3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForgeScripts(NBTTagCompound compound) {
|
||||||
|
this.forgeScripts.readFromNBT(compound);
|
||||||
|
File file = this.forgeScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
|
this.forgeScripts.lastInited = -1L;
|
||||||
|
} catch (IOException var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
} catch (JsonException var5) {
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private File playerScriptsFile() {
|
||||||
|
return new File(dir, "player_scripts.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean loadPlayerScripts() {
|
||||||
|
this.playerScripts.clear();
|
||||||
|
File file = this.playerScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(!file.exists()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.playerScripts.readFromNBT(NBTJsonUtil.LoadFile(file));
|
||||||
|
shouldSave = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception var3) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), var3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerScripts(NBTTagCompound compound) {
|
||||||
|
this.playerScripts.readFromNBT(compound);
|
||||||
|
File file = this.playerScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
|
this.lastPlayerUpdate = System.currentTimeMillis();
|
||||||
|
} catch (IOException var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
} catch (JsonException var5) {
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadCategories(){
|
private void loadCategories(){
|
||||||
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
@@ -103,39 +184,40 @@ public class ScriptController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean loadStoredData(){
|
public boolean loadStoredData(){
|
||||||
loadCategories();
|
loadCategories();
|
||||||
File file = getSavedFile();
|
File file = getSavedFile();
|
||||||
try {
|
try {
|
||||||
if(!file.exists())
|
if(!file.exists())
|
||||||
return false;
|
return false;
|
||||||
this.compound = NBTJsonUtil.LoadFile(file);
|
this.compound = NBTJsonUtil.LoadFile(file);
|
||||||
shouldSave = false;
|
shouldSave = false;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getSavedFile(){
|
private File getSavedFile(){
|
||||||
return new File(dir, "world_data.json");
|
return new File(dir, "world_data.json");
|
||||||
}
|
}
|
||||||
private String readFile(File file) throws IOException {
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
|
||||||
try {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
String line = br.readLine();
|
|
||||||
|
|
||||||
while (line != null) {
|
private String readFile(File file) throws IOException {
|
||||||
sb.append(line);
|
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||||
sb.append("\n");
|
try {
|
||||||
line = br.readLine();
|
StringBuilder sb = new StringBuilder();
|
||||||
}
|
String line = br.readLine();
|
||||||
return sb.toString();
|
|
||||||
} finally {
|
while (line != null) {
|
||||||
br.close();
|
sb.append(line);
|
||||||
}
|
sb.append("\n");
|
||||||
|
line = br.readLine();
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} finally {
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptEngine getEngineByName(String language) {
|
public ScriptEngine getEngineByName(String language) {
|
||||||
@@ -156,7 +238,7 @@ public class ScriptController {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getScripts(String language){
|
private List<String> getScripts(String language){
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
String ext = languages.get(language);
|
String ext = languages.get(language);
|
||||||
@@ -202,14 +284,14 @@ public class ScriptController {
|
|||||||
public void saveWorld(WorldEvent.Save event){
|
public void saveWorld(WorldEvent.Save event){
|
||||||
if(!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0])
|
if(!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NBTJsonUtil.SaveFile(getSavedFile(), compound);
|
NBTJsonUtil.SaveFile(getSavedFile(), compound);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldSave = false;
|
shouldSave = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||||
import noppes.npcs.scripted.ScriptEntity;
|
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||||
|
|
||||||
public class ScriptEntityData implements IExtendedEntityProperties{
|
public class ScriptEntityData implements IExtendedEntityProperties{
|
||||||
public ScriptEntity base;
|
public ScriptEntity base;
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.controllers.data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.EventHooks;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.NBTTags;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
|
||||||
|
import javax.script.ScriptEngine;
|
||||||
|
|
||||||
|
public class ForgeDataScript implements IScriptHandler {
|
||||||
|
private List<ScriptContainer> scripts = new ArrayList();
|
||||||
|
private String scriptLanguage = "ECMAScript";
|
||||||
|
public long lastInited = -1L;
|
||||||
|
private boolean enabled = false;
|
||||||
|
|
||||||
|
public ForgeDataScript() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.scripts = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
|
||||||
|
this.scriptLanguage = compound.getString("ScriptLanguage");
|
||||||
|
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||||
|
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
|
||||||
|
compound.setString("ScriptLanguage", this.scriptLanguage);
|
||||||
|
compound.setBoolean("ScriptEnabled", this.enabled);
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callScript(EnumScriptType var1, Event var2) {
|
||||||
|
callScript(var1.function, var2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(String type, Event event) {
|
||||||
|
if(this.isEnabled()) {
|
||||||
|
//Minecraft.getMinecraft().func_152344_a(() -> {
|
||||||
|
if (ScriptController.Instance.lastLoaded > this.lastInited) {
|
||||||
|
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||||
|
if (!type.equals("init")) {
|
||||||
|
EventHooks.onForgeInit(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var3 = this.scripts.iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
ScriptContainer script = (ScriptContainer)var3.next();
|
||||||
|
script.run(type, event);
|
||||||
|
}
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return this.enabled && ScriptController.HasStart && this.scripts.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClient() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
return "ForgeScript";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
TreeMap 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()) {
|
||||||
|
Entry entry = (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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
package noppes.npcs.controllers.data;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
import noppes.npcs.EventHooks;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.NBTTags;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
|
import noppes.npcs.scripted.event.PlayerEvent;
|
||||||
|
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||||
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.script.ScriptEngine;
|
||||||
|
public class PlayerDataScript implements IScriptHandler {
|
||||||
|
public List<ScriptContainer> scripts = new ArrayList();
|
||||||
|
public String scriptLanguage = "ECMAScript";
|
||||||
|
private EntityPlayer player;
|
||||||
|
private IPlayer playerAPI;
|
||||||
|
private long lastPlayerUpdate = 0L;
|
||||||
|
public long lastInited = -1L;
|
||||||
|
public boolean enabled = false;
|
||||||
|
private Map<Long, String> console = new TreeMap();
|
||||||
|
public List<Integer> errored = new ArrayList();
|
||||||
|
|
||||||
|
public PlayerDataScript(EntityPlayer player) {
|
||||||
|
if(player != null) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void clear() {
|
||||||
|
this.console = new TreeMap();
|
||||||
|
this.errored = new ArrayList();
|
||||||
|
this.scripts = new ArrayList();
|
||||||
|
}
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
|
||||||
|
this.scriptLanguage = compound.getString("ScriptLanguage");
|
||||||
|
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||||
|
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
|
||||||
|
}
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||||
|
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
|
||||||
|
compound.setString("ScriptLanguage", this.scriptLanguage);
|
||||||
|
compound.setBoolean("ScriptEnabled", this.enabled);
|
||||||
|
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(EnumScriptType type, Event event) {
|
||||||
|
if (this.isEnabled()) {
|
||||||
|
ScriptContainer script;
|
||||||
|
if (ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) {
|
||||||
|
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||||
|
errored.clear();
|
||||||
|
|
||||||
|
this.lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate;
|
||||||
|
|
||||||
|
if (type != EnumScriptType.INIT) {
|
||||||
|
noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event;
|
||||||
|
EventHooks.onPlayerInit(this, (ScriptPlayer) playerEvent.player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < ScriptController.Instance.playerScripts.scripts.size(); ++i) {
|
||||||
|
script = (ScriptContainer)ScriptController.Instance.playerScripts.scripts.get(i);
|
||||||
|
if (!errored.contains(i)) {
|
||||||
|
if(script == null || script.errored || !script.hasCode() || ScriptController.Instance.playerScripts.errored.contains(i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
script.run(type, event);
|
||||||
|
|
||||||
|
if (script.errored) {
|
||||||
|
ScriptController.Instance.playerScripts.errored.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var8 = script.console.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var8.hasNext()) {
|
||||||
|
Entry<Long, String> entry = (Entry)var8.next();
|
||||||
|
if (!ScriptController.Instance.playerScripts.console.containsKey(entry.getKey())) {
|
||||||
|
ScriptController.Instance.playerScripts.console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + (String)entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
script.console.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
||||||
|
}
|
||||||
|
public boolean isClient() {
|
||||||
|
return this.player.isClientWorld();
|
||||||
|
}
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return ScriptController.Instance.playerScripts.enabled;
|
||||||
|
}
|
||||||
|
public void setEnabled(boolean bo) {
|
||||||
|
ScriptController.Instance.playerScripts.enabled = bo;
|
||||||
|
this.enabled = bo;
|
||||||
|
}
|
||||||
|
public String getLanguage() {
|
||||||
|
return ScriptController.Instance.playerScripts.scriptLanguage;
|
||||||
|
}
|
||||||
|
public void setLanguage(String lang) {
|
||||||
|
this.scriptLanguage = lang;
|
||||||
|
}
|
||||||
|
public List<ScriptContainer> getScripts() {
|
||||||
|
return this.scripts;
|
||||||
|
}
|
||||||
|
public String noticeString() {
|
||||||
|
if(this.player == null) {
|
||||||
|
return "Global script";
|
||||||
|
} else {
|
||||||
|
BlockPos pos = new BlockPos(this.player);
|
||||||
|
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IPlayer getPlayer() {
|
||||||
|
if (this.playerAPI == null) {
|
||||||
|
this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player);
|
||||||
|
}
|
||||||
|
return this.playerAPI;
|
||||||
|
}
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
return this.console;
|
||||||
|
}
|
||||||
|
public void clearConsole() {
|
||||||
|
this.console.clear();
|
||||||
|
}
|
||||||
|
public static final class ToStringHelper {
|
||||||
|
private final String className;
|
||||||
|
private final PlayerDataScript.ToStringHelper.ValueHolder holderHead;
|
||||||
|
private PlayerDataScript.ToStringHelper.ValueHolder holderTail;
|
||||||
|
private boolean omitNullValues;
|
||||||
|
private boolean omitEmptyValues;
|
||||||
|
private ToStringHelper(String className) {
|
||||||
|
this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderHead;
|
||||||
|
this.omitNullValues = false;
|
||||||
|
this.omitEmptyValues = false;
|
||||||
|
this.className = (String) Preconditions.checkNotNull(className);
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper omitNullValues() {
|
||||||
|
this.omitNullValues = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
|
||||||
|
return this.addHolder(name, value);
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, boolean value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, char value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, double value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, float value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, int value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper add(String name, long value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(@CheckForNull Object value) {
|
||||||
|
return this.addHolder(value);
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(boolean value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(char value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(double value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(float value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(int value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public PlayerDataScript.ToStringHelper addValue(long value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
private static boolean isEmpty(Object value) {
|
||||||
|
if (value instanceof CharSequence) {
|
||||||
|
return ((CharSequence)value).length() == 0;
|
||||||
|
} else if (value instanceof Collection) {
|
||||||
|
return ((Collection)value).isEmpty();
|
||||||
|
} else if (value instanceof Map) {
|
||||||
|
return ((Map)value).isEmpty();
|
||||||
|
} else if (value instanceof Optional) {
|
||||||
|
return !((Optional)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalInt) {
|
||||||
|
return !((OptionalInt)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalLong) {
|
||||||
|
return !((OptionalLong)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalDouble) {
|
||||||
|
return !((OptionalDouble)value).isPresent();
|
||||||
|
} else if (value instanceof com.google.common.base.Optional) {
|
||||||
|
return !((com.google.common.base.Optional)value).isPresent();
|
||||||
|
} else if (value.getClass().isArray()) {
|
||||||
|
return Array.getLength(value) == 0;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
boolean omitNullValuesSnapshot = this.omitNullValues;
|
||||||
|
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
|
||||||
|
String nextSeparator = "";
|
||||||
|
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
|
||||||
|
for(PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
|
||||||
|
Object value = valueHolder.value;
|
||||||
|
if (!(valueHolder instanceof PlayerDataScript.ToStringHelper.UnconditionalValueHolder)) {
|
||||||
|
if (value == null) {
|
||||||
|
if (omitNullValuesSnapshot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (omitEmptyValuesSnapshot && isEmpty(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.append(nextSeparator);
|
||||||
|
nextSeparator = ", ";
|
||||||
|
if (valueHolder.name != null) {
|
||||||
|
builder.append(valueHolder.name).append('=');
|
||||||
|
}
|
||||||
|
if (value != null && value.getClass().isArray()) {
|
||||||
|
Object[] objectArray = new Object[]{value};
|
||||||
|
String arrayString = Arrays.deepToString(objectArray);
|
||||||
|
builder.append(arrayString, 1, arrayString.length() - 1);
|
||||||
|
} else {
|
||||||
|
builder.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.append('}').toString();
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper.ValueHolder addHolder() {
|
||||||
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = new PlayerDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
|
||||||
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
|
||||||
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
|
||||||
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new PlayerDataScript.ToStringHelper.UnconditionalValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper addUnconditionalHolder(Object value) {
|
||||||
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
|
||||||
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private static final class UnconditionalValueHolder extends PlayerDataScript.ToStringHelper.ValueHolder {
|
||||||
|
private UnconditionalValueHolder() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class ValueHolder {
|
||||||
|
@CheckForNull
|
||||||
|
String name;
|
||||||
|
@CheckForNull
|
||||||
|
Object value;
|
||||||
|
@CheckForNull
|
||||||
|
PlayerDataScript.ToStringHelper.ValueHolder next;
|
||||||
|
private ValueHolder() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
|
||||||
|
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
package noppes.npcs.entity;
|
package noppes.npcs.entity;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.entity.ai.EntityAISwimming;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
|
||||||
|
|
||||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||||
|
|
||||||
@@ -16,8 +12,6 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
super(world);
|
super(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FLY CHANGE [WIP]
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFly(){
|
public boolean canFly(){
|
||||||
return ai.movementType == 1;
|
return ai.movementType == 1;
|
||||||
@@ -35,59 +29,18 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
super.updateFallState(p_180433_1_, p_180433_3_);
|
super.updateFallState(p_180433_1_, p_180433_3_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onLivingUpdate()
|
||||||
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_){
|
{
|
||||||
if(!canFly()){
|
super.onLivingUpdate();
|
||||||
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
if(!canFly()){
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isInWater()){
|
|
||||||
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
|
|
||||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
|
||||||
this.motionX *= 0.800000011920929D;
|
|
||||||
this.motionY *= 0.800000011920929D;
|
|
||||||
this.motionZ *= 0.800000011920929D;
|
|
||||||
}
|
|
||||||
else if (this.isInsideOfMaterial(Material.lava)){
|
|
||||||
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
|
|
||||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
|
||||||
this.motionX *= 0.5D;
|
|
||||||
this.motionY *= 0.5D;
|
|
||||||
this.motionZ *= 0.5D;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
float f2 = 0.91F;
|
|
||||||
|
|
||||||
if (this.onGround){
|
|
||||||
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
|
|
||||||
}
|
|
||||||
|
|
||||||
float f3 = 0.16277136F / (f2 * f2 * f2);
|
|
||||||
this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F);
|
|
||||||
f2 = 0.91F;
|
|
||||||
|
|
||||||
if (this.onGround){
|
|
||||||
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
|
||||||
this.motionX *= (double)f2;
|
|
||||||
this.motionY *= (double)f2;
|
|
||||||
this.motionZ *= (double)f2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.prevLimbSwingAmount = this.limbSwingAmount;
|
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0)
|
||||||
double d1 = this.posX - this.prevPosX;
|
{
|
||||||
double d0 = this.posZ - this.prevPosZ;
|
this.motionY *= this.ai.flyGravity;
|
||||||
float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;
|
this.velocityChanged = true;
|
||||||
|
|
||||||
if (f4 > 1.0F){
|
|
||||||
f4 = 1.0F;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
|
|
||||||
this.limbSwing += this.limbSwingAmount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ package noppes.npcs.entity;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.command.ICommandSender;
|
import net.minecraft.command.ICommandSender;
|
||||||
@@ -24,7 +20,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
import net.minecraft.entity.projectile.EntityThrowable;
|
import net.minecraft.entity.projectile.EntityThrowable;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBow;
|
import net.minecraft.item.ItemBow;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -66,7 +61,6 @@ import noppes.npcs.ai.EntityAIWander;
|
|||||||
import noppes.npcs.ai.EntityAIWatchClosest;
|
import noppes.npcs.ai.EntityAIWatchClosest;
|
||||||
import noppes.npcs.ai.pathfinder.FlyingMoveHelper;
|
import noppes.npcs.ai.pathfinder.FlyingMoveHelper;
|
||||||
import noppes.npcs.ai.pathfinder.PathNavigateFlying;
|
import noppes.npcs.ai.pathfinder.PathNavigateFlying;
|
||||||
import noppes.npcs.ai.pathfinder.PathNavigateGround;
|
|
||||||
import noppes.npcs.ai.selector.NPCAttackSelector;
|
import noppes.npcs.ai.selector.NPCAttackSelector;
|
||||||
import noppes.npcs.ai.target.EntityAIClearTarget;
|
import noppes.npcs.ai.target.EntityAIClearTarget;
|
||||||
import noppes.npcs.ai.target.EntityAIClosestTarget;
|
import noppes.npcs.ai.target.EntityAIClosestTarget;
|
||||||
@@ -93,23 +87,28 @@ import noppes.npcs.controllers.PlayerDataController;
|
|||||||
import noppes.npcs.controllers.PlayerQuestData;
|
import noppes.npcs.controllers.PlayerQuestData;
|
||||||
import noppes.npcs.controllers.QuestData;
|
import noppes.npcs.controllers.QuestData;
|
||||||
import noppes.npcs.controllers.TransformData;
|
import noppes.npcs.controllers.TransformData;
|
||||||
|
import noppes.npcs.entity.data.DataTimers;
|
||||||
import noppes.npcs.roles.JobBard;
|
import noppes.npcs.roles.JobBard;
|
||||||
import noppes.npcs.roles.JobFollower;
|
import noppes.npcs.roles.JobFollower;
|
||||||
import noppes.npcs.roles.JobInterface;
|
import noppes.npcs.roles.JobInterface;
|
||||||
import noppes.npcs.roles.RoleCompanion;
|
import noppes.npcs.roles.RoleCompanion;
|
||||||
import noppes.npcs.roles.RoleFollower;
|
import noppes.npcs.roles.RoleFollower;
|
||||||
import noppes.npcs.roles.RoleInterface;
|
import noppes.npcs.roles.RoleInterface;
|
||||||
import noppes.npcs.scripted.ScriptEventAttack;
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
import noppes.npcs.scripted.ScriptEventDamaged;
|
import noppes.npcs.scripted.event.ScriptEventAttack;
|
||||||
import noppes.npcs.scripted.ScriptEventKilled;
|
import noppes.npcs.scripted.event.ScriptEventDamaged;
|
||||||
import noppes.npcs.scripted.ScriptEventTarget;
|
import noppes.npcs.scripted.event.ScriptEventKilled;
|
||||||
|
import noppes.npcs.scripted.event.ScriptEventTarget;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||||
import noppes.npcs.util.GameProfileAlt;
|
import noppes.npcs.util.GameProfileAlt;
|
||||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||||
|
|
||||||
public abstract class EntityNPCInterface extends EntityCreature implements IEntityAdditionalSpawnData, ICommandSender, IRangedAttackMob, IBossDisplayData{
|
public abstract class EntityNPCInterface extends EntityCreature implements IEntityAdditionalSpawnData, ICommandSender, IRangedAttackMob, IBossDisplayData{
|
||||||
|
public ICustomNpc wrappedNPC;
|
||||||
|
|
||||||
private static final GameProfileAlt chateventProfile = new GameProfileAlt();
|
public static final GameProfileAlt chateventProfile = new GameProfileAlt();
|
||||||
private static FakePlayer chateventPlayer;
|
public static FakePlayer chateventPlayer;
|
||||||
|
public static FakePlayer CommandPlayer;
|
||||||
public DataDisplay display;
|
public DataDisplay display;
|
||||||
public DataStats stats;
|
public DataStats stats;
|
||||||
public DataAI ai;
|
public DataAI ai;
|
||||||
@@ -117,6 +116,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
public DataInventory inventory;
|
public DataInventory inventory;
|
||||||
public DataScript script;
|
public DataScript script;
|
||||||
public TransformData transform;
|
public TransformData transform;
|
||||||
|
public DataTimers timers;
|
||||||
|
|
||||||
public String linkedName = "";
|
public String linkedName = "";
|
||||||
public long linkedLast = 0;
|
public long linkedLast = 0;
|
||||||
@@ -154,12 +154,19 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
public boolean updateAI = false;
|
public boolean updateAI = false;
|
||||||
|
|
||||||
// Fly Change
|
// Fly Change
|
||||||
// public EntityMoveHelper moveHelper;
|
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
||||||
// public PathNavigate navigator;
|
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
||||||
|
|
||||||
public EntityNPCInterface(World world) {
|
public EntityNPCInterface(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
try{
|
try{
|
||||||
|
if (canFly()) {
|
||||||
|
this.getNavigator().setCanSwim(true);
|
||||||
|
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||||
|
} else {
|
||||||
|
this.tasks.addTask(0, new EntityAIWaterNav(this));
|
||||||
|
}
|
||||||
|
|
||||||
dialogs = new HashMap<Integer, DialogOption>();
|
dialogs = new HashMap<Integer, DialogOption>();
|
||||||
if(!CustomNpcs.DefaultInteractLine.isEmpty())
|
if(!CustomNpcs.DefaultInteractLine.isEmpty())
|
||||||
advanced.interactLines.lines.put(0, new Line(CustomNpcs.DefaultInteractLine));
|
advanced.interactLines.lines.put(0, new Line(CustomNpcs.DefaultInteractLine));
|
||||||
@@ -171,6 +178,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
setFaction(faction.id);
|
setFaction(faction.id);
|
||||||
setSize(1, 1);
|
setSize(1, 1);
|
||||||
this.updateTasks();
|
this.updateTasks();
|
||||||
|
|
||||||
|
if (!this.isRemote()) {
|
||||||
|
this.wrappedNPC = new ScriptNpc(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -188,12 +199,12 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
inventory = new DataInventory(this);
|
inventory = new DataInventory(this);
|
||||||
transform = new TransformData(this);
|
transform = new TransformData(this);
|
||||||
script = new DataScript(this);
|
script = new DataScript(this);
|
||||||
|
timers = new DataTimers(this);
|
||||||
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
|
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
|
||||||
|
|
||||||
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(stats.maxHealth);
|
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(stats.maxHealth);
|
||||||
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
|
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
|
||||||
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(this.getSpeed());
|
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(this.getSpeed());
|
||||||
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(stats.getAttackStrength());
|
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(stats.getAttackStrength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +235,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
if(this.ticksExisted % 10 == 0)
|
if(this.ticksExisted % 10 == 0)
|
||||||
script.callScript(EnumScriptType.TICK);
|
script.callScript(EnumScriptType.TICK);
|
||||||
|
this.timers.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorld(World world){
|
public void setWorld(World world){
|
||||||
@@ -398,6 +410,29 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PathNavigate getNavigator() {
|
||||||
|
if(canFly())
|
||||||
|
return this.flyNavigator;
|
||||||
|
else {
|
||||||
|
return super.getNavigator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityMoveHelper getMoveHelper() {
|
||||||
|
if(canFly())
|
||||||
|
return this.flyMoveHelper;
|
||||||
|
else {
|
||||||
|
return super.getMoveHelper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateAITasks()
|
||||||
|
{
|
||||||
|
super.updateAITasks();
|
||||||
|
this.getNavigator().onUpdateNavigation();
|
||||||
|
this.getMoveHelper().onUpdateMoveHelper();
|
||||||
|
}
|
||||||
|
|
||||||
public void addInteract(EntityLivingBase entity){
|
public void addInteract(EntityLivingBase entity){
|
||||||
if( !ai.stopAndInteract || isAttacking() || !entity.isEntityAlive())
|
if( !ai.stopAndInteract || isAttacking() || !entity.isEntityAlive())
|
||||||
@@ -522,7 +557,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
if(event.getTarget() == null)
|
if(event.getTarget() == null)
|
||||||
entity = null;
|
entity = null;
|
||||||
else
|
else
|
||||||
entity = event.getTarget().getMinecraftEntity();
|
entity = event.getTarget().getMCEntity();
|
||||||
}
|
}
|
||||||
if (entity != null && entity != this && ai.onAttack != 3 && !isAttacking() && !isRemote()){
|
if (entity != null && entity != this && ai.onAttack != 3 && !isAttacking() && !isRemote()){
|
||||||
Line line = advanced.getAttackLine();
|
Line line = advanced.getAttackLine();
|
||||||
@@ -593,17 +628,12 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
this.targetTasks.addTask(3, new EntityAIOwnerHurtByTarget(this));
|
this.targetTasks.addTask(3, new EntityAIOwnerHurtByTarget(this));
|
||||||
this.targetTasks.addTask(4, new EntityAIOwnerHurtTarget(this));
|
this.targetTasks.addTask(4, new EntityAIOwnerHurtTarget(this));
|
||||||
|
|
||||||
this.tasks.addTask(0, new EntityAIWaterNav(this));
|
if (canFly()) {
|
||||||
|
this.getNavigator().setCanSwim(true);
|
||||||
// if(canFly()){
|
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||||
// this.moveHelper = new FlyingMoveHelper(this);
|
} else {
|
||||||
// this.navigator = new PathNavigateFlying(this, worldObj);
|
this.tasks.addTask(0, new EntityAIWaterNav(this));
|
||||||
// }
|
}
|
||||||
// else{
|
|
||||||
// this.moveHelper = new EntityMoveHelper(this);
|
|
||||||
// this.navigator = new PathNavigateGround(this, worldObj);
|
|
||||||
// this.tasks.addTask(0, new EntityAIWaterNav(this));
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.taskCount = 1;
|
this.taskCount = 1;
|
||||||
this.doorInteractType();
|
this.doorInteractType();
|
||||||
@@ -901,13 +931,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addVelocity(double d, double d1, double d2) {
|
|
||||||
if (isWalking() && !isKilled())
|
|
||||||
super.addVelocity(d, d1, d2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||||
super.readEntityFromNBT(compound);
|
super.readEntityFromNBT(compound);
|
||||||
@@ -918,7 +941,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
stats.readToNBT(compound);
|
stats.readToNBT(compound);
|
||||||
ai.readToNBT(compound);
|
ai.readToNBT(compound);
|
||||||
script.readFromNBT(compound);
|
script.readFromNBT(compound);
|
||||||
|
timers.readFromNBT(compound);
|
||||||
advanced.readToNBT(compound);
|
advanced.readToNBT(compound);
|
||||||
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
||||||
roleInterface.readFromNBT(compound);
|
roleInterface.readFromNBT(compound);
|
||||||
@@ -949,7 +972,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
stats.writeToNBT(compound);
|
stats.writeToNBT(compound);
|
||||||
ai.writeToNBT(compound);
|
ai.writeToNBT(compound);
|
||||||
script.writeToNBT(compound);
|
script.writeToNBT(compound);
|
||||||
|
timers.writeToNBT(compound);
|
||||||
advanced.writeToNBT(compound);
|
advanced.writeToNBT(compound);
|
||||||
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
||||||
roleInterface.writeToNBT(compound);
|
roleInterface.writeToNBT(compound);
|
||||||
@@ -1446,7 +1469,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
public NBTTagCompound writeSpawnData() {
|
public NBTTagCompound writeSpawnData() {
|
||||||
NBTTagCompound compound = new NBTTagCompound();
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
display.writeToNBT(compound);
|
display.writeToNBT(compound);
|
||||||
compound.setInteger("MaxHealth", stats.maxHealth);
|
compound.setDouble("MaxHealth", stats.maxHealth);
|
||||||
compound.setTag("Armor", NBTTags.nbtItemStackList(inventory.getArmor()));
|
compound.setTag("Armor", NBTTags.nbtItemStackList(inventory.getArmor()));
|
||||||
compound.setTag("Weapons", NBTTags.nbtItemStackList(inventory.getWeapons()));
|
compound.setTag("Weapons", NBTTags.nbtItemStackList(inventory.getWeapons()));
|
||||||
compound.setInteger("Speed", ai.getWalkingSpeed());
|
compound.setInteger("Speed", ai.getWalkingSpeed());
|
||||||
@@ -1485,7 +1508,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void readSpawnData(NBTTagCompound compound) {
|
public void readSpawnData(NBTTagCompound compound) {
|
||||||
stats.maxHealth = compound.getInteger("MaxHealth");
|
stats.maxHealth = compound.getDouble("MaxHealth");
|
||||||
ai.setWalkingSpeed(compound.getInteger("Speed"));
|
ai.setWalkingSpeed(compound.getInteger("Speed"));
|
||||||
stats.hideKilledBody = compound.getBoolean("DeadBody");
|
stats.hideKilledBody = compound.getBoolean("DeadBody");
|
||||||
ai.standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
|
ai.standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
|
||||||
@@ -1514,7 +1537,18 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
display.readToNBT(compound);
|
display.readToNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Entity func_174793_f() {
|
||||||
|
if (this.worldObj.isRemote) {
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
EntityUtil.Copy(this, CommandPlayer);
|
||||||
|
CommandPlayer.setWorld(this.worldObj);
|
||||||
|
CommandPlayer.setPosition(this.posX, this.posY, this.posZ);
|
||||||
|
return CommandPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandSenderName() {
|
public String getCommandSenderName() {
|
||||||
return display.name;
|
return display.name;
|
||||||
@@ -1556,11 +1590,27 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
if(!ai.ignoreCobweb)
|
if(!ai.ignoreCobweb)
|
||||||
super.setInWeb();
|
super.setInWeb();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCollidedWith(){
|
public boolean canBeCollidedWith(){
|
||||||
return !isKilled();
|
return !isKilled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// obviously we dont want this
|
||||||
|
@Override
|
||||||
|
public boolean canBePushed() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not any entity can collide. if you want projectiles to still be
|
||||||
|
// effective, you will have to handle those yourself
|
||||||
|
@Override
|
||||||
|
protected void collideWithEntity(Entity p_82167_1_) {}
|
||||||
|
|
||||||
|
// checks for any entity within a certain boundingbox, eg minecarts
|
||||||
|
@Override
|
||||||
|
protected void collideWithNearbyEntities() {}
|
||||||
|
|
||||||
public boolean canFly(){
|
public boolean canFly(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1584,9 +1634,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvisibleToPlayer(EntityPlayer player){
|
public boolean isInvisibleToPlayer(EntityPlayer player){
|
||||||
return display.visible == 1 && (player.getHeldItem() == null || player.getHeldItem().getItem() != CustomItems.wand);
|
return (scriptInvisibleToPlayer(player) || display.visible == 1) && (player.getHeldItem() == null || player.getHeldItem().getItem() != CustomItems.wand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean scriptInvisibleToPlayer(EntityPlayer player){
|
||||||
|
return display.invisibleToList != null && display.invisibleToList.contains(player.getPersistentID());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvisible(){
|
public boolean isInvisible(){
|
||||||
return display.visible != 0;
|
return display.visible != 0;
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by Fernflower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package noppes.npcs.entity.data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import noppes.npcs.EventHooks;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.interfaces.ITimers;
|
||||||
|
import noppes.npcs.controllers.PlayerData;
|
||||||
|
import noppes.npcs.scripted.CustomNPCsException;
|
||||||
|
|
||||||
|
public class DataTimers implements ITimers {
|
||||||
|
private Object parent;
|
||||||
|
private Map<Integer, DataTimers.Timer> timers = new HashMap();
|
||||||
|
|
||||||
|
public DataTimers(Object parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(int id, int ticks, boolean repeat) {
|
||||||
|
if(this.timers.containsKey(Integer.valueOf(id))) {
|
||||||
|
throw new CustomNPCsException("There is already a timer with id: " + id, new Object[0]);
|
||||||
|
} else {
|
||||||
|
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceStart(int id, int ticks, boolean repeat) {
|
||||||
|
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(int id) {
|
||||||
|
return this.timers.containsKey(Integer.valueOf(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stop(int id) {
|
||||||
|
boolean remove = this.timers.remove(Integer.valueOf(id)) != null;
|
||||||
|
return remove;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset(int id) {
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||||
|
if(timer == null) {
|
||||||
|
throw new CustomNPCsException("There is no timer with id: " + id, new Object[0]);
|
||||||
|
} else {
|
||||||
|
timer.ticks = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound compound) {
|
||||||
|
NBTTagList list = new NBTTagList();
|
||||||
|
Iterator var3 = this.timers.values().iterator();
|
||||||
|
|
||||||
|
while(var3.hasNext()) {
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)var3.next();
|
||||||
|
NBTTagCompound c = new NBTTagCompound();
|
||||||
|
c.setInteger("ID", timer.id);
|
||||||
|
c.setInteger("TimerTicks", timer.id);
|
||||||
|
c.setBoolean("Repeat", timer.repeat);
|
||||||
|
c.setInteger("Ticks", timer.ticks);
|
||||||
|
list.appendTag(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
compound.setTag("NpcsTimers", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
Map<Integer, DataTimers.Timer> timers = new HashMap();
|
||||||
|
NBTTagList list = compound.getTagList("NpcsTimers", 10);
|
||||||
|
|
||||||
|
if(list != null) {
|
||||||
|
for (int i = 0; i < list.tagCount(); ++i) {
|
||||||
|
NBTTagCompound c = list.getCompoundTagAt(i);
|
||||||
|
DataTimers.Timer t = new DataTimers.Timer(c.getInteger("ID"), c.getInteger("TimerTicks"), c.getBoolean("Repeat"));
|
||||||
|
t.ticks = c.getInteger("Ticks");
|
||||||
|
timers.put(t.id, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timers = timers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
Iterator var1 = (new ArrayList(this.timers.values())).iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)var1.next();
|
||||||
|
timer.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.timers = new HashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() { return this.timers.size(); }
|
||||||
|
|
||||||
|
class Timer {
|
||||||
|
public int id;
|
||||||
|
private boolean repeat;
|
||||||
|
private int timerTicks;
|
||||||
|
private int ticks = 0;
|
||||||
|
|
||||||
|
public Timer(int id, int ticks, boolean repeat) {
|
||||||
|
this.id = id;
|
||||||
|
this.repeat = repeat;
|
||||||
|
this.timerTicks = ticks;
|
||||||
|
this.ticks = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(this.ticks-- <= 0) {
|
||||||
|
if(this.repeat) {
|
||||||
|
this.ticks = this.timerTicks;
|
||||||
|
} else {
|
||||||
|
DataTimers.this.stop(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object ob = DataTimers.this.parent;
|
||||||
|
if (ob instanceof EntityNPCInterface) {
|
||||||
|
EventHooks.onNPCTimer((EntityNPCInterface)ob, this.id);
|
||||||
|
}
|
||||||
|
else if(ob instanceof PlayerData) {
|
||||||
|
EventHooks.onPlayerTimer((PlayerData)ob, this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 162 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user