Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0732d98ff8 | ||
|
|
32f89f8e92 | ||
|
|
65bb3b5939 | ||
|
|
e95eb0ee98 | ||
|
|
ea3669fed8 | ||
|
|
6294062d23 | ||
|
|
5aa5fb335c | ||
|
|
be44db63d3 | ||
|
|
993e7a9d7c | ||
|
|
ebc0b96582 | ||
|
|
6101e75306 | ||
|
|
4abe8dca92 | ||
|
|
8749ba0280 | ||
|
|
6a0af3b0a0 | ||
|
|
f59b5d1e87 | ||
|
|
cddada1984 | ||
|
|
917f0d030a | ||
|
|
3454ecb78a | ||
|
|
57de575d42 | ||
|
|
8ab652361e | ||
|
|
694afb7b6b | ||
|
|
464f5ecb1e | ||
|
|
3066e1dfbc | ||
|
|
286f6862cb | ||
|
|
9a244ca2fe | ||
|
|
33378fba59 | ||
|
|
e26a0a1bd5 | ||
|
|
50fe08ce2e | ||
|
|
18ff2bff78 | ||
|
|
092592bd27 | ||
|
|
769a574210 | ||
|
|
df2e742cbb | ||
|
|
c0bac481ad | ||
|
|
d867017871 | ||
|
|
1752cdd14d | ||
|
|
1e771bce8a | ||
|
|
a507f06d7f | ||
|
|
df5c6afd2e | ||
|
|
dafd5f4460 | ||
|
|
08fb12f716 | ||
|
|
c0fa3935cd | ||
|
|
a10d79da9b | ||
|
|
0226001596 | ||
|
|
60e14f548e | ||
|
|
16321dd4ff | ||
|
|
1cb27a9e7a | ||
|
|
89b7019e29 | ||
|
|
3339488a6f | ||
|
|
1a7267349f | ||
|
|
5578f2055e | ||
|
|
e23620d724 | ||
|
|
3bc9686816 | ||
|
|
805054ceb0 | ||
|
|
75b7c01f87 | ||
|
|
f1741b4660 | ||
|
|
7f8246e04e | ||
|
|
65ab37158f | ||
|
|
d2d3cef681 | ||
|
|
403738262c | ||
|
|
90c6574125 | ||
|
|
7b0a6b7497 | ||
|
|
54fa6d106f | ||
|
|
451a60f297 | ||
|
|
3ac531a49d | ||
|
|
34b6eb05e5 | ||
|
|
4bdbe0efee | ||
|
|
c3bba543f0 | ||
|
|
d4f6df5a81 | ||
|
|
22b622d46c | ||
|
|
ee02988d8c | ||
|
|
450e065e27 | ||
|
|
c2a669fbeb | ||
|
|
732e97e0fe | ||
|
|
33e884c217 | ||
|
|
3d1caf494b | ||
|
|
18e02461a6 | ||
|
|
6bfbffb0e6 | ||
|
|
e42c4cab7e | ||
|
|
47f41ff5b7 | ||
|
|
5a86d1cc6f | ||
|
|
7d647d788f | ||
|
|
01e568d0c7 |
No files matched your search
@@ -9,7 +9,7 @@ Link to CurseForge: [HERE](https://www.curseforge.com/minecraft/mc-mods/customnp
|
|||||||
### ❗ Notice
|
### ❗ Notice
|
||||||
I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs)
|
I am not the original creator of CustomNPC. The original creator is @[Noppes](https://github.com/Noppes). I have been permitted to update the 1.7.10 and post my results on GitHub. The original mod that is updated to the latest versions of Minecraft can be found on these links: [CurseForge](https://www.curseforge.com/minecraft/mc-mods/custom-npcs), [kodevelopment](http://www.kodevelopment.nl/minecraft/customnpcs)
|
||||||
|
|
||||||
### 🔹 First Release! V1.0 (Installation)
|
### 🔹 Installation
|
||||||
This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy.
|
This mod is an ***update*** to CustomNPC and not an add-on. Do not install CustomNPC with CustomNPC-Plus. CustomNPC-Plus does not remove any functional features from the original mod. It expands upon CustomNPC with original features and backported features from newer versions. Simply drag CustomNPC-Plus into any client/server mods folder to utilize. Please **backup** before using as this could still have unforeseen errors. Report any bugs if found, thank you and enjoy.
|
||||||
|
|
||||||
### ❓ Features:
|
### ❓ Features:
|
||||||
@@ -32,7 +32,8 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
|
|||||||
- Custom Part Disabling
|
- Custom Part Disabling
|
||||||
- Markov Name Generator
|
- Markov Name Generator
|
||||||
- Flying NPCS
|
- Flying NPCS
|
||||||
- Better Script Speeds
|
- PlayerData Storage Options [JSON/Zstd]
|
||||||
|
- Script Enchanments and Fixes
|
||||||
- Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation)
|
- Scripting Additions: [Documentation](https://github.com/PewDizinho/CustomNPCPlus-Script-Documentation)
|
||||||
|
|
||||||
--- Please Suggest New Features!
|
--- Please Suggest New Features!
|
||||||
@@ -56,5 +57,6 @@ This mod is an ***update*** to CustomNPC and not an add-on. Do not install Custo
|
|||||||
[](https://discord.gg/rgeWsmQaKa)
|
[](https://discord.gg/rgeWsmQaKa)
|
||||||
[](https://discord.gg/pQqRTvFeJ5)
|
[](https://discord.gg/pQqRTvFeJ5)
|
||||||
[](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
|
[](https://www.curseforge.com/minecraft/mc-mods/customnpc-plus)
|
||||||
[](https://github.com/KAMKEEL/Plugin-Mod)
|
[](https://github.com/KAMKEEL/Plugin-Mod)
|
||||||
|
<a href="https://ko-fi.com/kamkeel"> <img src="https://i.imgur.com/zvdVbeW.png" alt="Support Me on Kofi" width="180" height="27"> </a>
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.5.1-beta"
|
version = "1.5.3"
|
||||||
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "CustomNPC-Plus"
|
archivesBaseName = "CustomNPC-Plus"
|
||||||
|
|
||||||
@@ -29,6 +29,21 @@ minecraft {
|
|||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
shade
|
||||||
|
compile.extendsFrom shade
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of all supported OS for zstd compression (This is include only for anyone which is not using the default compression)
|
||||||
|
def supportedOS = [
|
||||||
|
"linux_amd64",
|
||||||
|
"linux_i386",
|
||||||
|
"win_amd64",
|
||||||
|
"win_x86",
|
||||||
|
"darwin_x86_64",
|
||||||
|
"darwin_aarch64"
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// you may put jars on which you depend on in ./libs
|
// you may put jars on which you depend on in ./libs
|
||||||
// or you may define them like so..
|
// or you may define them like so..
|
||||||
@@ -42,6 +57,11 @@ dependencies {
|
|||||||
// for more info...
|
// for more info...
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||||
|
// shade 'com.github.luben:zstd-jni:1.5.2-2' - Remove almost implementations of zstd
|
||||||
|
|
||||||
|
for (os in supportedOS) {
|
||||||
|
shade ("com.github.luben:zstd-jni:1.5.2-2:${os}")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,4 +85,16 @@ processResources
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
configurations.shade.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {main { output.resourcesDir = output.classesDir }}
|
sourceSets {main { output.resourcesDir = output.classesDir }}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
package foxz.command;
|
||||||
|
|
||||||
|
import foxz.commandhelper.ChMcLogger;
|
||||||
|
import foxz.commandhelper.annotations.Command;
|
||||||
|
import foxz.commandhelper.annotations.SubCommand;
|
||||||
|
import foxz.commandhelper.permissions.OpOnly;
|
||||||
|
import luizotavio.compressor.ZstdCompressor;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.controllers.PlayerDataController;
|
||||||
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import static luizotavio.compressor.executor.IOExecutor.IO_EXECUTOR;
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "compressor",
|
||||||
|
desc = "Convert a file to a compressed file or back to json",
|
||||||
|
usage = "update [file|all] [json|zstd]"
|
||||||
|
)
|
||||||
|
public class CmdCompressor extends ChMcLogger {
|
||||||
|
|
||||||
|
public CmdCompressor(Object sender) {
|
||||||
|
super(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubCommand(
|
||||||
|
name = "update",
|
||||||
|
desc = "Convert all files in the current directory to compressed files",
|
||||||
|
permissions = {OpOnly.class}
|
||||||
|
)
|
||||||
|
public boolean onConvert(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
if (args.length == 0) {
|
||||||
|
sendmessage("Usage: /noppes compressor update [<filename>|all] [json|zstd]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 1) {
|
||||||
|
sendmessage("Please specify the type of compression to use");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String type;
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("json")) {
|
||||||
|
type = "json";
|
||||||
|
} else if (args[1].equalsIgnoreCase("zstd")) {
|
||||||
|
type = "zstd";
|
||||||
|
} else {
|
||||||
|
sendmessage("Please specify the type of compression to use");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File directory = PlayerDataController.instance.getSaveDir();
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
sendmessage("Converting all files in the current directory to " + type + " files");
|
||||||
|
|
||||||
|
for (File file : directory.listFiles()) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".json") && type.equalsIgnoreCase("zstd")) {
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
||||||
|
|
||||||
|
File compressed = new File(file.getParentFile(), file.getName().replace(".json", ".zstd"));
|
||||||
|
|
||||||
|
byte[] bytes = ZstdCompressor.writeCompound(compound);
|
||||||
|
|
||||||
|
Files.write(
|
||||||
|
compressed.toPath(),
|
||||||
|
bytes,
|
||||||
|
StandardOpenOption.CREATE,
|
||||||
|
StandardOpenOption.WRITE
|
||||||
|
);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".zstd") && type.equalsIgnoreCase("json")) {
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
|
||||||
|
new RandomAccessFile(file, "r")
|
||||||
|
);
|
||||||
|
|
||||||
|
File compressed = new File(file.getParentFile(), file.getName().replace(".zstd", ".json"));
|
||||||
|
|
||||||
|
NBTJsonUtil.SaveFile(compressed, compound);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sendmessage("Done! All files were converted.");
|
||||||
|
} else {
|
||||||
|
File file = new File(directory, args[0] + ".json");
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
file = new File(directory, args[0] + ".zstd");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
sendmessage("File not found");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File finalFile = file;
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".json")) {
|
||||||
|
if (type.equalsIgnoreCase("json")) {
|
||||||
|
sendmessage("File is already in json format");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = NBTJsonUtil.LoadFile(finalFile);
|
||||||
|
|
||||||
|
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".json", ".zstd"));
|
||||||
|
|
||||||
|
byte[] bytes = ZstdCompressor.writeCompound(compound);
|
||||||
|
|
||||||
|
Files.write(
|
||||||
|
compressed.toPath(),
|
||||||
|
bytes,
|
||||||
|
StandardOpenOption.CREATE,
|
||||||
|
StandardOpenOption.WRITE
|
||||||
|
);
|
||||||
|
|
||||||
|
sendmessage("File compressed to zstd!");
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.getName().endsWith(".zstd")) {
|
||||||
|
if (type.equalsIgnoreCase("zstd")) {
|
||||||
|
sendmessage("File is already in zstd format");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTTagCompound compound = ZstdCompressor.readCompressCompound(
|
||||||
|
new RandomAccessFile(finalFile, "r")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (compound == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File compressed = new File(finalFile.getParentFile(), finalFile.getName().replace(".zstd", ".json"));
|
||||||
|
|
||||||
|
NBTJsonUtil.SaveFile(compressed, compound);
|
||||||
|
|
||||||
|
sendmessage("File converted to json!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void submit(Runnable runnable) throws ExecutionException, InterruptedException, TimeoutException {
|
||||||
|
CompletableFuture.runAsync(runnable, IO_EXECUTOR).get(5, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -123,6 +123,6 @@ public class CmdDialog extends ChMcLogger {
|
|||||||
option.dialogId = diagid;
|
option.dialogId = diagid;
|
||||||
option.title = dialog.title;
|
option.title = dialog.title;
|
||||||
npc.dialogs.put(0, option);
|
npc.dialogs.put(0, option);
|
||||||
NoppesUtilServer.openDialog(player, npc, dialog);
|
NoppesUtilServer.openDialog(player, npc, dialog, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ import foxz.commandhelper.permissions.PlayerOnly;
|
|||||||
@Command(
|
@Command(
|
||||||
name = "noppes",
|
name = "noppes",
|
||||||
desc = "noppes root command",
|
desc = "noppes root command",
|
||||||
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
|
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class, CmdCompressor.class}
|
||||||
)
|
)
|
||||||
public class CmdNoppes extends ChMcLogger {
|
public class CmdNoppes extends ChMcLogger {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package luizotavio.compressor;
|
||||||
|
|
||||||
|
import com.github.luben.zstd.Zstd;
|
||||||
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
|
import net.minecraft.nbt.NBTSizeTracker;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ZstdCompressor {
|
||||||
|
|
||||||
|
public static byte[] readCompressed(DataInput inputStream) throws IOException {
|
||||||
|
int compressedLength = inputStream.readInt();
|
||||||
|
int uncompressedLength = inputStream.readInt();
|
||||||
|
|
||||||
|
if (compressedLength < 0 || uncompressedLength < 0) {
|
||||||
|
throw new IllegalArgumentException("Invalid length");
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] compressed = new byte[compressedLength];
|
||||||
|
|
||||||
|
inputStream.readFully(compressed);
|
||||||
|
|
||||||
|
return Zstd.decompress(compressed, uncompressedLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagCompound readCompressCompound(DataInput inputStream) throws IOException {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
|
||||||
|
byte[] compressed = readCompressed(inputStream);
|
||||||
|
|
||||||
|
try (DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(compressed))) {
|
||||||
|
compound = CompressedStreamTools.func_152456_a(dataInputStream, NBTSizeTracker.field_152451_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] writeCompound(NBTTagCompound compound) throws IOException {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(),
|
||||||
|
copy = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try (DataOutputStream dataOutputStream = new DataOutputStream(outputStream)) {
|
||||||
|
CompressedStreamTools.write(compound, dataOutputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] uncompressed = outputStream.toByteArray();
|
||||||
|
|
||||||
|
byte[] compress = Zstd.compress(uncompressed);
|
||||||
|
|
||||||
|
try (DataOutputStream dataOutputStream = new DataOutputStream(copy)) {
|
||||||
|
dataOutputStream.writeInt(compress.length);
|
||||||
|
dataOutputStream.writeInt(uncompressed.length);
|
||||||
|
|
||||||
|
dataOutputStream.write(compress);
|
||||||
|
|
||||||
|
return copy.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package luizotavio.compressor.executor;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
public class IOExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please, do not change this value unless you know what you are doing.
|
||||||
|
* This value is used to define the number of threads that will be used to
|
||||||
|
* compress the files.
|
||||||
|
*
|
||||||
|
* If you want to change this value, please, do it with care.
|
||||||
|
*/
|
||||||
|
public static ExecutorService IO_EXECUTOR;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package noppes.npcs;
|
package noppes.npcs;
|
||||||
|
|
||||||
import java.io.File;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
@@ -12,6 +10,7 @@ import cpw.mods.fml.common.network.FMLEventChannel;
|
|||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||||
import foxz.command.CommandNoppes;
|
import foxz.command.CommandNoppes;
|
||||||
|
import luizotavio.compressor.executor.IOExecutor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockIce;
|
import net.minecraft.block.BlockIce;
|
||||||
import net.minecraft.block.BlockLeavesBase;
|
import net.minecraft.block.BlockLeavesBase;
|
||||||
@@ -25,50 +24,41 @@ import net.minecraftforge.common.MinecraftForge;
|
|||||||
import nikedemos.markovnames.generators.*;
|
import nikedemos.markovnames.generators.*;
|
||||||
import noppes.npcs.config.ConfigLoader;
|
import noppes.npcs.config.ConfigLoader;
|
||||||
import noppes.npcs.config.ConfigProp;
|
import noppes.npcs.config.ConfigProp;
|
||||||
import noppes.npcs.controllers.BankController;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.ChunkController;
|
|
||||||
import noppes.npcs.controllers.DialogController;
|
|
||||||
import noppes.npcs.controllers.FactionController;
|
|
||||||
import noppes.npcs.controllers.GlobalDataController;
|
|
||||||
import noppes.npcs.controllers.LinkedNpcController;
|
|
||||||
import noppes.npcs.controllers.PixelmonHelper;
|
|
||||||
import noppes.npcs.controllers.PlayerDataController;
|
|
||||||
import noppes.npcs.controllers.QuestController;
|
|
||||||
import noppes.npcs.controllers.RecipeController;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
import noppes.npcs.controllers.ServerCloneController;
|
|
||||||
import noppes.npcs.controllers.SpawnController;
|
|
||||||
import noppes.npcs.controllers.TransportController;
|
|
||||||
import noppes.npcs.enchants.EnchantInterface;
|
import noppes.npcs.enchants.EnchantInterface;
|
||||||
import noppes.npcs.entity.*;
|
import noppes.npcs.entity.*;
|
||||||
import noppes.npcs.entity.old.EntityNPCDwarfFemale;
|
import noppes.npcs.entity.old.*;
|
||||||
import noppes.npcs.entity.old.EntityNPCDwarfMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCElfFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCElfMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCEnderman;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCFurryFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCFurryMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCHumanFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCHumanMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCOrcFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCOrcMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNPCVillager;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcEnderchibi;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcMonsterFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcMonsterMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcNagaFemale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcNagaMale;
|
|
||||||
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.1-beta")
|
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.3")
|
||||||
public class CustomNpcs {
|
public class CustomNpcs {
|
||||||
|
|
||||||
@ConfigProp(info = "Disable Chat Bubbles")
|
@ConfigProp(info = "Disable Chat Bubbles")
|
||||||
public static boolean EnableChatBubbles = true;
|
public static boolean EnableChatBubbles = true;
|
||||||
|
|
||||||
private static int NewEntityStartId = 0;
|
private static int NewEntityStartId = 0;
|
||||||
|
|
||||||
|
@ConfigProp(info = "*BACKUP BEFORE CHANGING* File Type used with PlayerData. Converting files may reduce lag. To convert existing files: /noppes compressor update [<filename>|all] [json|zstd]")
|
||||||
|
public static String CompressorType = "json";
|
||||||
|
|
||||||
|
@ConfigProp(info = "The size of IO executors used for compression and decompression. This is the number of threads used for compression and decompression. If you are experiencing issues with the server lagging/crashing, try changing this to a higher number.")
|
||||||
|
public static int CompressorThreads = 2;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables/Disables ALL scripting. You can still see and write code in the scripter, but these scripts won't run. True by default")
|
||||||
|
public static boolean ScriptingEnabled = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global player event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
|
||||||
|
public static boolean GlobalPlayerScripts = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global forge event scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. True by default.")
|
||||||
|
public static boolean GlobalForgeScripts = true;
|
||||||
|
|
||||||
|
@ConfigProp(info = "Enables global NPC scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. False by default, use with caution!")
|
||||||
|
public static boolean GlobalNPCScripts = false;
|
||||||
|
|
||||||
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
|
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
|
||||||
public static int NpcNavRange = 32;
|
public static int NpcNavRange = 32;
|
||||||
|
|
||||||
@@ -227,14 +217,19 @@ public class CustomNpcs {
|
|||||||
registerNpc(EntityNPCGolem.class, "npcGolem");
|
registerNpc(EntityNPCGolem.class, "npcGolem");
|
||||||
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
||||||
|
|
||||||
|
IOExecutor.IO_EXECUTOR = Executors.newFixedThreadPool(
|
||||||
|
CompressorThreads,
|
||||||
|
new ThreadFactoryBuilder()
|
||||||
|
.setNameFormat("CustomNpcs-IO-%d")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
|
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
|
||||||
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
|
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
|
||||||
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
|
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
|
||||||
|
|
||||||
new RecipeController();
|
new RecipeController();
|
||||||
|
|
||||||
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
||||||
|
|
||||||
new CustomNpcsPermissions();
|
new CustomNpcsPermissions();
|
||||||
@@ -270,6 +265,7 @@ public class CustomNpcs {
|
|||||||
new LinkedNpcController();
|
new LinkedNpcController();
|
||||||
ScriptController.Instance.loadStoredData();
|
ScriptController.Instance.loadStoredData();
|
||||||
ScriptController.Instance.loadForgeScripts();
|
ScriptController.Instance.loadForgeScripts();
|
||||||
|
ScriptController.Instance.loadNPCScripts();
|
||||||
ScriptController.Instance.loadPlayerScripts();
|
ScriptController.Instance.loadPlayerScripts();
|
||||||
ScriptController.HasStart = false;
|
ScriptController.HasStart = false;
|
||||||
WrapperNpcAPI.clearCache();
|
WrapperNpcAPI.clearCache();
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class DataScript implements IScriptHandler {
|
|||||||
return false;
|
return false;
|
||||||
if(!hasInited){
|
if(!hasInited){
|
||||||
hasInited = true;
|
hasInited = true;
|
||||||
|
EventHooks.onNPCInit(this.npc);
|
||||||
callScript(EnumScriptType.INIT);
|
callScript(EnumScriptType.INIT);
|
||||||
}
|
}
|
||||||
ScriptContainer script = scripts.get(type.ordinal());
|
ScriptContainer script = scripts.get(type.ordinal());
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.event.entity.EntityEvent;
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import noppes.npcs.controllers.CustomGuiController;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.Quest;
|
|
||||||
import noppes.npcs.controllers.ScriptController;
|
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.*;
|
import noppes.npcs.scripted.*;
|
||||||
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||||
import noppes.npcs.scripted.event.*;
|
import noppes.npcs.scripted.event.*;
|
||||||
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
|
||||||
@@ -42,7 +42,6 @@ import noppes.npcs.scripted.interfaces.IItemStack;
|
|||||||
import noppes.npcs.scripted.interfaces.IWorld;
|
import noppes.npcs.scripted.interfaces.IWorld;
|
||||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||||
import noppes.npcs.constants.EnumScriptType;
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
import noppes.npcs.controllers.PlayerData;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -51,12 +50,140 @@ public class EventHooks {
|
|||||||
public EventHooks() {
|
public EventHooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onNPCInit(EntityNPCInterface npc) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
|
||||||
|
npc.script.callScript(EnumScriptType.INIT);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCUpdate(EntityNPCInterface npc) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event);
|
||||||
|
npc.script.callScript(EnumScriptType.TICK);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
|
||||||
|
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCRangedAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event);
|
||||||
|
npc.script.callScript(EnumScriptType.KILLS, "target", entity);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event);
|
||||||
|
npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean onNPCKilled(EntityNPCInterface npc, DamageSource damagesource, Entity entity, ScriptEventKilled killedEvent){
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event);
|
||||||
|
boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent);
|
||||||
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
||||||
|
if(npc == null || npc.wrappedNPC == null)
|
||||||
|
return;
|
||||||
|
|
||||||
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||||
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||||
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
||||||
|
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
|
||||||
WrapperNpcAPI.EVENT_BUS.post(event);
|
WrapperNpcAPI.EVENT_BUS.post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ public class ModelPartData {
|
|||||||
type = compound.getByte("Type");
|
type = compound.getByte("Type");
|
||||||
color = compound.getInteger("Color");
|
color = compound.getInteger("Color");
|
||||||
texture = compound.getString("Texture");
|
texture = compound.getString("Texture");
|
||||||
if(texture.contains("moreplayermodels:textures")){
|
|
||||||
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
|
|
||||||
}
|
|
||||||
playerTexture = compound.getBoolean("PlayerTexture");
|
playerTexture = compound.getBoolean("PlayerTexture");
|
||||||
location = null;
|
location = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class NoppesUtilPlayer {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
|
EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog);
|
||||||
|
|
||||||
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
||||||
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
@@ -271,7 +271,7 @@ public class NoppesUtilPlayer {
|
|||||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||||
}
|
}
|
||||||
else if(option.optionType == EnumOptionType.DialogOption){
|
else if(option.optionType == EnumOptionType.DialogOption){
|
||||||
NoppesUtilServer.openDialog(player, npc, option.getDialog());
|
NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1);
|
||||||
}
|
}
|
||||||
else if(option.optionType == EnumOptionType.CommandBlock){
|
else if(option.optionType == EnumOptionType.CommandBlock){
|
||||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class NoppesUtilServer {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
|
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
|
||||||
Dialog dialog = dia.copy(player);
|
Dialog dialog = dia.copy(player);
|
||||||
|
|
||||||
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
|
||||||
@@ -203,7 +203,7 @@ public class NoppesUtilServer {
|
|||||||
if(!data.dialogsRead.contains(dialog.id))
|
if(!data.dialogsRead.contains(dialog.id))
|
||||||
data.dialogsRead.add(dialog.id);
|
data.dialogsRead.add(dialog.id);
|
||||||
setEditingNpc(player, npc);
|
setEditingNpc(player, npc);
|
||||||
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id);
|
EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog);
|
||||||
}
|
}
|
||||||
public static void runCommand(EntityPlayer player, String name, String command){
|
public static void runCommand(EntityPlayer player, String name, String command){
|
||||||
runCommand(player, name, command, player);
|
runCommand(player, name, command, player);
|
||||||
@@ -312,11 +312,14 @@ public class NoppesUtilServer {
|
|||||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void spawnScriptedParticle(Entity entity, String directory, int HEXcolor, int amount, int maxAge,
|
public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
double x, double y, double z,
|
double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||||
int entityID
|
int entityID
|
||||||
){
|
){
|
||||||
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||||
@@ -325,6 +328,9 @@ public class NoppesUtilServer {
|
|||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import noppes.npcs.containers.ContainerMail;
|
|||||||
import noppes.npcs.controllers.*;
|
import noppes.npcs.controllers.*;
|
||||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityCustomNpc;
|
import noppes.npcs.entity.EntityCustomNpc;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
@@ -102,7 +103,7 @@ public class PacketHandlerServer{
|
|||||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||||
//player doesnt have permission to do this
|
//player doesnt have permission to do this
|
||||||
}
|
}
|
||||||
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
||||||
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
||||||
else {
|
else {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@@ -118,6 +119,8 @@ public class PacketHandlerServer{
|
|||||||
featherPackets(type, buffer, player);
|
featherPackets(type, buffer, player);
|
||||||
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||||
playerScriptPackets(type, buffer, player);
|
playerScriptPackets(type, buffer, player);
|
||||||
|
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
|
||||||
|
npcScriptPackets(type, buffer, player);
|
||||||
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||||
forgeScriptPackets(type, buffer, player);
|
forgeScriptPackets(type, buffer, player);
|
||||||
else if (item.getItem() == CustomItems.scripter)
|
else if (item.getItem() == CustomItems.scripter)
|
||||||
@@ -172,6 +175,18 @@ public class PacketHandlerServer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void npcScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||||
|
NBTTagCompound compound;
|
||||||
|
if(type == EnumPacketServer.ScriptNPCGet) {
|
||||||
|
NPCDataScript data = ScriptController.Instance.npcScripts;
|
||||||
|
compound = data.writeToNBT(new NBTTagCompound());
|
||||||
|
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||||
|
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||||
|
} else if(type == EnumPacketServer.ScriptNPCSave) {
|
||||||
|
ScriptController.Instance.setNPCScripts(Server.readNBT(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||||
if(type == EnumPacketServer.DimensionsGet){
|
if(type == EnumPacketServer.DimensionsGet){
|
||||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public class ServerEventsHandler {
|
|||||||
if(line != null)
|
if(line != null)
|
||||||
npc.saySurrounding(line.formatTarget(event.entityLiving));
|
npc.saySurrounding(line.formatTarget(event.entityLiving));
|
||||||
|
|
||||||
npc.script.callScript(EnumScriptType.KILLS, "target", event.entityLiving);
|
EventHooks.onNPCKilledEntity(npc,event.entityLiving);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityPlayer player = null;
|
EntityPlayer player = null;
|
||||||
@@ -308,7 +308,16 @@ public class ServerEventsHandler {
|
|||||||
}
|
}
|
||||||
String name = entityName;
|
String name = entityName;
|
||||||
QuestKill quest = (QuestKill) data.quest.questInterface;
|
QuestKill quest = (QuestKill) data.quest.questInterface;
|
||||||
if(quest.targetType == 1 && !(entity instanceof EntityNPCInterface))
|
|
||||||
|
Class entityType = EntityNPCInterface.class;
|
||||||
|
if(quest.targetType == 2) {
|
||||||
|
try {
|
||||||
|
entityType = Class.forName(quest.customTargetType);
|
||||||
|
} catch (ClassNotFoundException notFoundException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(quest.targetType > 0 && !(entityType.isInstance(entity)))
|
||||||
continue;
|
continue;
|
||||||
if(quest.targets.containsKey(entity.getCommandSenderName()))
|
if(quest.targets.containsKey(entity.getCommandSenderName()))
|
||||||
name = entity.getCommandSenderName();
|
name = entity.getCommandSenderName();
|
||||||
|
|||||||
@@ -12,11 +12,21 @@ import noppes.npcs.controllers.Lines;
|
|||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
|
||||||
public class VersionCompatibility {
|
public class VersionCompatibility {
|
||||||
public static int ModRev = 16;
|
public static int ModRev = 17;
|
||||||
|
|
||||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
||||||
if(npc.npcVersion == ModRev)
|
if(npc.npcVersion == ModRev)
|
||||||
return;
|
return;
|
||||||
|
if(npc.npcVersion < 17){
|
||||||
|
// Fix DialogDarkenScreen
|
||||||
|
if(compound.hasKey("DialogDarkenScreen")){
|
||||||
|
compound.removeTag("DialogDarkenScreen");
|
||||||
|
}
|
||||||
|
// Remove MPM Texture Requirement
|
||||||
|
String texture = compound.getString("Texture");
|
||||||
|
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
|
||||||
|
compound.setString("Texture", texture);
|
||||||
|
}
|
||||||
if(npc.npcVersion < 12){
|
if(npc.npcVersion < 12){
|
||||||
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||||
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||||
|
|||||||
@@ -166,79 +166,27 @@ public class FlyPathFinder extends PathFinder
|
|||||||
b0 = 1;
|
b0 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
for(int y = -1; y <= 1; y ++) {
|
||||||
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
|
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
||||||
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
|
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0);
|
||||||
|
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
||||||
|
|
||||||
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
this.pathOptions[i++] = pathpoint3;
|
||||||
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
}
|
||||||
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
|
||||||
|
|
||||||
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
|
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
this.pathOptions[i++] = pathpoint4;
|
||||||
FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
|
}
|
||||||
FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
|
|
||||||
|
|
||||||
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_)
|
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
{
|
this.pathOptions[i++] = pathpoint5;
|
||||||
this.pathOptions[i++] = pathpoint3;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_)
|
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) {
|
||||||
{
|
this.pathOptions[i++] = pathpoint6;
|
||||||
this.pathOptions[i++] = pathpoint4;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint7;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint9;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint11;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint12;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint13;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_)
|
|
||||||
{
|
|
||||||
this.pathOptions[i++] = pathpoint14;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -29,48 +29,36 @@ public class FlyingMoveHelper extends EntityMoveHelper{
|
|||||||
if (this.update) {
|
if (this.update) {
|
||||||
this.update = false;
|
this.update = false;
|
||||||
|
|
||||||
double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed;
|
||||||
double speedMult = 0.6000000238418579D / 0.5D;
|
|
||||||
|
|
||||||
double d0 = this.posX - this.entity.posX;
|
double d0 = this.posX - this.entity.posX;
|
||||||
double d1 = this.posY - this.entity.posY;
|
double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D);
|
||||||
double d2 = this.posZ - this.entity.posZ;
|
double d2 = this.posZ - this.entity.posZ;
|
||||||
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
double d5 = MathHelper.sqrt_double(d4);
|
||||||
|
|
||||||
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
double heightOffGround = 0;
|
||||||
if (this.posY != this.entity.posY) {
|
if(this.entity.ai.hasFlyLimit) {
|
||||||
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) {
|
for (int blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||||
this.entity.motionY = 0.0D;
|
heightOffGround = this.posY - blockY;
|
||||||
|
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
|
||||||
if(verticalSpeed > speed * speedMult)
|
|
||||||
verticalSpeed = speed * speedMult;
|
|
||||||
verticalSpeed += this.entity.ai.flySpeed/2.0D;
|
|
||||||
|
|
||||||
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
|
|
||||||
verticalSpeed = Math.abs(this.entity.posY - this.posY);
|
|
||||||
|
|
||||||
int blockY = (int) this.posY;
|
|
||||||
double heightOffGround = 0;
|
|
||||||
if(this.entity.ai.hasFlyLimit) {
|
|
||||||
for (blockY = (int) this.posY; blockY > 0; blockY--) {
|
|
||||||
heightOffGround = this.posY - blockY;
|
|
||||||
if (this.entity.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.entity.ai.flyHeightLimit){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit)
|
|
||||||
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double d5 = MathHelper.sqrt_double(d4);
|
|
||||||
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult;
|
|
||||||
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F);
|
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
|
||||||
|
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed;
|
||||||
|
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed;
|
||||||
|
|
||||||
|
if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) {
|
||||||
|
this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entity.velocityChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,15 +289,15 @@ public class PathNavigateFlying extends PathNavigate {
|
|||||||
|
|
||||||
private Vec3 getEntityPosition()
|
private Vec3 getEntityPosition()
|
||||||
{
|
{
|
||||||
return Vec3.createVectorHelper(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ);
|
return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
|
||||||
*/
|
*/
|
||||||
private int getPathableYPos()
|
private double getPathableYPos()
|
||||||
{
|
{
|
||||||
return (int)(this.theEntity.boundingBox.minY + 0.5D);
|
return this.theEntity.boundingBox.minY + 0.05D;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
else if(gui == EnumGuiType.PlayerTransporter)
|
else if(gui == EnumGuiType.PlayerTransporter)
|
||||||
return new GuiTransportSelection(npc);
|
return new GuiTransportSelection(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.Script)
|
else if(gui == EnumGuiType.Script && CustomNpcs.ScriptingEnabled)
|
||||||
return new GuiScript(npc);
|
return new GuiScript(npc);
|
||||||
|
|
||||||
else if(gui == EnumGuiType.PlayerAnvil)
|
else if(gui == EnumGuiType.PlayerAnvil)
|
||||||
|
|||||||
@@ -98,6 +98,21 @@ public class NoppesUtil {
|
|||||||
float alphaRate = buffer.readFloat();
|
float alphaRate = buffer.readFloat();
|
||||||
int alphaRateStart = buffer.readInt();
|
int alphaRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationX1 = buffer.readFloat();
|
||||||
|
float rotationX2 = buffer.readFloat();
|
||||||
|
float rotationXRate = buffer.readFloat();
|
||||||
|
int rotationXRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationY1 = buffer.readFloat();
|
||||||
|
float rotationY2 = buffer.readFloat();
|
||||||
|
float rotationYRate = buffer.readFloat();
|
||||||
|
int rotationYRateStart = buffer.readInt();
|
||||||
|
|
||||||
|
float rotationZ1 = buffer.readFloat();
|
||||||
|
float rotationZ2 = buffer.readFloat();
|
||||||
|
float rotationZRate = buffer.readFloat();
|
||||||
|
int rotationZRateStart = buffer.readInt();
|
||||||
|
|
||||||
int entityID = buffer.readInt();
|
int entityID = buffer.readInt();
|
||||||
|
|
||||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||||
@@ -113,6 +128,9 @@ public class NoppesUtil {
|
|||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
maxAge
|
maxAge
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class TranslateUtil {
|
|||||||
return null;
|
return null;
|
||||||
element = array.get(0);
|
element = array.get(0);
|
||||||
}
|
}
|
||||||
System.out.println(element.getAsString());
|
// System.out.println(element.getAsString());
|
||||||
return element.getAsString();
|
return element.getAsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import noppes.npcs.client.ClientProxy;
|
import noppes.npcs.client.ClientProxy;
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
public class EntityCustomFX extends EntityFX {
|
public class EntityCustomFX extends EntityFX {
|
||||||
@@ -27,10 +26,31 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
public float alphaRate = 0.0F;
|
public float alphaRate = 0.0F;
|
||||||
public int alphaRateStart = 0;
|
public int alphaRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationX = 0;
|
||||||
|
public float rotationX1 = 0;
|
||||||
|
public float rotationX2 = 0;
|
||||||
|
public float rotationXRate = 0.0F;
|
||||||
|
public int rotationXRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationY = 0;
|
||||||
|
public float rotationY1 = 0;
|
||||||
|
public float rotationY2 = 0;
|
||||||
|
public float rotationYRate = 0.0F;
|
||||||
|
public int rotationYRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationZ = 0;
|
||||||
|
public float rotationZ1 = 0;
|
||||||
|
public float rotationZ2 = 0;
|
||||||
|
public float rotationZRate = 0.0F;
|
||||||
|
public int rotationZRateStart = 0;
|
||||||
|
|
||||||
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||||
int age) {
|
int age) {
|
||||||
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||||
|
|
||||||
@@ -50,6 +70,30 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
if(alpha1 > alpha2)
|
if(alpha1 > alpha2)
|
||||||
this.alphaRate *= -1;
|
this.alphaRate *= -1;
|
||||||
|
|
||||||
|
this.rotationX1 = rotationX1;
|
||||||
|
this.rotationX2 = rotationX2;
|
||||||
|
this.rotationXRate = Math.abs(rotationXRate);
|
||||||
|
this.rotationXRateStart = rotationXRateStart;
|
||||||
|
rotationX = rotationX1;
|
||||||
|
if(rotationX1 > rotationX2)
|
||||||
|
this.rotationXRate *= -1;
|
||||||
|
|
||||||
|
this.rotationY1 = rotationY1;
|
||||||
|
this.rotationY2 = rotationY2;
|
||||||
|
this.rotationYRate = Math.abs(rotationYRate);
|
||||||
|
this.rotationYRateStart = rotationYRateStart;
|
||||||
|
rotationY = rotationY1;
|
||||||
|
if(rotationY1 > rotationY2)
|
||||||
|
this.rotationYRate *= -1;
|
||||||
|
|
||||||
|
this.rotationZ1 = rotationZ1;
|
||||||
|
this.rotationZ2 = rotationZ2;
|
||||||
|
this.rotationZRate = Math.abs(rotationZRate);
|
||||||
|
this.rotationZRateStart = rotationZRateStart;
|
||||||
|
rotationZ = rotationZ1;
|
||||||
|
if(rotationZ1 > rotationZ2)
|
||||||
|
this.rotationZRate *= -1;
|
||||||
|
|
||||||
particleGravity = gravity/0.04F;
|
particleGravity = gravity/0.04F;
|
||||||
particleMaxAge = age;
|
particleMaxAge = age;
|
||||||
|
|
||||||
@@ -74,148 +118,92 @@ public class EntityCustomFX extends EntityFX {
|
|||||||
location = new ResourceLocation(directory);
|
location = new ResourceLocation(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
par2 = partial tick time
|
|
||||||
par3 = ActiveRenderInfo.rotationX;
|
|
||||||
par4 = ActiveRenderInfo.rotationZ;
|
|
||||||
par5 = ActiveRenderInfo.rotationYZ;
|
|
||||||
par6 = ActiveRenderInfo.rotationXY;
|
|
||||||
par7 = ActiveRenderInfo.rotationXZ;
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
|
||||||
{
|
{
|
||||||
if(move){
|
|
||||||
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)par2);
|
|
||||||
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)par2);
|
|
||||||
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)par2);
|
|
||||||
}
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
float scale = this.scaleRate / (float)particleMaxAge;
|
|
||||||
if((this.scaleRate < 0 && particleScale+scale < this.scale2) || (this.scaleRate > 0 && particleScale+scale > this.scale2))
|
|
||||||
particleScale = this.scale2;
|
|
||||||
else if(particleAge >= this.scaleRateStart)
|
|
||||||
particleScale += scale;
|
|
||||||
|
|
||||||
float alpha = this.alphaRate / (float)particleMaxAge;
|
|
||||||
if((this.alphaRate < 0 && particleAlpha+alpha < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alpha > this.alpha2))
|
|
||||||
particleAlpha = this.alpha2;
|
|
||||||
else if(particleAge >= this.alphaRateStart)
|
|
||||||
particleAlpha += alpha;
|
|
||||||
|
|
||||||
ClientProxy.bindTexture(location);
|
|
||||||
|
|
||||||
float f = 0.0f;
|
|
||||||
float f1 = 1.0f;
|
|
||||||
float f2 = 0.0f;
|
|
||||||
float f3 = 1.0f;
|
|
||||||
float f4 = 0.1F * particleScale;
|
|
||||||
float f5 = (float)(((prevPosX + (posX - prevPosX) * (double)par2) - interpPosX) + startX);
|
|
||||||
float f6 = (float)(((prevPosY + (posY - prevPosY) * (double)par2) - interpPosY) + startY);
|
|
||||||
float f7 = (float)(((prevPosZ + (posZ - prevPosZ) * (double)par2) - interpPosZ) + startZ);
|
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.setBrightness(240);
|
|
||||||
par1Tessellator.setColorOpaque_F(1, 1, 1);
|
|
||||||
par1Tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
|
||||||
par1Tessellator.addVertexWithUV(f5 - par3 * f4 - par6 * f4, f6 - par4 * f4, f7 - par5 * f4 - par7 * f4, f1, f3);
|
|
||||||
par1Tessellator.addVertexWithUV((f5 - par3 * f4) + par6 * f4, f6 + par4 * f4, (f7 - par5 * f4) + par7 * f4, f1, f2);
|
|
||||||
par1Tessellator.addVertexWithUV(f5 + par3 * f4 + par6 * f4, f6 + par4 * f4, f7 + par5 * f4 + par7 * f4, f, f2);
|
|
||||||
par1Tessellator.addVertexWithUV((f5 + par3 * f4) - par6 * f4, f6 - par4 * f4, (f7 + par5 * f4) - par7 * f4, f, f3);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
|
||||||
EntityPlayer player = minecraft.thePlayer;
|
|
||||||
|
|
||||||
double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360;
|
|
||||||
double angleRad = (angle/180)*Math.PI;
|
|
||||||
|
|
||||||
double diffX = player.posX - this.startX;
|
|
||||||
double diffY = player.posY - player.getYOffset() - this.startY;
|
|
||||||
double diffZ = player.posZ - this.startZ;
|
|
||||||
|
|
||||||
double yaw = (player.rotationYaw/180)*Math.PI;
|
|
||||||
double pitch = (player.rotationPitch/180)*Math.PI;
|
|
||||||
|
|
||||||
double angleX = Math.sin(yaw)*Math.cos(pitch);
|
|
||||||
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 angleXtranslateX = 0.0D;
|
|
||||||
double angleXtranslateY = 0.0D;//(-diffY + Math.cos(angleRad)*diffY) + (-Math.sin(angleRad)*diffZ);
|
|
||||||
double angleXtranslateZ = 0.0D;//(Math.sin(angleRad)*diffY) + (-diffZ + Math.cos(angleRad)*diffZ);
|
|
||||||
|
|
||||||
double angleYtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (Math.sin(angleRad)*diffZ);
|
|
||||||
double angleYtranslateY = 0.0D;
|
|
||||||
double angleYtranslateZ = 0.0D;//(-Math.sin(angleRad)*diffX) + (-diffZ + Math.cos(angleRad)*diffZ);
|
|
||||||
|
|
||||||
double angleZtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (-Math.sin(angleRad)*diffY);
|
|
||||||
double angleZtranslateY = 0.0D;//(Math.sin(angleRad)*diffX) + (-diffY + Math.cos(angleRad)*diffY);
|
|
||||||
double angleZtranslateZ = 0.0D;
|
|
||||||
|
|
||||||
double translateX = angleXtranslateX + angleYtranslateX + angleZtranslateX;
|
|
||||||
double translateY = angleXtranslateY + angleYtranslateY + angleZtranslateY;
|
|
||||||
double translateZ = angleXtranslateZ + angleYtranslateZ + angleZtranslateZ;
|
|
||||||
|
|
||||||
//distance in the X & Z plane
|
|
||||||
double distXZ = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffZ,2));
|
|
||||||
//distance in the X & Y plane
|
|
||||||
double distXY = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffY,2));
|
|
||||||
//distance in the Y & Z plane
|
|
||||||
double distYZ = Math.sqrt(Math.pow(diffY,2) + Math.pow(diffZ,2));
|
|
||||||
|
|
||||||
double signDiffX = Math.signum(diffX);
|
|
||||||
double signDiffY = Math.signum(diffY);
|
|
||||||
double signDiffZ = Math.signum(diffZ);
|
|
||||||
|
|
||||||
double angleXtoNorm = Math.sin(Math.acos(diffX/distXZ));
|
|
||||||
double angleZtoNorm = Math.sin(Math.acos(diffZ/distXZ));
|
|
||||||
|
|
||||||
double angleDiffX = (Math.abs(Math.cos(yaw))-angleXtoNorm);
|
|
||||||
double angleDiffZ = (Math.abs(Math.cos(yaw))-angleZtoNorm);
|
|
||||||
|
|
||||||
double translateX = -Math.abs(angleDiffX*angleZ*distXZ)*signDiffX;
|
|
||||||
double translateY = 0;
|
|
||||||
double translateZ = -Math.abs(angleDiffX*angleX*distXZ)*signDiffZ + Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ;
|
|
||||||
|
|
||||||
if(minecraft.currentScreen == null) {
|
|
||||||
System.out.println();
|
|
||||||
//System.out.printf("diffX: %f, diffY: %f, diffZ: %f\n", diffX, diffY, diffZ);
|
|
||||||
//System.out.printf("angleX: %f, angleY: %f, angleZ: %f\n", angleX, angleY, angleZ);
|
|
||||||
//System.out.printf("angleXtoNorm: %f, angleZtoNorm: %f\n", angleXtoNorm, angleZtoNorm);
|
|
||||||
System.out.printf("Math.sin(yaw): %f\n", Math.sin(yaw));
|
|
||||||
System.out.printf("Math.cos(yaw): %f\n", Math.cos(yaw));
|
|
||||||
//System.out.printf("Math.sin(pitch): %f\n", Math.sin(pitch));
|
|
||||||
//System.out.printf("Math.cos(pitch): %f\n", Math.cos(pitch));
|
|
||||||
System.out.printf("angleDiffX: %f\n", angleDiffX);
|
|
||||||
System.out.printf("angleDiffZ: %f\n", angleDiffZ);
|
|
||||||
System.out.printf("translateX: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleZ*distXZ)*signDiffX);
|
|
||||||
System.out.printf("translateZ: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glColor4f(1, 1, 1, 1.0F);
|
ClientProxy.bindTexture(location);
|
||||||
|
|
||||||
//GL11.glTranslated(translateX,translateY,translateZ);
|
if(move){
|
||||||
//GL11.glRotated(angle, angleX, angleY, angleZ);
|
startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick);
|
||||||
|
startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick);
|
||||||
|
startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick);
|
||||||
|
}
|
||||||
|
|
||||||
|
float scaleChange = this.scaleRate / (float)particleMaxAge;
|
||||||
|
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
|
||||||
|
particleScale = this.scale2;
|
||||||
|
else if(particleAge >= this.scaleRateStart)
|
||||||
|
particleScale += scaleChange;
|
||||||
|
|
||||||
|
float alphaChange = this.alphaRate / (float)particleMaxAge;
|
||||||
|
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
|
||||||
|
particleAlpha = this.alpha2;
|
||||||
|
else if(particleAge >= this.alphaRateStart)
|
||||||
|
particleAlpha += alphaChange;
|
||||||
|
|
||||||
|
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
|
||||||
|
rotationX = this.rotationX2;
|
||||||
|
else if(particleAge >= this.rotationXRateStart)
|
||||||
|
rotationX += rotationXChange;
|
||||||
|
|
||||||
|
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
|
||||||
|
rotationY = this.rotationY2;
|
||||||
|
else if(particleAge >= this.rotationYRateStart)
|
||||||
|
rotationY += rotationYChange;
|
||||||
|
|
||||||
|
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
|
||||||
|
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
|
||||||
|
rotationZ = this.rotationZ2;
|
||||||
|
else if(particleAge >= this.rotationZRateStart)
|
||||||
|
rotationZ += rotationZChange;
|
||||||
|
|
||||||
|
float u1 = 0.0f;
|
||||||
|
float u2 = 1.0f;
|
||||||
|
float v1 = 0.0f;
|
||||||
|
float v2 = 1.0f;
|
||||||
|
|
||||||
|
float renderScale = 0.1F * particleScale;
|
||||||
|
|
||||||
|
float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX);
|
||||||
|
float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY);
|
||||||
|
float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ);
|
||||||
|
|
||||||
|
GL11.glTranslated((double)posX, (double)posY, (double)posZ);
|
||||||
|
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
double yaw = (player.rotationYaw/180)*Math.PI;
|
||||||
|
double pitch = (player.rotationPitch/180)*Math.PI;
|
||||||
|
|
||||||
|
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
|
||||||
|
rotationX += 180*Math.signum(rotationX);
|
||||||
|
}
|
||||||
|
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
|
||||||
|
rotationY += 180*Math.signum(rotationY);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
|
||||||
|
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
|
||||||
|
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setBrightness(240);
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||||
|
tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2);
|
||||||
|
tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1);
|
||||||
|
tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1);
|
||||||
|
tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
ClientProxy.bindTexture(resource);
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||||
|
ClientProxy.bindTexture(resource);
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFXLayer(){
|
public int getFXLayer(){
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
|
|
||||||
public GuiNpcMobSpawner(int i, int j, int k) {
|
public GuiNpcMobSpawner(int i, int j, int k) {
|
||||||
super();
|
super();
|
||||||
xSize = 384;
|
xSize = 354;
|
||||||
|
|
||||||
posX = i;
|
posX = i;
|
||||||
posY = j;
|
posY = j;
|
||||||
posZ = k;
|
posZ = k;
|
||||||
@@ -53,6 +52,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
guiTop += 10;
|
guiTop += 10;
|
||||||
|
guiLeft += 30;
|
||||||
|
|
||||||
if(scroll == null){
|
if(scroll == null){
|
||||||
scroll = new GuiCustomScroll(this,0);
|
scroll = new GuiCustomScroll(this,0);
|
||||||
@@ -69,36 +69,37 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData{
|
|||||||
GuiMenuTopButton button;
|
GuiMenuTopButton button;
|
||||||
addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
|
addTopButton(button = new GuiMenuTopButton(3,guiLeft + 4, guiTop - 17, "spawner.clones"));
|
||||||
button.active = showingClones == 0;
|
button.active = showingClones == 0;
|
||||||
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
|
|
||||||
button.active = showingClones == 1;
|
|
||||||
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
|
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
|
||||||
button.active = showingClones == 2;
|
button.active = showingClones == 2;
|
||||||
|
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
|
||||||
|
button.active = showingClones == 1;
|
||||||
|
|
||||||
addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 82, 20, "item.monsterPlacer.name"));
|
addButton(new GuiNpcButton(1, guiLeft + 298, guiTop + 6, 52, 20, "item.monsterPlacer.name"));
|
||||||
|
|
||||||
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 82, 20, "spawner.mobspawner"));
|
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 100, 52, 20, "spawner.mobspawner"));
|
||||||
|
|
||||||
if(showingClones == 0 || showingClones == 2){
|
if(showingClones == 0 || showingClones == 2){
|
||||||
|
|
||||||
addSideButton(new GuiMenuSideButton(21,guiLeft - 90, this.guiTop + 2, 90,22, "1"));
|
addSideButton(new GuiMenuSideButton(21,guiLeft - 70, this.guiTop + 2, 70,22, "1"));
|
||||||
addSideButton(new GuiMenuSideButton(22,guiLeft - 90, this.guiTop + 23, 90,22, "2"));
|
addSideButton(new GuiMenuSideButton(22,guiLeft - 70, this.guiTop + 23, 70,22, "2"));
|
||||||
addSideButton(new GuiMenuSideButton(23,guiLeft - 90, this.guiTop + 44, 90,22, "3"));
|
addSideButton(new GuiMenuSideButton(23,guiLeft - 70, this.guiTop + 44, 70,22, "3"));
|
||||||
addSideButton(new GuiMenuSideButton(24,guiLeft - 90, this.guiTop + 65, 90,22, "4"));
|
addSideButton(new GuiMenuSideButton(24,guiLeft - 70, this.guiTop + 65, 70,22, "4"));
|
||||||
addSideButton(new GuiMenuSideButton(25,guiLeft - 90, this.guiTop + 86, 90,22, "5"));
|
addSideButton(new GuiMenuSideButton(25,guiLeft - 70, this.guiTop + 86, 70,22, "5"));
|
||||||
addSideButton(new GuiMenuSideButton(26,guiLeft - 90, this.guiTop + 107, 45,22, "6"));
|
addSideButton(new GuiMenuSideButton(26,guiLeft - 70, this.guiTop + 107, 35,22, "6"));
|
||||||
addSideButton(new GuiMenuSideButton(27,guiLeft - 45, this.guiTop + 107, 45,22, "7"));
|
addSideButton(new GuiMenuSideButton(27,guiLeft - 35, this.guiTop + 107, 35,22, "7"));
|
||||||
addSideButton(new GuiMenuSideButton(28,guiLeft - 90, this.guiTop + 128, 45,22, "8"));
|
addSideButton(new GuiMenuSideButton(28,guiLeft - 70, this.guiTop + 128, 35,22, "8"));
|
||||||
addSideButton(new GuiMenuSideButton(29,guiLeft - 45, this.guiTop + 128, 45,22, "9"));
|
addSideButton(new GuiMenuSideButton(29,guiLeft - 35, this.guiTop + 128, 35,22, "9"));
|
||||||
addSideButton(new GuiMenuSideButton(30,guiLeft - 90, this.guiTop + 149, 45,22, "10"));
|
addSideButton(new GuiMenuSideButton(30,guiLeft - 70, this.guiTop + 149, 35,22, "10"));
|
||||||
addSideButton(new GuiMenuSideButton(31,guiLeft - 45, this.guiTop + 149, 45,22, "11"));
|
addSideButton(new GuiMenuSideButton(31,guiLeft - 35, this.guiTop + 149, 35,22, "11"));
|
||||||
addSideButton(new GuiMenuSideButton(32,guiLeft - 90, this.guiTop + 170, 45,22, "12"));
|
addSideButton(new GuiMenuSideButton(32,guiLeft - 70, this.guiTop + 170, 35,22, "12"));
|
||||||
addSideButton(new GuiMenuSideButton(33,guiLeft - 45, this.guiTop + 170, 45,22, "13"));
|
addSideButton(new GuiMenuSideButton(33,guiLeft - 35, this.guiTop + 170, 35,22, "13"));
|
||||||
addSideButton(new GuiMenuSideButton(34,guiLeft - 90, this.guiTop + 191, 45,22, "14"));
|
addSideButton(new GuiMenuSideButton(34,guiLeft - 70, this.guiTop + 191, 35,22, "14"));
|
||||||
addSideButton(new GuiMenuSideButton(35,guiLeft - 45, this.guiTop + 191, 45,22, "15"));
|
addSideButton(new GuiMenuSideButton(35,guiLeft - 35, this.guiTop + 191, 35,22, "15"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove"));
|
// addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 82, 20, "gui.remove"));
|
||||||
|
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove"));
|
||||||
|
|
||||||
getSideButton(20 + activeTab).active = true;
|
getSideButton(20 + activeTab).active = true;
|
||||||
showClones();
|
showClones();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.DataScript;
|
import noppes.npcs.DataScript;
|
||||||
import noppes.npcs.NoppesStringUtils;
|
import noppes.npcs.NoppesStringUtils;
|
||||||
import noppes.npcs.client.Client;
|
import noppes.npcs.client.Client;
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) {
|
protected void keyTyped(char typedChar, int keyCode) {
|
||||||
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
|
if (keyCode == 1)
|
||||||
{
|
{
|
||||||
this.mc.thePlayer.closeScreen();
|
this.mc.thePlayer.closeScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
boolean hovered = mouseX >= this.field_146162_g && mouseY >= this.field_146174_h && mouseX < this.field_146162_g + this.field_146167_a && mouseY < this.field_146174_h + this.field_146161_f;
|
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.field_146167_a && mouseY < this.y + this.field_146161_f;
|
||||||
this.drawLabel();
|
this.drawLabel();
|
||||||
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||||
this.parent.hoverText = this.hoverText;
|
this.parent.hoverText = this.hoverText;
|
||||||
@@ -146,6 +146,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
|||||||
lbl.color = component.getColor();
|
lbl.color = component.getColor();
|
||||||
lbl.alpha = component.getAlpha();
|
lbl.alpha = component.getAlpha();
|
||||||
lbl.rotation = component.getRotation();
|
lbl.rotation = component.getRotation();
|
||||||
|
lbl.field_146167_a = component.getWidth();
|
||||||
|
lbl.field_146161_f = component.getHeight();
|
||||||
|
|
||||||
return lbl;
|
return lbl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||||
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
|
||||||
mc.getTextureManager().bindTexture(this.texture);
|
mc.getTextureManager().bindTexture(this.texture);
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
@@ -80,10 +80,9 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
|||||||
float blue = (color & 255) / 255f;
|
float blue = (color & 255) / 255f;
|
||||||
GL11.glColor4f(red,green,blue,this.alpha);
|
GL11.glColor4f(red,green,blue,this.alpha);
|
||||||
|
|
||||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
|
||||||
|
|
||||||
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
|
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.0F);
|
||||||
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
|
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
|
||||||
|
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||||
|
|
||||||
int p_73729_1_ = (int) (this.x/this.scale);
|
int p_73729_1_ = (int) (this.x/this.scale);
|
||||||
int p_73729_2_ = (int) (this.y/this.scale);
|
int p_73729_2_ = (int) (this.y/this.scale);
|
||||||
|
|||||||
@@ -46,13 +46,14 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT
|
|||||||
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
|
||||||
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
|
||||||
getTextField(0).integersOnly = true;
|
getTextField(0).integersOnly = true;
|
||||||
getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0);
|
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
|
||||||
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
|
||||||
getTextField(1).integersOnly = true;
|
getTextField(1).integersOnly = true;
|
||||||
getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0);
|
|
||||||
|
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
|
||||||
|
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
|
||||||
|
|
||||||
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
|
||||||
|
|
||||||
addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5));
|
addLabel(new GuiNpcLabel(2,"inv.npcInventory", guiLeft + 191, guiTop + 5));
|
||||||
@@ -194,7 +195,9 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements IGuiData, IT
|
|||||||
public void unFocused(GuiNpcTextField textfield) {
|
public void unFocused(GuiNpcTextField textfield) {
|
||||||
if(textfield.id >= 2){
|
if(textfield.id >= 2){
|
||||||
chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
|
chances.put(textfield.id-2, Double.parseDouble(textfield.getText()));
|
||||||
this.save();
|
|
||||||
}
|
}
|
||||||
|
getTextField(0).setMinMaxDefault(0, getTextField(1).getInteger(), 0);
|
||||||
|
getTextField(1).setMinMaxDefault(getTextField(0).getInteger(), Short.MAX_VALUE, 0);
|
||||||
|
this.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,8 +88,12 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
addScroll(scroll);
|
addScroll(scroll);
|
||||||
|
|
||||||
guiTop += 50;
|
guiTop += 50;
|
||||||
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 300, 98, 20, "gui.back"));
|
this.addButton(new GuiNpcButton(0, guiLeft + 4, guiTop + 310, 98, 20, "gui.back"));
|
||||||
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs"}, quest.targetType));
|
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 260, 98, 20, new String[]{"Any", "NPCs", "Custom"}, quest.targetType));
|
||||||
|
|
||||||
|
this.addTextField(new GuiNpcTextField(36, this, fontRendererObj, guiLeft + 4, guiTop + 282, 180, 20, quest.customTargetType));
|
||||||
|
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
|
||||||
|
|
||||||
guiTop -= 50;
|
guiTop -= 50;
|
||||||
|
|
||||||
scroll.visible = GuiNpcTextField.isFieldActive();
|
scroll.visible = GuiNpcTextField.isFieldActive();
|
||||||
@@ -101,7 +105,8 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
if (guibutton.id == 1) {
|
if (guibutton.id == 1) {
|
||||||
quest.targetType = guibutton.displayString.equals("NPCs") ? 1 : 0;
|
quest.targetType = this.getButton(1).getValue();
|
||||||
|
this.getTextField(36).setVisible(this.getButton(1).getValue() == 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void mouseClicked(int i, int j, int k)
|
public void mouseClicked(int i, int j, int k)
|
||||||
@@ -117,6 +122,9 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
|
|||||||
if(guiNpcTextField.id < 12)
|
if(guiNpcTextField.id < 12)
|
||||||
lastSelected = guiNpcTextField;
|
lastSelected = guiNpcTextField;
|
||||||
|
|
||||||
|
if(guiNpcTextField.id == 36)
|
||||||
|
quest.customTargetType = guiNpcTextField.getText();
|
||||||
|
|
||||||
saveTargets();
|
saveTargets();
|
||||||
}
|
}
|
||||||
private void saveTargets(){
|
private void saveTargets(){
|
||||||
|
|||||||
@@ -163,8 +163,6 @@ public class GuiNpcPuppet extends GuiModelInterface implements ISliderListener{
|
|||||||
}
|
}
|
||||||
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
if(btn.id == 170 || btn.id == 171 || btn.id == 172){
|
||||||
if(btn.id == 170){
|
if(btn.id == 170){
|
||||||
System.out.println(part.rotationX);
|
|
||||||
System.out.println(rotateX.sliderValue);
|
|
||||||
part.rotationX = 0.0f;
|
part.rotationX = 0.0f;
|
||||||
rotateX.sliderValue = 0.5f;
|
rotateX.sliderValue = 0.5f;
|
||||||
int percent = (int) ((rotateX.sliderValue) * 360);
|
int percent = (int) ((rotateX.sliderValue) * 360);
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package noppes.npcs.client.gui.script;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.client.Client;
|
||||||
|
import noppes.npcs.constants.EnumPacketServer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
|
|
||||||
|
public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||||
|
private NPCDataScript script = new NPCDataScript(null);
|
||||||
|
|
||||||
|
public GuiScriptAllNPCs() {
|
||||||
|
this.handler = this.script;
|
||||||
|
Client.sendData(EnumPacketServer.ScriptNPCGet, new Object[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuiData(NBTTagCompound compound) {
|
||||||
|
this.script.readFromNBT(compound);
|
||||||
|
super.setGuiData(compound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
super.save();
|
||||||
|
Client.sendData(EnumPacketServer.ScriptNPCSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
ScriptController.Instance.npcScripts.errored.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ package noppes.npcs.client.gui.script;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
@@ -23,8 +24,17 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
|||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
this.addButton(new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players"));
|
GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players");
|
||||||
this.addButton(new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge"));
|
playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(playerButton);
|
||||||
|
|
||||||
|
GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge");
|
||||||
|
forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(forgeButton);
|
||||||
|
|
||||||
|
GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs");
|
||||||
|
npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled);
|
||||||
|
this.addButton(npcButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawScreen(int i, int j, float f) {
|
public void drawScreen(int i, int j, float f) {
|
||||||
@@ -42,6 +52,9 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
|||||||
if (guibutton.id == 1) {
|
if (guibutton.id == 1) {
|
||||||
this.displayGuiScreen(new GuiScriptForge());
|
this.displayGuiScreen(new GuiScriptForge());
|
||||||
}
|
}
|
||||||
|
if (guibutton.id == 2) {
|
||||||
|
this.displayGuiScreen(new GuiScriptAllNPCs());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyTyped(char c, int i) {
|
public void keyTyped(char c, int i) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import noppes.npcs.client.gui.util.*;
|
|||||||
import noppes.npcs.controllers.IScriptHandler;
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
import noppes.npcs.controllers.ScriptController;
|
import noppes.npcs.controllers.ScriptController;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -147,6 +148,22 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
|||||||
hookList.add("customGuiSlot");
|
hookList.add("customGuiSlot");
|
||||||
hookList.add("customGuiScroll");
|
hookList.add("customGuiScroll");
|
||||||
hookList.add("customGuiTextfield");
|
hookList.add("customGuiTextfield");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(handler instanceof NPCDataScript) {
|
||||||
|
hookList.add("init");
|
||||||
|
hookList.add("tick");
|
||||||
|
hookList.add("interact");
|
||||||
|
hookList.add("dialog");
|
||||||
|
hookList.add("damaged");
|
||||||
|
hookList.add("killed");
|
||||||
|
hookList.add("meleeAttack");
|
||||||
|
hookList.add("rangedLaunched");
|
||||||
|
hookList.add("target");
|
||||||
|
hookList.add("collide");
|
||||||
|
hookList.add("kills");
|
||||||
|
hookList.add("dialogClose");
|
||||||
|
hookList.add("timer");
|
||||||
}
|
}
|
||||||
else if(handler instanceof ForgeDataScript) {
|
else if(handler instanceof ForgeDataScript) {
|
||||||
hooks.setSize(238, 198);
|
hooks.setSize(238, 198);
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
|
|||||||
{
|
{
|
||||||
private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
private ResourceLocation background = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
||||||
private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
private final ResourceLocation defaultBackground = new ResourceLocation("customnpcs","textures/gui/menubg.png");
|
||||||
private GuiNpcMenu menu;
|
private final ResourceLocation defaultBackground2 = new ResourceLocation("customnpcs","textures/gui/menubg2.png");
|
||||||
|
|
||||||
|
private GuiNpcMenu menu;
|
||||||
public int menuYOffset = 0;
|
public int menuYOffset = 0;
|
||||||
|
|
||||||
public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont)
|
public GuiContainerNPCInterface2(EntityNPCInterface npc,Container cont)
|
||||||
@@ -74,18 +76,12 @@ public abstract class GuiContainerNPCInterface2 extends GuiContainerNPCInterface
|
|||||||
mc.renderEngine.bindTexture(background);
|
mc.renderEngine.bindTexture(background);
|
||||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256);
|
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, 256);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
mc.renderEngine.bindTexture(defaultBackground);
|
mc.renderEngine.bindTexture(defaultBackground2);
|
||||||
drawTexturedModalRect(guiLeft + xSize-200, guiTop, 26, 0, 200, 220);
|
drawTexturedModalRect(guiLeft + xSize-256, guiTop, 0, 0, 256, 220);
|
||||||
|
|
||||||
menu.drawElements(fontRendererObj, i, j, mc, f);
|
menu.drawElements(fontRendererObj, i, j, mc, f);
|
||||||
|
|
||||||
super.drawGuiContainerBackgroundLayer(f, i, j);
|
super.drawGuiContainerBackgroundLayer(f, i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void drawSlotInventory(Slot par1Slot)
|
|
||||||
// {this.dra
|
|
||||||
// if(subgui == null)
|
|
||||||
// super.drawSlotInventory(par1Slot);
|
|
||||||
// } //TODO fix
|
|
||||||
}
|
}
|
||||||
@@ -114,13 +114,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Alex");
|
||||||
this.bipedRightArm.addChild(this.solidRightArmWear);
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Alex");
|
||||||
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -136,13 +136,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
this.bipedRightArmWear = (new ModelScaleRenderer(this, 40, 32));
|
||||||
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightArmWear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
this.bipedRightArm.addChild(this.bipedRightArmWear);
|
||||||
this.solidRightArmWear = new ModelLimbWear(this,"arm","right");
|
this.solidRightArmWear = new ModelLimbWear(this,"arm","right","Steve");
|
||||||
this.bipedRightArm.addChild(this.solidRightArmWear);
|
this.bipedRightArm.addChild(this.solidRightArmWear);
|
||||||
|
|
||||||
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
this.bipedLeftArmwear = new ModelScaleRenderer(this, 48, 48);
|
||||||
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
this.bipedLeftArm.addChild(this.bipedLeftArmwear);
|
||||||
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left");
|
this.solidLeftArmWear = new ModelLimbWear(this,"arm","left","Steve");
|
||||||
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
this.bipedLeftArm.addChild(this.solidLeftArmWear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,13 +157,13 @@ public class ModelMPM extends ModelNPCMale{
|
|||||||
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
this.bipedRightLegWear = (new ModelScaleRenderer(this, 0, 32));
|
||||||
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedRightLegWear.addBox(-2.08F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
this.bipedRightLeg.addChild(this.bipedRightLegWear);
|
||||||
this.solidRightLegWear = new ModelLimbWear(this,"leg","right");
|
this.solidRightLegWear = new ModelLimbWear(this,"leg","right","Steve");
|
||||||
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
this.bipedRightLeg.addChild(this.solidRightLegWear);
|
||||||
|
|
||||||
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
this.bipedLeftLegWear = new ModelScaleRenderer(this, 0, 48);
|
||||||
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
this.bipedLeftLegWear.addBox(-1.92F, 0.0F, -2.0F, 4, 12, 4, par1 + 0.25F);
|
||||||
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
this.bipedLeftLeg.addChild(this.bipedLeftLegWear);
|
||||||
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left");
|
this.solidLeftLegWear = new ModelLimbWear(this,"leg","left","Steve");
|
||||||
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
this.bipedLeftLeg.addChild(this.solidLeftLegWear);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
package noppes.npcs.client.model.part;
|
package noppes.npcs.client.model.part;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
@@ -6,18 +8,32 @@ import noppes.npcs.client.model.util.Model2DRenderer;
|
|||||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||||
|
|
||||||
public class ModelLimbWear extends ModelScaleRenderer {
|
public class ModelLimbWear extends ModelScaleRenderer {
|
||||||
public ModelLimbWear(ModelBase base, String limb, String side) {
|
public ModelLimbWear(ModelBase base, String limb, String side, String type) {
|
||||||
super(base);
|
super(base);
|
||||||
|
|
||||||
float thick = 0.55f;
|
float thick = 0.55f;
|
||||||
switch (limb){
|
switch (limb){
|
||||||
case "arm":
|
case "arm":
|
||||||
switch (side){
|
switch(type) {
|
||||||
case "right":
|
case "Steve":
|
||||||
rightArm(base,thick);
|
switch (side) {
|
||||||
|
case "right":
|
||||||
|
rightArm(base, thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftArm(base, thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "left":
|
case "Alex":
|
||||||
leftArm(base,thick);
|
switch (side) {
|
||||||
|
case "right":
|
||||||
|
rightArmAlex(base, thick);
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
leftArmAlex(base, thick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -36,6 +52,100 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rightArmAlex(ModelBase base, float thick){
|
||||||
|
float x = 0.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 44, 36, 3, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 51, 36, 3, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 47, 36, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 3, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 47, 32, 3, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leftArmAlex(ModelBase base,float thick){
|
||||||
|
float x = 1.95f;
|
||||||
|
float y = -2.0f;
|
||||||
|
|
||||||
|
Model2DRenderer front = new Model2DRenderer(base, 44+8, 36+16, 3, 12, 64, 64);
|
||||||
|
front.setRotationPoint(-3.39375f+x, 12.535f+y, -2.58f);
|
||||||
|
front.setScale(0.96f,0.8175f);
|
||||||
|
front.setThickness(thick);
|
||||||
|
setRotation(front, 0, 0, 0);
|
||||||
|
this.addChild(front);
|
||||||
|
|
||||||
|
Model2DRenderer back = new Model2DRenderer(base, 51+8, 36+16, 3, 12, 64, 64);
|
||||||
|
back.setRotationPoint(0.44f+x, 12.535f+y, 2.58f);
|
||||||
|
back.setScale(0.96f,0.8175f);
|
||||||
|
back.setThickness(thick);
|
||||||
|
setRotation(back, 0, (float)(Math.PI), 0);
|
||||||
|
this.addChild(back);
|
||||||
|
|
||||||
|
Model2DRenderer right = new Model2DRenderer(base, 47+8, 36+16, 4, 12, 64, 64);
|
||||||
|
right.setRotationPoint(0.45f+x, 12.55f+y, -2.55f);
|
||||||
|
right.setScale(0.96f,0.82f);
|
||||||
|
right.setThickness(thick);
|
||||||
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
|
this.addChild(right);
|
||||||
|
|
||||||
|
Model2DRenderer left = new Model2DRenderer(base, 40+8, 36+16, 4, 12, 64, 64);
|
||||||
|
left.setRotationPoint(-3.405f+x, 12.55f+y, 2.55f);
|
||||||
|
left.setScale(0.96f,0.82f);
|
||||||
|
left.setThickness(thick);
|
||||||
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
|
this.addChild(left);
|
||||||
|
|
||||||
|
Model2DRenderer top = new Model2DRenderer(base, 44+8, 32+16, 3, 4, 64, 64);
|
||||||
|
top.setRotationPoint(-3.39375f+x, -0.6f+y, -2.55f);
|
||||||
|
top.setScale(0.32f);
|
||||||
|
top.setThickness(thick);
|
||||||
|
setRotation(top, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(top);
|
||||||
|
|
||||||
|
Model2DRenderer bottom = new Model2DRenderer(base, 47+8, 32+16, 3, 4, 64, 64);
|
||||||
|
bottom.setRotationPoint(-3.39375f+x, 12.0f+y, -2.545f);
|
||||||
|
bottom.setScale(0.32f);
|
||||||
|
bottom.setThickness(thick);
|
||||||
|
setRotation(bottom, (float)(Math.PI / -2), 0, 0);
|
||||||
|
this.addChild(bottom);
|
||||||
|
}
|
||||||
|
|
||||||
public void rightArm(ModelBase base, float thick){
|
public void rightArm(ModelBase base, float thick){
|
||||||
float x = 0.95f;
|
float x = 0.95f;
|
||||||
float y = -2.0f;
|
float y = -2.0f;
|
||||||
@@ -55,17 +165,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 48, 36, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.1f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 40, 36, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-3.98f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
|
Model2DRenderer top = new Model2DRenderer(base, 44, 32, 4, 4, 64, 64);
|
||||||
@@ -102,17 +212,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 56, 52, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.06f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 48, 52, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.56f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
@@ -150,17 +260,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 8, 36, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 0, 36, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
@@ -198,17 +308,17 @@ public class ModelLimbWear extends ModelScaleRenderer {
|
|||||||
this.addChild(back);
|
this.addChild(back);
|
||||||
|
|
||||||
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
|
Model2DRenderer right = new Model2DRenderer(base, 8, 52, 4, 12, 64, 64);
|
||||||
right.setRotationPoint(0.15f+x, 12.55f+y, 2.55f);
|
right.setRotationPoint(0.62f+x, 12.55f+y, -2.55f);
|
||||||
right.setScale(0.96f,0.82f);
|
right.setScale(0.96f,0.82f);
|
||||||
right.setThickness(thick);
|
right.setThickness(thick);
|
||||||
setRotation(right, 0, (float)(Math.PI/2f), 0);
|
setRotation(right, 0, (float)(Math.PI/-2f), 0);
|
||||||
this.addChild(right);
|
this.addChild(right);
|
||||||
|
|
||||||
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
|
Model2DRenderer left = new Model2DRenderer(base, 0, 52, 4, 12, 64, 64);
|
||||||
left.setRotationPoint(-4.03f+x, 12.55f+y, -2.55f);
|
left.setRotationPoint(-4.53f+x, 12.55f+y, 2.55f);
|
||||||
left.setScale(0.96f,0.82f);
|
left.setScale(0.96f,0.82f);
|
||||||
left.setThickness(thick);
|
left.setThickness(thick);
|
||||||
setRotation(left, 0, (float)(Math.PI/-2f), 0);
|
setRotation(left, 0, (float)(Math.PI/2f), 0);
|
||||||
this.addChild(left);
|
this.addChild(left);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -255,7 +255,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
||||||
}
|
}
|
||||||
this.modelBipedMain.bipedRightArm.postRender(0.0625F);
|
this.modelBipedMain.bipedRightArm.postRender(0.0625F);
|
||||||
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
|
|
||||||
|
if(npc.getModelType() == 2){
|
||||||
|
GL11.glTranslatef(-0.0125F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
||||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
||||||
@@ -269,8 +275,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||||
GL11.glScalef(-var6, -var6, var6);
|
GL11.glScalef(-var6, -var6, var6);
|
||||||
}
|
}
|
||||||
// CHANGE HERE
|
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
|
||||||
else if (itemstack2.getItem() instanceof ItemBow)
|
|
||||||
{
|
{
|
||||||
var6 = 0.625F;
|
var6 = 0.625F;
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
@@ -343,8 +348,15 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
|
||||||
}
|
}
|
||||||
this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
|
this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
|
||||||
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
|
|
||||||
float var6;
|
if(npc.getModelType() == 2){
|
||||||
|
GL11.glTranslatef(0.0125F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
|
||||||
|
}
|
||||||
|
|
||||||
|
float var6;
|
||||||
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
|
||||||
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
|
||||||
@@ -362,7 +374,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
|
|||||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||||
GL11.glScalef(var6, -var6, var6);
|
GL11.glScalef(var6, -var6, var6);
|
||||||
}
|
}
|
||||||
else if (itemstack2.getItem() instanceof ItemBow)
|
else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
|
||||||
{
|
{
|
||||||
var6 = 0.625F;
|
var6 = 0.625F;
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
|
|||||||
@@ -219,7 +219,6 @@ public class RenderNPCPony extends RenderNPCInterface
|
|||||||
float f4 = 0.375F * f;
|
float f4 = 0.375F * f;
|
||||||
GL11.glScalef(f4, -f4, f4);
|
GL11.glScalef(f4, -f4, f4);
|
||||||
} else
|
} else
|
||||||
// CHANGE HERE
|
|
||||||
if(itemstack.getItem() instanceof ItemBow)
|
if(itemstack.getItem() instanceof ItemBow)
|
||||||
{
|
{
|
||||||
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ public enum EnumPacketServer {
|
|||||||
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
ScriptForgeSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
ScriptForgeGet(false),
|
ScriptForgeGet(false),
|
||||||
|
|
||||||
|
ScriptNPCSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||||
|
ScriptNPCGet(false),
|
||||||
|
|
||||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||||
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA),
|
||||||
|
|||||||
@@ -67,10 +67,7 @@ public class Dialog implements ICompatibilty, IDialog {
|
|||||||
else {
|
else {
|
||||||
darkenScreen = true;
|
darkenScreen = true;
|
||||||
}
|
}
|
||||||
// Temporary Remove after Few Versions
|
|
||||||
if(compound.hasKey("DialogDarkenScreen")){
|
|
||||||
compound.removeTag("DialogDarkenScreen");
|
|
||||||
}
|
|
||||||
|
|
||||||
NBTTagList options = compound.getTagList("Options", 10);
|
NBTTagList options = compound.getTagList("Options", 10);
|
||||||
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
|
HashMap<Integer,DialogOption> newoptions = new HashMap<Integer,DialogOption>();
|
||||||
@@ -104,10 +101,6 @@ public class Dialog implements ICompatibilty, IDialog {
|
|||||||
compound.setBoolean("DialogDisableEsc", disableEsc);
|
compound.setBoolean("DialogDisableEsc", disableEsc);
|
||||||
|
|
||||||
compound.setBoolean("DialogDarkScreen", darkenScreen);
|
compound.setBoolean("DialogDarkScreen", darkenScreen);
|
||||||
// Temporary Remove after Few Versions
|
|
||||||
if(compound.hasKey("DialogDarkenScreen")){
|
|
||||||
compound.removeTag("DialogDarkenScreen");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sound != null && !sound.isEmpty())
|
if(sound != null && !sound.isEmpty())
|
||||||
compound.setString("DialogSound", sound);
|
compound.setString("DialogSound", sound);
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
package noppes.npcs.controllers;
|
package noppes.npcs.controllers;
|
||||||
|
|
||||||
import java.io.EOFException;
|
import luizotavio.compressor.ZstdCompressor;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
|
import net.minecraft.nbt.NBTSizeTracker;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
|
import noppes.npcs.util.JsonException;
|
||||||
import noppes.npcs.util.NBTJsonUtil;
|
import noppes.npcs.util.NBTJsonUtil;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static luizotavio.compressor.executor.IOExecutor.IO_EXECUTOR;
|
||||||
|
|
||||||
public class PlayerDataController {
|
public class PlayerDataController {
|
||||||
public static PlayerDataController instance;
|
public static PlayerDataController instance;
|
||||||
|
|
||||||
@@ -70,14 +73,20 @@ public class PlayerDataController {
|
|||||||
public NBTTagCompound loadPlayerData(String player){
|
public NBTTagCompound loadPlayerData(String player){
|
||||||
File saveDir = getSaveDir();
|
File saveDir = getSaveDir();
|
||||||
String filename = player;
|
String filename = player;
|
||||||
if(filename.isEmpty())
|
if(filename.isEmpty()) {
|
||||||
filename = "noplayername";
|
return new NBTTagCompound();
|
||||||
filename += ".json";
|
}
|
||||||
|
|
||||||
|
if(CustomNpcs.CompressorType.equalsIgnoreCase("zstd")) {
|
||||||
|
filename += ".zstd";
|
||||||
|
} else {
|
||||||
|
filename += ".json";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File file = new File(saveDir, filename);
|
return ensureCompressor(
|
||||||
if(file.exists()){
|
new File(saveDir, filename)
|
||||||
return NBTJsonUtil.LoadFile(file);
|
);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.error("Error loading: " + filename, e);
|
LogWriter.error("Error loading: " + filename, e);
|
||||||
}
|
}
|
||||||
@@ -87,16 +96,24 @@ public class PlayerDataController {
|
|||||||
|
|
||||||
public void savePlayerData(PlayerData data){
|
public void savePlayerData(PlayerData data){
|
||||||
NBTTagCompound compound = data.getNBT();
|
NBTTagCompound compound = data.getNBT();
|
||||||
String filename = data.uuid + ".json";
|
String filename;
|
||||||
|
|
||||||
|
if (CustomNpcs.CompressorType.equalsIgnoreCase("zstd")) {
|
||||||
|
filename = data.uuid + ".zstd";
|
||||||
|
} else {
|
||||||
|
filename = data.uuid + ".json";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File saveDir = getSaveDir();
|
File saveDir = getSaveDir();
|
||||||
File file = new File(saveDir, filename+"_new");
|
|
||||||
File file1 = new File(saveDir, filename);
|
File file = new File(saveDir, filename);
|
||||||
NBTJsonUtil.SaveFile(file, compound);
|
|
||||||
if(file1.exists()){
|
if (file.exists()) {
|
||||||
file1.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
file.renameTo(file1);
|
|
||||||
|
writeCompressor(file, compound);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogWriter.except(e);
|
LogWriter.except(e);
|
||||||
}
|
}
|
||||||
@@ -164,7 +181,8 @@ public class PlayerDataController {
|
|||||||
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
if(file.isDirectory() || !file.getName().endsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
|
NBTTagCompound compound = ensureCompressor(file);
|
||||||
|
|
||||||
if(compound.hasKey("PlayerName")){
|
if(compound.hasKey("PlayerName")){
|
||||||
map.put(compound.getString("PlayerName"), compound);
|
map.put(compound.getString("PlayerName"), compound);
|
||||||
}
|
}
|
||||||
@@ -178,4 +196,57 @@ public class PlayerDataController {
|
|||||||
public boolean hasMail(EntityPlayer player) {
|
public boolean hasMail(EntityPlayer player) {
|
||||||
return getPlayerData(player).mailData.hasMail();
|
return getPlayerData(player).mailData.hasMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeCompressor(File file, NBTTagCompound compound) {
|
||||||
|
if (compound == null) {
|
||||||
|
throw new IllegalArgumentException("Compound cannot be null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomNpcs.CompressorType.equalsIgnoreCase("json")) {
|
||||||
|
IO_EXECUTOR.submit(() -> {
|
||||||
|
try {
|
||||||
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
|
} catch (IOException | JsonException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (CustomNpcs.CompressorType.equalsIgnoreCase("zstd")) {
|
||||||
|
IO_EXECUTOR.submit(() -> {
|
||||||
|
try {
|
||||||
|
byte[] compressed = ZstdCompressor.writeCompound(compound);
|
||||||
|
|
||||||
|
Files.write(
|
||||||
|
file.toPath(),
|
||||||
|
compressed,
|
||||||
|
StandardOpenOption.CREATE,
|
||||||
|
StandardOpenOption.WRITE
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private NBTTagCompound ensureCompressor(File file) throws JsonException, IOException {
|
||||||
|
if (!file.exists()) {
|
||||||
|
return new NBTTagCompound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomNpcs.CompressorType.equalsIgnoreCase("json")) {
|
||||||
|
return NBTJsonUtil.LoadFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomNpcs.CompressorType.equalsIgnoreCase("zstd")) {
|
||||||
|
byte[] readCompressed = ZstdCompressor.readCompressed(
|
||||||
|
new RandomAccessFile(file, "r")
|
||||||
|
);
|
||||||
|
|
||||||
|
try (DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(readCompressed))) {
|
||||||
|
return CompressedStreamTools.func_152456_a(dataInputStream, NBTSizeTracker.field_152451_a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IOException("Unknown compressor type: " + CustomNpcs.CompressorType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -110,10 +110,16 @@ public class ScriptContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run(EnumScriptType type, Event event) {
|
public void run(EnumScriptType type, Event event) {
|
||||||
|
if(!CustomNpcs.ScriptingEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
this.run((String)type.function, (Object)event);
|
this.run((String)type.function, (Object)event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String type, Object event) {
|
public void run(String type, Object event) {
|
||||||
|
if(!CustomNpcs.ScriptingEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
||||||
this.setEngine(this.handler.getLanguage());
|
this.setEngine(this.handler.getLanguage());
|
||||||
if (this.engine != null) {
|
if (this.engine != null) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
|||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.LogWriter;
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||||
|
import noppes.npcs.controllers.data.NPCDataScript;
|
||||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import noppes.npcs.scripted.entity.*;
|
import noppes.npcs.scripted.entity.*;
|
||||||
@@ -56,6 +57,8 @@ public class ScriptController {
|
|||||||
|
|
||||||
public ForgeDataScript forgeScripts = new ForgeDataScript();
|
public ForgeDataScript forgeScripts = new ForgeDataScript();
|
||||||
|
|
||||||
|
public NPCDataScript npcScripts = new NPCDataScript((EntityNPCInterface) null);
|
||||||
|
|
||||||
public ScriptController(){
|
public ScriptController(){
|
||||||
loaded = false;
|
loaded = false;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@@ -111,6 +114,10 @@ public class ScriptController {
|
|||||||
return new File(dir, "player_scripts.json");
|
return new File(dir, "player_scripts.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File npcScriptsFile() {
|
||||||
|
return new File(dir, "npc_scripts.json");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean loadPlayerScripts() {
|
public boolean loadPlayerScripts() {
|
||||||
this.playerScripts.clear();
|
this.playerScripts.clear();
|
||||||
File file = this.playerScriptsFile();
|
File file = this.playerScriptsFile();
|
||||||
@@ -143,6 +150,37 @@ public class ScriptController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean loadNPCScripts() {
|
||||||
|
this.npcScripts.clear();
|
||||||
|
File file = this.npcScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(!file.exists()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.npcScripts.readFromNBT(NBTJsonUtil.LoadFile(file));
|
||||||
|
shouldSave = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception var3) {
|
||||||
|
LogWriter.error("Error loading: " + file.getAbsolutePath(), var3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNPCScripts(NBTTagCompound compound) {
|
||||||
|
this.npcScripts.readFromNBT(compound);
|
||||||
|
File file = this.npcScriptsFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
NBTJsonUtil.SaveFile(file, compound);
|
||||||
|
} catch (IOException var4) {
|
||||||
|
var4.printStackTrace();
|
||||||
|
} catch (JsonException var5) {
|
||||||
|
var5.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadCategories(){
|
private void loadCategories(){
|
||||||
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public class ServerCloneController implements ICloneHandler {
|
|||||||
try {
|
try {
|
||||||
File dir = new File(getDir(), "..");
|
File dir = new File(getDir(), "..");
|
||||||
File file = new File(dir, "clonednpcs.dat");
|
File file = new File(dir, "clonednpcs.dat");
|
||||||
System.out.println(file.getAbsolutePath());
|
// System.out.println(file.getAbsolutePath());
|
||||||
System.out.println(file.exists());
|
// System.out.println(file.exists());
|
||||||
if(file.exists()){
|
if(file.exists()){
|
||||||
Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file);
|
Map<Integer, Map<String, NBTTagCompound>> clones = loadOldClones(file);
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.EventHooks;
|
import noppes.npcs.EventHooks;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
@@ -84,7 +85,7 @@ public class ForgeDataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getEnabled() {
|
public boolean getEnabled() {
|
||||||
return this.enabled;
|
return CustomNpcs.GlobalForgeScripts && this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean bo) {
|
public void setEnabled(boolean bo) {
|
||||||
|
|||||||
@@ -0,0 +1,297 @@
|
|||||||
|
package noppes.npcs.controllers.data;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.NBTTags;
|
||||||
|
import noppes.npcs.constants.EnumScriptType;
|
||||||
|
import noppes.npcs.controllers.IScriptHandler;
|
||||||
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
|
import noppes.npcs.controllers.ScriptController;
|
||||||
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class NPCDataScript implements IScriptHandler {
|
||||||
|
public List<ScriptContainer> scripts = new ArrayList();
|
||||||
|
public String scriptLanguage = "ECMAScript";
|
||||||
|
private EntityNPCInterface npc;
|
||||||
|
private ICustomNpc npcAPI;
|
||||||
|
public long lastInited = -1L;
|
||||||
|
public boolean enabled = false;
|
||||||
|
private Map<Long, String> console = new TreeMap();
|
||||||
|
public List<Integer> errored = new ArrayList();
|
||||||
|
|
||||||
|
public NPCDataScript(EntityNPCInterface npc) {
|
||||||
|
if(npc != null) {
|
||||||
|
this.npc = npc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void clear() {
|
||||||
|
this.console = new TreeMap();
|
||||||
|
this.errored = new ArrayList();
|
||||||
|
this.scripts = new ArrayList();
|
||||||
|
}
|
||||||
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
|
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
|
||||||
|
this.scriptLanguage = compound.getString("ScriptLanguage");
|
||||||
|
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||||
|
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
|
||||||
|
}
|
||||||
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||||
|
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
|
||||||
|
compound.setString("ScriptLanguage", this.scriptLanguage);
|
||||||
|
compound.setBoolean("ScriptEnabled", this.enabled);
|
||||||
|
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
|
||||||
|
return compound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void callScript(EnumScriptType type, Event event) {
|
||||||
|
if (this.isEnabled()) {
|
||||||
|
ScriptContainer script;
|
||||||
|
if (ScriptController.Instance.lastLoaded > this.lastInited) {
|
||||||
|
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||||
|
errored.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < ScriptController.Instance.npcScripts.scripts.size(); ++i) {
|
||||||
|
script = (ScriptContainer)ScriptController.Instance.npcScripts.scripts.get(i);
|
||||||
|
if (!errored.contains(i)) {
|
||||||
|
if(script == null || script.errored || !script.hasCode() || ScriptController.Instance.npcScripts.errored.contains(i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
script.run(type, event);
|
||||||
|
|
||||||
|
if (script.errored) {
|
||||||
|
ScriptController.Instance.npcScripts.errored.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator var8 = script.console.entrySet().iterator();
|
||||||
|
|
||||||
|
while(var8.hasNext()) {
|
||||||
|
Map.Entry<Long, String> entry = (Map.Entry)var8.next();
|
||||||
|
if (!ScriptController.Instance.npcScripts.console.containsKey(entry.getKey())) {
|
||||||
|
ScriptController.Instance.npcScripts.console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + (String)entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
script.console.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return CustomNpcs.GlobalNPCScripts && ScriptController.Instance.npcScripts.enabled && ScriptController.HasStart && (this.npc == null || !this.npc.worldObj.isRemote);
|
||||||
|
}
|
||||||
|
public boolean isClient() {
|
||||||
|
return this.npc.isClientWorld();
|
||||||
|
}
|
||||||
|
public boolean getEnabled() {
|
||||||
|
return ScriptController.Instance.npcScripts.enabled;
|
||||||
|
}
|
||||||
|
public void setEnabled(boolean bo) {
|
||||||
|
ScriptController.Instance.npcScripts.enabled = bo;
|
||||||
|
this.enabled = bo;
|
||||||
|
}
|
||||||
|
public String getLanguage() {
|
||||||
|
return ScriptController.Instance.npcScripts.scriptLanguage;
|
||||||
|
}
|
||||||
|
public void setLanguage(String lang) {
|
||||||
|
this.scriptLanguage = lang;
|
||||||
|
}
|
||||||
|
public List<ScriptContainer> getScripts() {
|
||||||
|
return this.scripts;
|
||||||
|
}
|
||||||
|
public String noticeString() {
|
||||||
|
if(this.npc == null) {
|
||||||
|
return "Global script";
|
||||||
|
} else {
|
||||||
|
BlockPos pos = new BlockPos(this.npc);
|
||||||
|
return NPCDataScript.toStringHelper(this.npc).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ICustomNpc getNpc() {
|
||||||
|
if (this.npcAPI == null) {
|
||||||
|
this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc);
|
||||||
|
}
|
||||||
|
return this.npcAPI;
|
||||||
|
}
|
||||||
|
public Map<Long, String> getConsoleText() {
|
||||||
|
return this.console;
|
||||||
|
}
|
||||||
|
public void clearConsole() {
|
||||||
|
this.console.clear();
|
||||||
|
}
|
||||||
|
public static final class ToStringHelper {
|
||||||
|
private final String className;
|
||||||
|
private final NPCDataScript.ToStringHelper.ValueHolder holderHead;
|
||||||
|
private NPCDataScript.ToStringHelper.ValueHolder holderTail;
|
||||||
|
private boolean omitNullValues;
|
||||||
|
private boolean omitEmptyValues;
|
||||||
|
private ToStringHelper(String className) {
|
||||||
|
this.holderHead = new NPCDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderHead;
|
||||||
|
this.omitNullValues = false;
|
||||||
|
this.omitEmptyValues = false;
|
||||||
|
this.className = (String) Preconditions.checkNotNull(className);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper omitNullValues() {
|
||||||
|
this.omitNullValues = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
|
||||||
|
return this.addHolder(name, value);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, boolean value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, char value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, double value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, float value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, int value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper add(String name, long value) {
|
||||||
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(@CheckForNull Object value) {
|
||||||
|
return this.addHolder(value);
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(boolean value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(char value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(double value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(float value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(int value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
public NPCDataScript.ToStringHelper addValue(long value) {
|
||||||
|
return this.addUnconditionalHolder(String.valueOf(value));
|
||||||
|
}
|
||||||
|
private static boolean isEmpty(Object value) {
|
||||||
|
if (value instanceof CharSequence) {
|
||||||
|
return ((CharSequence)value).length() == 0;
|
||||||
|
} else if (value instanceof Collection) {
|
||||||
|
return ((Collection)value).isEmpty();
|
||||||
|
} else if (value instanceof Map) {
|
||||||
|
return ((Map)value).isEmpty();
|
||||||
|
} else if (value instanceof Optional) {
|
||||||
|
return !((Optional)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalInt) {
|
||||||
|
return !((OptionalInt)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalLong) {
|
||||||
|
return !((OptionalLong)value).isPresent();
|
||||||
|
} else if (value instanceof OptionalDouble) {
|
||||||
|
return !((OptionalDouble)value).isPresent();
|
||||||
|
} else if (value instanceof com.google.common.base.Optional) {
|
||||||
|
return !((com.google.common.base.Optional)value).isPresent();
|
||||||
|
} else if (value.getClass().isArray()) {
|
||||||
|
return Array.getLength(value) == 0;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
boolean omitNullValuesSnapshot = this.omitNullValues;
|
||||||
|
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
|
||||||
|
String nextSeparator = "";
|
||||||
|
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
|
||||||
|
for(NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
|
||||||
|
Object value = valueHolder.value;
|
||||||
|
if (!(valueHolder instanceof NPCDataScript.ToStringHelper.UnconditionalValueHolder)) {
|
||||||
|
if (value == null) {
|
||||||
|
if (omitNullValuesSnapshot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (omitEmptyValuesSnapshot && isEmpty(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.append(nextSeparator);
|
||||||
|
nextSeparator = ", ";
|
||||||
|
if (valueHolder.name != null) {
|
||||||
|
builder.append(valueHolder.name).append('=');
|
||||||
|
}
|
||||||
|
if (value != null && value.getClass().isArray()) {
|
||||||
|
Object[] objectArray = new Object[]{value};
|
||||||
|
String arrayString = Arrays.deepToString(objectArray);
|
||||||
|
builder.append(arrayString, 1, arrayString.length() - 1);
|
||||||
|
} else {
|
||||||
|
builder.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.append('}').toString();
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper.ValueHolder addHolder() {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = new NPCDataScript.ToStringHelper.ValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new NPCDataScript.ToStringHelper.UnconditionalValueHolder();
|
||||||
|
this.holderTail = this.holderTail.next = valueHolder;
|
||||||
|
return valueHolder;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addUnconditionalHolder(Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private NPCDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
|
||||||
|
NPCDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
||||||
|
valueHolder.value = value;
|
||||||
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private static final class UnconditionalValueHolder extends NPCDataScript.ToStringHelper.ValueHolder {
|
||||||
|
private UnconditionalValueHolder() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class ValueHolder {
|
||||||
|
@CheckForNull
|
||||||
|
String name;
|
||||||
|
@CheckForNull
|
||||||
|
Object value;
|
||||||
|
@CheckForNull
|
||||||
|
NPCDataScript.ToStringHelper.ValueHolder next;
|
||||||
|
private ValueHolder() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static NPCDataScript.ToStringHelper toStringHelper(Object self) {
|
||||||
|
return new NPCDataScript.ToStringHelper(self.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
|
import noppes.npcs.CustomNpcs;
|
||||||
import noppes.npcs.EventHooks;
|
import noppes.npcs.EventHooks;
|
||||||
import noppes.npcs.controllers.ScriptContainer;
|
import noppes.npcs.controllers.ScriptContainer;
|
||||||
import noppes.npcs.NBTTags;
|
import noppes.npcs.NBTTags;
|
||||||
@@ -106,7 +107,7 @@ public class PlayerDataScript implements IScriptHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
return CustomNpcs.GlobalPlayerScripts && ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
||||||
}
|
}
|
||||||
public boolean isClient() {
|
public boolean isClient() {
|
||||||
return this.player.isClientWorld();
|
return this.player.isClientWorld();
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package noppes.npcs.entity;
|
package noppes.npcs.entity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
|
||||||
import net.minecraft.entity.ai.EntityAISwimming;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||||
@@ -30,17 +26,21 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
super.updateFallState(p_180433_1_, p_180433_3_);
|
super.updateFallState(p_180433_1_, p_180433_3_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLivingUpdate()
|
@Override
|
||||||
|
public boolean isOnLadder(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
|
||||||
{
|
{
|
||||||
super.onLivingUpdate();
|
if(!this.canFly() || this.hurtTime != 0) {
|
||||||
if(!canFly()){
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockY = (int) this.posY;
|
|
||||||
double heightOffGround = 0;
|
double heightOffGround = 0;
|
||||||
if(this.ai.hasFlyLimit) {
|
if(this.ai.hasFlyLimit) {
|
||||||
for (blockY = (int) this.posY; blockY > 0; blockY--) {
|
for (int blockY = (int) this.posY; blockY > 0; blockY--) {
|
||||||
heightOffGround = this.posY - blockY;
|
heightOffGround = this.posY - blockY;
|
||||||
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
|
if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){
|
||||||
break;
|
break;
|
||||||
@@ -48,24 +48,19 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0)
|
if(heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit){
|
||||||
{
|
super.moveEntityWithHeading(p_70612_1_,p_70612_2_);
|
||||||
if(heightOffGround >= this.ai.flyHeightLimit && this.ai.hasFlyLimit){
|
return;
|
||||||
this.motionY *= 0.8D;
|
|
||||||
this.velocityChanged = true;
|
|
||||||
} else {
|
|
||||||
this.motionY *= this.ai.flyGravity;
|
|
||||||
this.velocityChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double d3 = this.motionY;
|
||||||
|
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
||||||
|
this.motionY = d3;
|
||||||
|
|
||||||
|
this.fallDistance = 0.0F;
|
||||||
|
this.velocityChanged = true;
|
||||||
|
|
||||||
|
if(this.getNavigator().noPath())
|
||||||
|
this.motionY = 0.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnLadder(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,20 +40,7 @@ import net.minecraft.world.WorldServer;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.event.ServerChatEvent;
|
import net.minecraftforge.event.ServerChatEvent;
|
||||||
import noppes.npcs.CustomItems;
|
import noppes.npcs.*;
|
||||||
import noppes.npcs.CustomNpcs;
|
|
||||||
import noppes.npcs.DataAI;
|
|
||||||
import noppes.npcs.DataAdvanced;
|
|
||||||
import noppes.npcs.DataDisplay;
|
|
||||||
import noppes.npcs.DataInventory;
|
|
||||||
import noppes.npcs.DataScript;
|
|
||||||
import noppes.npcs.DataStats;
|
|
||||||
import noppes.npcs.IChatMessages;
|
|
||||||
import noppes.npcs.NBTTags;
|
|
||||||
import noppes.npcs.NoppesUtilServer;
|
|
||||||
import noppes.npcs.NpcDamageSource;
|
|
||||||
import noppes.npcs.Server;
|
|
||||||
import noppes.npcs.VersionCompatibility;
|
|
||||||
import noppes.npcs.ai.*;
|
import noppes.npcs.ai.*;
|
||||||
import noppes.npcs.ai.EntityAIMoveIndoors;
|
import noppes.npcs.ai.EntityAIMoveIndoors;
|
||||||
import noppes.npcs.ai.EntityAIPanic;
|
import noppes.npcs.ai.EntityAIPanic;
|
||||||
@@ -153,7 +140,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
public boolean updateClient = false;
|
public boolean updateClient = false;
|
||||||
public boolean updateAI = false;
|
public boolean updateAI = false;
|
||||||
|
|
||||||
// Fly Change
|
|
||||||
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
||||||
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
||||||
|
|
||||||
@@ -233,8 +219,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
@Override
|
@Override
|
||||||
public void onUpdate(){
|
public void onUpdate(){
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
if(this.ticksExisted % 10 == 0)
|
if(this.ticksExisted % 10 == 0) {
|
||||||
script.callScript(EnumScriptType.TICK);
|
EventHooks.onNPCUpdate(this);
|
||||||
|
}
|
||||||
this.timers.update();
|
this.timers.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,6 +230,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
script.setWorld(world);
|
script.setWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxSafePointTries()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attackEntityAsMob(Entity par1Entity){
|
public boolean attackEntityAsMob(Entity par1Entity){
|
||||||
float f = stats.getAttackStrength();
|
float f = stats.getAttackStrength();
|
||||||
@@ -252,7 +244,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
if(par1Entity instanceof EntityLivingBase){
|
if(par1Entity instanceof EntityLivingBase){
|
||||||
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
|
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
|
||||||
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", par1Entity))
|
if(EventHooks.onNPCMeleeAttack(this, f, (EntityLivingBase)par1Entity))
|
||||||
return false;
|
return false;
|
||||||
f = event.getDamage();
|
f = event.getDamage();
|
||||||
}
|
}
|
||||||
@@ -393,8 +385,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(script.callScript(EnumScriptType.INTERACT, "player", player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player))
|
if(EventHooks.onNPCInteract(this, player) || isAttacking() || isKilled() || faction.isAggressiveToPlayer(player))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
addInteract(player);
|
addInteract(player);
|
||||||
@@ -406,7 +398,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||||
}
|
}
|
||||||
else if (dialog != null){
|
else if (dialog != null){
|
||||||
NoppesUtilServer.openDialog(player, this, dialog);
|
NoppesUtilServer.openDialog(player, this, dialog, 0);
|
||||||
}
|
}
|
||||||
else if(roleInterface != null)
|
else if(roleInterface != null)
|
||||||
roleInterface.interact(player);
|
roleInterface.interact(player);
|
||||||
@@ -510,7 +502,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
|
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
|
||||||
return false;
|
return false;
|
||||||
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
|
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
|
||||||
if(script.callScript(EnumScriptType.DAMAGED, "event", result) || isKilled())
|
if(EventHooks.onNPCDamaged(this, attackingEntity, i, damagesource, result) || isKilled())
|
||||||
return false;
|
return false;
|
||||||
i = result.getDamage();
|
i = result.getDamage();
|
||||||
|
|
||||||
@@ -560,7 +552,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return;
|
return;
|
||||||
if(getAttackTarget() != entity && entity != null){
|
if(getAttackTarget() != entity && entity != null){
|
||||||
ScriptEventTarget event = new ScriptEventTarget(entity);
|
ScriptEventTarget event = new ScriptEventTarget(entity);
|
||||||
if(script.callScript(EnumScriptType.TARGET, "event", event))
|
if(EventHooks.onNPCTarget(this,entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(event.getTarget() == null)
|
if(event.getTarget() == null)
|
||||||
@@ -585,7 +577,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
|
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
|
||||||
if(script.callScript(EnumScriptType.ATTACK, "event", event, "target", entity))
|
if(EventHooks.onNPCRangedAttack(this, f, (EntityLivingBase)entity))
|
||||||
return;
|
return;
|
||||||
for(int i = 0; i < this.stats.shotCount; i++)
|
for(int i = 0; i < this.stats.shotCount; i++)
|
||||||
{
|
{
|
||||||
@@ -914,7 +906,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saySurrounding(Line line) {
|
public void saySurrounding(Line line) {
|
||||||
if (line == null || line.text == null)
|
if (line == null || line.text == null || getFakePlayer() == null)
|
||||||
return;
|
return;
|
||||||
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
|
ServerChatEvent event = new ServerChatEvent(getFakePlayer(), line.text, new ChatComponentTranslation(line.text.replace("%", "%%")));
|
||||||
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
|
if (MinecraftForge.EVENT_BUS.post(event) || event.component == null){
|
||||||
@@ -1067,8 +1059,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
if(jobInterface != null)
|
if(jobInterface != null)
|
||||||
jobInterface.reset();
|
jobInterface.reset();
|
||||||
|
|
||||||
script.callScript(EnumScriptType.INIT);
|
EventHooks.onNPCInit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCollide() {
|
public void onCollide() {
|
||||||
@@ -1090,8 +1082,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i){
|
for (int i = 0; i < list.size(); ++i){
|
||||||
Entity entity = (Entity)list.get(i);
|
Entity entity = (Entity)list.get(i);
|
||||||
if (entity.isEntityAlive())
|
if (entity.isEntityAlive()) {
|
||||||
script.callScript(EnumScriptType.COLLIDE, "entity", entity);
|
EventHooks.onNPCCollide(this,entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1218,7 +1211,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
attackingEntity = ((EntityThrowable) entity).getThrower();
|
attackingEntity = ((EntityThrowable) entity).getThrower();
|
||||||
|
|
||||||
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
|
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
|
||||||
if(script.callScript(EnumScriptType.KILLED, "event", result))
|
if(EventHooks.onNPCKilled(this,damagesource,attackingEntity,result))
|
||||||
return;
|
return;
|
||||||
if(!isRemote()){
|
if(!isRemote()){
|
||||||
if(this.recentlyHit > 0)
|
if(this.recentlyHit > 0)
|
||||||
@@ -1293,7 +1286,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIcon getItemIcon(ItemStack par1ItemStack, int par2){
|
public IIcon getItemIcon(ItemStack par1ItemStack, int par2){
|
||||||
// Change Here
|
|
||||||
if (par1ItemStack.getItem() instanceof ItemBow){
|
if (par1ItemStack.getItem() instanceof ItemBow){
|
||||||
return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
|
return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
|
||||||
}
|
}
|
||||||
@@ -1812,4 +1804,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
|||||||
{
|
{
|
||||||
this.display.modelType = val;
|
this.display.modelType = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateLeashedState(){}
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,42 @@ public class DataTimers implements ITimers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ticks(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTicks(int id, int ticks){
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||||
|
if(ticks < 0)
|
||||||
|
ticks = 0;
|
||||||
|
if(ticks > timer.timerTicks)
|
||||||
|
ticks = timer.timerTicks;
|
||||||
|
|
||||||
|
timer.ticks = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int maxTicks(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).timerTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxTicks(int id, int maxTicks){
|
||||||
|
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||||
|
if(maxTicks < 0)
|
||||||
|
maxTicks = 0;
|
||||||
|
if(timer.ticks > maxTicks)
|
||||||
|
timer.ticks = maxTicks;
|
||||||
|
|
||||||
|
timer.timerTicks = maxTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean repeats(int id){
|
||||||
|
return this.timers.get(Integer.valueOf(id)).repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepeats(int id, boolean repeat){
|
||||||
|
this.timers.get(Integer.valueOf(id)).repeat = repeat;
|
||||||
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
public void writeToNBT(NBTTagCompound compound) {
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
Iterator var3 = this.timers.values().iterator();
|
Iterator var3 = this.timers.values().iterator();
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ import noppes.npcs.scripted.handler.data.IQuestObjective;
|
|||||||
public class QuestKill extends QuestInterface implements IQuestKill {
|
public class QuestKill extends QuestInterface implements IQuestKill {
|
||||||
public HashMap<String,Integer> targets = new HashMap<String,Integer>();
|
public HashMap<String,Integer> targets = new HashMap<String,Integer>();
|
||||||
public int targetType = 0;
|
public int targetType = 0;
|
||||||
|
public String customTargetType = "noppes.npcs.entity.EntityCustomNpc";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||||
compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets));
|
compound.setTag("QuestKills", NBTTags.nbtStringIntegerMap(targets));
|
||||||
//compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets));
|
//compound.setTag("QuestDialogs", NBTTags.nbtStringIntegerMap(targets));
|
||||||
compound.setInteger("TargetType",targetType);
|
compound.setInteger("TargetType",targetType);
|
||||||
|
compound.setString("CustomTargetType",customTargetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,6 +42,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
|||||||
|
|
||||||
//targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
|
//targets = NBTTags.getStringIntegerMap(compound.getTagList("QuestDialogs", 10));
|
||||||
targetType = compound.getInteger("TargetType");
|
targetType = compound.getInteger("TargetType");
|
||||||
|
customTargetType = compound.getString("CustomTargetType");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +51,20 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
|||||||
QuestData data = playerdata.activeQuests.get(questId);
|
QuestData data = playerdata.activeQuests.get(questId);
|
||||||
if(data == null)
|
if(data == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HashMap<String,Integer> killed = getKilled(data);
|
HashMap<String,Integer> killed = getKilled(data);
|
||||||
|
int completed = 0;
|
||||||
|
for(String entityName : targets.keySet()){
|
||||||
|
int amount = 0;
|
||||||
|
if(killed.containsKey(entityName))
|
||||||
|
amount = killed.get(entityName);
|
||||||
|
if(amount >= targets.get(entityName)){
|
||||||
|
completed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(completed >= targets.keySet().size())
|
||||||
|
return true;
|
||||||
|
|
||||||
if(killed.size() != targets.size())
|
if(killed.size() != targets.size())
|
||||||
return false;
|
return false;
|
||||||
for(String entity : killed.keySet()){
|
for(String entity : killed.keySet()){
|
||||||
@@ -106,8 +122,8 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
|||||||
public void setTargetType(int type) {
|
public void setTargetType(int type) {
|
||||||
if(type < 0)
|
if(type < 0)
|
||||||
type = 0;
|
type = 0;
|
||||||
if(type > 1)
|
if(type > 2)
|
||||||
type = 1;
|
type = 2;
|
||||||
|
|
||||||
this.targetType = type;
|
this.targetType = type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,35 @@ public class ScriptEntityParticle {
|
|||||||
private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
|
private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
|
||||||
private int scaleRateStart = 0, alphaRateStart = 0;
|
private int scaleRateStart = 0, alphaRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationX1 = 0;
|
||||||
|
public float rotationX2 = 0;
|
||||||
|
public float rotationXRate = 0.0F;
|
||||||
|
public int rotationXRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationY1 = 0;
|
||||||
|
public float rotationY2 = 0;
|
||||||
|
public float rotationYRate = 0.0F;
|
||||||
|
public int rotationYRateStart = 0;
|
||||||
|
|
||||||
|
public float rotationZ1 = 0;
|
||||||
|
public float rotationZ2 = 0;
|
||||||
|
public float rotationZRate = 0.0F;
|
||||||
|
public int rotationZRateStart = 0;
|
||||||
|
|
||||||
public ScriptEntityParticle(String directory){
|
public ScriptEntityParticle(String directory){
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnOnEntity(ScriptEntity entity){
|
public void spawnOnEntity(ScriptEntity entity){
|
||||||
int entityID = entity.getMCEntity().getEntityId();
|
int entityID = entity.getMCEntity().getEntityId();
|
||||||
NoppesUtilServer.spawnScriptedParticle(entity.getMCEntity(), directory, HEXcolor, amount, maxAge,
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,11 +70,9 @@ public class ScriptEntityParticle {
|
|||||||
public double getX() {
|
public double getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
@@ -64,50 +80,56 @@ public class ScriptEntityParticle {
|
|||||||
public double getMotionX() {
|
public double getMotionX() {
|
||||||
return motionX;
|
return motionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMotionY() {
|
public double getMotionY() {
|
||||||
return motionY;
|
return motionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMotionZ() {
|
public double getMotionZ() {
|
||||||
return motionZ;
|
return motionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getGravity() {
|
public float getGravity() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getScale1() {
|
|
||||||
return scale1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScale2() {
|
|
||||||
return scale2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getScaleRate() {
|
|
||||||
return scaleRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAlpha1() {
|
public float getAlpha1() {
|
||||||
return alpha1;
|
return alpha1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAlpha2() {
|
public float getAlpha2() {
|
||||||
return alpha2;
|
return alpha2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAlphaRate() {
|
public float getAlphaRate() {
|
||||||
return alphaRate;
|
return alphaRate;
|
||||||
}
|
}
|
||||||
|
public int getAlphaRateStart() {
|
||||||
|
return alphaRateStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getScale1() {
|
||||||
|
return scale1;
|
||||||
|
}
|
||||||
|
public float getScale2() {
|
||||||
|
return scale2;
|
||||||
|
}
|
||||||
|
public float getScaleRate() {
|
||||||
|
return scaleRate;
|
||||||
|
}
|
||||||
public int getScaleRateStart() {
|
public int getScaleRateStart() {
|
||||||
return scaleRateStart;
|
return scaleRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAlphaRateStart() {
|
public float getRotationX1() {return rotationX1;}
|
||||||
return alphaRateStart;
|
public float getRotationX2() {return rotationX2;}
|
||||||
}
|
public float getRotationXRate() {return rotationXRate;}
|
||||||
|
public int getRotationXRateStart() {return rotationXRateStart;}
|
||||||
|
|
||||||
|
public float getRotationY1() {return rotationY1;}
|
||||||
|
public float getRotationY2() {return rotationY2;}
|
||||||
|
public float getRotationYRate() {return rotationYRate;}
|
||||||
|
public int getRotationYRateStart() {return rotationYRateStart;}
|
||||||
|
|
||||||
|
public float getRotationZ1() {return rotationZ1;}
|
||||||
|
public float getRotationZ2() {return rotationZ2;}
|
||||||
|
public float getRotationZRate() {return rotationZRate;}
|
||||||
|
public int getRotationZRateStart() {return rotationZRateStart;}
|
||||||
|
|
||||||
public void setDirectory(String directory) {
|
public void setDirectory(String directory) {
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
@@ -130,15 +152,12 @@ public class ScriptEntityParticle {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setX(double x) {
|
public void setX(double x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setY(double y) {
|
public void setY(double y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZ(double z) {
|
public void setZ(double z) {
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
@@ -149,19 +168,15 @@ public class ScriptEntityParticle {
|
|||||||
this.motionZ = motionZ;
|
this.motionZ = motionZ;
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionX(double motionX) {
|
public void setMotionX(double motionX) {
|
||||||
this.motionX = motionX;
|
this.motionX = motionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionY(double motionY) {
|
public void setMotionY(double motionY) {
|
||||||
this.motionY = motionY;
|
this.motionY = motionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotionZ(double motionZ) {
|
public void setMotionZ(double motionZ) {
|
||||||
this.motionZ = motionZ;
|
this.motionZ = motionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGravity(float gravity) {
|
public void setGravity(float gravity) {
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
}
|
}
|
||||||
@@ -172,19 +187,15 @@ public class ScriptEntityParticle {
|
|||||||
this.scaleRate = scaleRate;
|
this.scaleRate = scaleRate;
|
||||||
this.scaleRateStart = scaleRateStart;
|
this.scaleRateStart = scaleRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale1(float scale1) {
|
public void setScale1(float scale1) {
|
||||||
this.scale1 = scale1;
|
this.scale1 = scale1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale2(float scale2) {
|
public void setScale2(float scale2) {
|
||||||
this.scale2 = scale2;
|
this.scale2 = scale2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScaleRate(float scaleRate) {
|
public void setScaleRate(float scaleRate) {
|
||||||
this.scaleRate = scaleRate;
|
this.scaleRate = scaleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScaleRateStart(int scaleRateStart) {
|
public void setScaleRateStart(int scaleRateStart) {
|
||||||
this.scaleRateStart = scaleRateStart;
|
this.scaleRateStart = scaleRateStart;
|
||||||
}
|
}
|
||||||
@@ -195,20 +206,49 @@ public class ScriptEntityParticle {
|
|||||||
this.alphaRate = alphaRate;
|
this.alphaRate = alphaRate;
|
||||||
this.alphaRateStart = alphaRateStart;
|
this.alphaRateStart = alphaRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlpha1(float alpha1) {
|
public void setAlpha1(float alpha1) {
|
||||||
this.alpha1 = alpha1;
|
this.alpha1 = alpha1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlpha2(float alpha2) {
|
public void setAlpha2(float alpha2) {
|
||||||
this.alpha2 = alpha2;
|
this.alpha2 = alpha2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlphaRate(float alphaRate) {
|
public void setAlphaRate(float alphaRate) {
|
||||||
this.alphaRate = alphaRate;
|
this.alphaRate = alphaRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlphaRateStart(int alphaRateStart) {
|
public void setAlphaRateStart(int alphaRateStart) {
|
||||||
this.alphaRateStart = alphaRateStart;
|
this.alphaRateStart = alphaRateStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){
|
||||||
|
this.rotationX1 = rotationX1;
|
||||||
|
this.rotationX2 = rotationX2;
|
||||||
|
this.rotationXRate = rotationXRate;
|
||||||
|
this.rotationXRateStart = rotationXRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationX1(float rotationX1) {this.rotationX1 = rotationX1;}
|
||||||
|
public void setRotationX2(float rotationX2) {this.rotationX2 = rotationX2;}
|
||||||
|
public void setRotationXRate(float rotationXRate) {this.rotationXRate = rotationXRate;}
|
||||||
|
public void setRotationXRateStart(int rotationXRateStart) {this.rotationXRateStart = rotationXRateStart;}
|
||||||
|
|
||||||
|
public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){
|
||||||
|
this.rotationY1 = rotationY1;
|
||||||
|
this.rotationY2 = rotationY2;
|
||||||
|
this.rotationYRate = rotationYRate;
|
||||||
|
this.rotationYRateStart = rotationYRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationY1(float rotationY1) {this.rotationY1 = rotationY1;}
|
||||||
|
public void setRotationY2(float rotationY2) {this.rotationY2 = rotationY2;}
|
||||||
|
public void setRotationYRate(float rotationYRate) {this.rotationYRate = rotationYRate;}
|
||||||
|
public void setRotationYRateStart(int rotationYRateStart) {this.rotationYRateStart = rotationYRateStart;}
|
||||||
|
|
||||||
|
public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){
|
||||||
|
this.rotationZ1 = rotationZ1;
|
||||||
|
this.rotationZ2 = rotationZ2;
|
||||||
|
this.rotationZRate = rotationZRate;
|
||||||
|
this.rotationZRateStart = rotationZRateStart;
|
||||||
|
}
|
||||||
|
public void setRotationZ1(float rotationZ1) {this.rotationZ1 = rotationZ1;}
|
||||||
|
public void setRotationZ2(float rotationZ2) {this.rotationZ2 = rotationZ2;}
|
||||||
|
public void setRotationZRate(float rotationZRate) {this.rotationZRate = rotationZRate;}
|
||||||
|
public void setRotationZRateStart(int rotationZRateStart) {this.rotationZRateStart = rotationZRateStart;}
|
||||||
}
|
}
|
||||||
@@ -224,23 +224,33 @@ public class ScriptItemStack implements IItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String[] getLore() {
|
public String[] getLore() {
|
||||||
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
if (this.item.getTagCompound() != null) {
|
||||||
if (compound != null && compound.func_150299_b("Lore") == 9) {
|
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
||||||
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
if(compound != null && compound.func_150299_b("Lore") == 9) {
|
||||||
if (nbttaglist.tagCount() < 1) {
|
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
||||||
return new String[0];
|
if (nbttaglist.tagCount() > 0) {
|
||||||
} else {
|
List<String> lore = new ArrayList();
|
||||||
List<String> lore = new ArrayList();
|
|
||||||
|
|
||||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||||
lore.add(nbttaglist.getStringTagAt(i));
|
lore.add(nbttaglist.getStringTagAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String[]) ((String[]) lore.toArray(new String[lore.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String[])((String[])lore.toArray(new String[lore.size()]));
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return new String[0];
|
|
||||||
}
|
}
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLore() {
|
||||||
|
if (this.item.getTagCompound() != null) {
|
||||||
|
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
|
||||||
|
if (compound != null && compound.func_150299_b("Lore") == 9) {
|
||||||
|
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
|
||||||
|
return nbttaglist.tagCount() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLore(String[] lore) {
|
public void setLore(String[] lore) {
|
||||||
|
|||||||
@@ -445,6 +445,26 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setForm(byte form){
|
public void setForm(byte form){
|
||||||
|
if(form < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(getRace()){
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
if(form > 3)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
if(form > 15)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if(form > 7)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
||||||
}
|
}
|
||||||
public byte getForm(){
|
public byte getForm(){
|
||||||
|
|||||||
@@ -67,14 +67,101 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
|||||||
double x, double y, double z,
|
double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
|
||||||
) {
|
) {
|
||||||
int entityID = entity.getEntityId();
|
int entityID = entity.getEntityId();
|
||||||
NoppesUtilServer.spawnScriptedParticle(entity, directory, HEXcolor, amount, maxAge,
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
motionX, motionY, motionZ, gravity,
|
motionX, motionY, motionZ, gravity,
|
||||||
scale1, scale2, scaleRate, scaleRateStart,
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
alpha1, alpha2, alphaRate, alphaRateStart,
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||||
|
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||||
|
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
alpha1, alpha2, alphaRate, alphaRateStart,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
|
float scale1, float scale2, float scaleRate, int scaleRateStart
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
scale1, scale2, scaleRate, scaleRateStart,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z,
|
||||||
|
double motionX, double motionY, double motionZ, float gravity
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
motionX, motionY, motionZ, gravity,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
|
double x, double y, double z
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
x, y, z,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
entityID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge
|
||||||
|
) {
|
||||||
|
int entityID = entity.getEntityId();
|
||||||
|
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||||
|
0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
entityID
|
entityID
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,11 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
|||||||
public T getMCEntity(){
|
public T getMCEntity(){
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T getMinecraftEntity(){
|
||||||
|
return getMCEntity();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the entity swing its hand
|
* Makes the entity swing its hand
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -74,7 +74,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHunger(int hunger){
|
public void setHunger(int hunger){
|
||||||
player.getFoodStats().setFoodLevel(hunger);
|
int prevHunger = this.getHunger();
|
||||||
|
if(hunger < 0)
|
||||||
|
hunger = 0;
|
||||||
|
|
||||||
|
player.getFoodStats().addStats(hunger-prevHunger,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSaturation(){
|
public float getSaturation(){
|
||||||
@@ -82,7 +86,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSaturation(float saturation){
|
public void setSaturation(float saturation){
|
||||||
player.getFoodStats().setFoodSaturationLevel(saturation);
|
float prevSaturation = this.getHunger();
|
||||||
|
if(saturation < 0)
|
||||||
|
saturation = 0;
|
||||||
|
|
||||||
|
player.getFoodStats().addStats(0,saturation-prevSaturation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDimension(){
|
public int getDimension(){
|
||||||
@@ -105,7 +113,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
|||||||
if(dialog == null)
|
if(dialog == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog);
|
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReadDialog(int id){
|
public boolean hasReadDialog(int id){
|
||||||
|
|||||||
@@ -13,4 +13,10 @@ public class CustomNPCsEvent extends Event{
|
|||||||
|
|
||||||
public CustomNPCsEvent() {
|
public CustomNPCsEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean bo){
|
||||||
|
this.setCanceled(bo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled(){return this.isCanceled();}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import noppes.npcs.controllers.Dialog;
|
||||||
import noppes.npcs.scripted.NpcAPI;
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
import noppes.npcs.scripted.interfaces.*;
|
import noppes.npcs.scripted.interfaces.*;
|
||||||
|
|
||||||
@@ -51,6 +52,10 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType(){
|
||||||
|
return damageSource.getMCDamageSource().damageType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RangedLaunchedEvent extends NpcEvent {
|
public static class RangedLaunchedEvent extends NpcEvent {
|
||||||
@@ -58,7 +63,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
public float damage;
|
public float damage;
|
||||||
//public List<IProjectile> projectiles = new ArrayList();
|
//public List<IProjectile> projectiles = new ArrayList();
|
||||||
|
|
||||||
public RangedLaunchedEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||||
super(npc);
|
super(npc);
|
||||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
@@ -70,7 +75,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
public final IEntityLivingBase target;
|
public final IEntityLivingBase target;
|
||||||
public float damage;
|
public float damage;
|
||||||
|
|
||||||
public MeleeAttackEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||||
super(npc);
|
super(npc);
|
||||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
@@ -99,6 +104,10 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
this.type = damagesource.damageType;
|
this.type = damagesource.damageType;
|
||||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType(){
|
||||||
|
return damageSource.getMCDamageSource().damageType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
@@ -111,6 +120,36 @@ public class NpcEvent extends CustomNPCsEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DialogEvent extends NpcEvent {
|
||||||
|
public final IPlayer player;
|
||||||
|
public final int id;
|
||||||
|
public final int optionId;
|
||||||
|
public final Dialog dialog;
|
||||||
|
|
||||||
|
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||||
|
super(npc);
|
||||||
|
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||||
|
this.id = id;
|
||||||
|
this.optionId = optionId;
|
||||||
|
this.dialog = dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DialogClosedEvent extends NpcEvent {
|
||||||
|
public final IPlayer player;
|
||||||
|
public final int id;
|
||||||
|
public final int optionId;
|
||||||
|
public final Dialog dialog;
|
||||||
|
|
||||||
|
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||||
|
super(npc);
|
||||||
|
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||||
|
this.id = id;
|
||||||
|
this.optionId = optionId;
|
||||||
|
this.dialog = dialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class TargetLostEvent extends NpcEvent {
|
public static class TargetLostEvent extends NpcEvent {
|
||||||
public final IEntityLivingBase entity;
|
public final IEntityLivingBase entity;
|
||||||
|
|||||||
@@ -11,4 +11,12 @@ class ScriptEvent{
|
|||||||
public boolean isCancelled(){
|
public boolean isCancelled(){
|
||||||
return isCancelled;
|
return isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCanceled(boolean bo){
|
||||||
|
isCancelled = bo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCanceled(){
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,39 @@
|
|||||||
package noppes.npcs.scripted.event;
|
package noppes.npcs.scripted.event;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import noppes.npcs.controllers.Dialog;
|
||||||
|
import noppes.npcs.scripted.NpcAPI;
|
||||||
|
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||||
|
|
||||||
public class ScriptEventDialog extends ScriptEvent{
|
public class ScriptEventDialog extends ScriptEvent{
|
||||||
|
public EntityPlayer player;
|
||||||
|
public int dialog;
|
||||||
|
public int option;
|
||||||
|
public Dialog dialogObj;
|
||||||
|
|
||||||
|
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
|
||||||
|
this.player = player;
|
||||||
|
this.dialog = dialog;
|
||||||
|
this.option = option;
|
||||||
|
this.dialogObj = dialogObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dialog getDialog() {
|
||||||
|
return dialogObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDialogId() {
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOptionId() {
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package noppes.npcs.scripted.gui;
|
package noppes.npcs.scripted.gui;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import noppes.npcs.client.gui.custom.GuiCustom;
|
|
||||||
import noppes.npcs.scripted.interfaces.ITexturedRect;
|
import noppes.npcs.scripted.interfaces.ITexturedRect;
|
||||||
|
|
||||||
public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect {
|
public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect {
|
||||||
|
|||||||
@@ -34,12 +34,36 @@ public interface IEntity<T extends Entity> {
|
|||||||
* @param alpha2 The particle's ending transparency
|
* @param alpha2 The particle's ending transparency
|
||||||
* @param scaleRate Multiplier for the particle's transparency growth rate
|
* @param scaleRate Multiplier for the particle's transparency growth rate
|
||||||
* @param alphaRateStart The time at which the particle begins appearing/fading
|
* @param alphaRateStart The time at which the particle begins appearing/fading
|
||||||
|
*
|
||||||
|
* @param rotation1 The particle's starting rotation angle with respect to the player's vision
|
||||||
|
* @param rotation2 The particle's final rotation angle with respect to the player's vision
|
||||||
|
* @param rotationRate The rate at which the particle rotates with respect to the player's vision
|
||||||
|
* @param rotationRateStart The time at which the particle begins rotating
|
||||||
|
|
||||||
|
* @param rotationX1 The particle's starting rotation angle with respect to the X-axis
|
||||||
|
* @param rotationX2 The particle's final rotation angle with respect to the X-axis
|
||||||
|
* @param rotationXRate The rate at which the particle rotates with respect to the X-axis
|
||||||
|
* @param rotationXRateStart The time at which the particle begins rotating over the X-axis
|
||||||
|
|
||||||
|
* @param rotationY1 The particle's starting rotation angle with respect to the Y-axis
|
||||||
|
* @param rotationY2 The particle's final rotation angle with respect to the Y-axis
|
||||||
|
* @param rotationYRate The rate at which the particle rotates with respect to the Y-axis
|
||||||
|
* @param rotationYRateStart The time at which the particle begins rotating over the Y-axis
|
||||||
|
|
||||||
|
* @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis
|
||||||
|
* @param rotationZ2 The particle's final rotation angle with respect to the Z-axis
|
||||||
|
* @param rotationZRate The rate at which the particle rotates with respect to the Z-axis
|
||||||
|
* @param rotationZRateStart The time at which the particle begins rotating over the Z-axis
|
||||||
*/
|
*/
|
||||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||||
double x, double y, double z,
|
double x, double y, double z,
|
||||||
double motionX, double motionY, double motionZ, float gravity,
|
double motionX, double motionY, double motionZ, float gravity,
|
||||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||||
|
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
|
||||||
|
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||||
|
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||||
|
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
|
||||||
);
|
);
|
||||||
|
|
||||||
public double getYOffset();
|
public double getYOffset();
|
||||||
|
|||||||
@@ -18,5 +18,17 @@ public interface ITimers {
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
int ticks(int id);
|
||||||
|
|
||||||
|
void setTicks(int id, int ticks);
|
||||||
|
|
||||||
|
int maxTicks(int id);
|
||||||
|
|
||||||
|
void setMaxTicks(int id, int maxTicks);
|
||||||
|
|
||||||
|
boolean repeats(int id);
|
||||||
|
|
||||||
|
void setRepeats(int id, boolean repeat);
|
||||||
|
|
||||||
int size();
|
int size();
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ remote.freeze=NPCs einfrieren
|
|||||||
|
|
||||||
spawner.entities=Unternehmen
|
spawner.entities=Unternehmen
|
||||||
spawner.clones=Klone
|
spawner.clones=Klone
|
||||||
spawner.mobspawner=MobSpawner
|
spawner.mobspawner=Spawner
|
||||||
spawner.mount=Geritten von...
|
spawner.mount=Geritten von...
|
||||||
spawner.mountplayer=Geritten von selbst
|
spawner.mountplayer=Geritten von selbst
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ spawner.clones=Clones
|
|||||||
spawner.clones2=Clones 2
|
spawner.clones2=Clones 2
|
||||||
spawner.clones3=Clones 3
|
spawner.clones3=Clones 3
|
||||||
spawner.clones4=Clones 4
|
spawner.clones4=Clones 4
|
||||||
spawner.mobspawner=MobSpawner
|
spawner.mobspawner=Spawner
|
||||||
spawner.mount=Mount by
|
spawner.mount=Mount by
|
||||||
spawner.mountplayer=Player mounts
|
spawner.mountplayer=Player mounts
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ remote.freeze=Geler Pnj
|
|||||||
|
|
||||||
spawner.entities=Entités
|
spawner.entities=Entités
|
||||||
spawner.clones=Clones
|
spawner.clones=Clones
|
||||||
spawner.mobspawner=MobSpawner
|
spawner.mobspawner=Spawner
|
||||||
|
|
||||||
display.model=Modèle
|
display.model=Modèle
|
||||||
display.show=Montrer
|
display.show=Montrer
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ remote.freeze=NPC-lefagyasztása
|
|||||||
|
|
||||||
spawner.entities=Entitások
|
spawner.entities=Entitások
|
||||||
spawner.clones=Klónok
|
spawner.clones=Klónok
|
||||||
spawner.mobspawner=MobSpawner
|
spawner.mobspawner=Spawner
|
||||||
|
|
||||||
display.model=Model
|
display.model=Model
|
||||||
display.show=Mutat
|
display.show=Mutat
|
||||||
|
|||||||
|
After Width: | Height: | Size: 669 B |
|
After Width: | Height: | Size: 593 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1016 B |
|
After Width: | Height: | Size: 574 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 597 B |
|
After Width: | Height: | Size: 797 B |
|
After Width: | Height: | Size: 803 B |
|
After Width: | Height: | Size: 919 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 589 B |
|
After Width: | Height: | Size: 621 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 641 B |
|
After Width: | Height: | Size: 612 B |
|
After Width: | Height: | Size: 601 B |
|
After Width: | Height: | Size: 769 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 634 B |
|
After Width: | Height: | Size: 832 B |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 994 B |
|
After Width: | Height: | Size: 943 B |
|
After Width: | Height: | Size: 700 B |