Compare commits

...
36 Commits
Author SHA1 Message Date
KAMKEEL 36992c5abd Added Awen Capes 2022-04-20 18:04:48 -04:00
Kamron Vaswani 09f2e19c88 Merge pull request #48 from KAMKEEL/dev
Dev
2022-04-20 17:56:29 -04:00
KAMKEEL a53baefafa Merge branch 'dev' of https://github.com/KAMKEEL/CustomNPC-Plus into dev 2022-04-20 17:50:18 -04:00
KAMKEEL d6cd41946c Remove ZSTD Compression 2022-04-20 17:49:20 -04:00
Kamron Vaswani 1e088323e9 Merge pull request #47 from KAMKEEL/revert-44-dev
Revert "Remove redundant files and make support for specific OS for zstd compression"
2022-04-20 17:24:01 -04:00
Kamron Vaswani b90406ddd6 Revert "Remove redundant files and make support for specific OS for zstd compression" 2022-04-20 17:23:45 -04:00
Kamron Vaswani 0ed0893682 Merge pull request #46 from c0508383/master
Scripted Dialog Hook Fix
2022-04-20 17:23:24 -04:00
Luis C.M ff37a8bec2 Merge branch 'KAMKEEL:master' into master 2022-04-13 04:27:25 -05:00
Luis C.M 1e88a4458d Fixed bug with NPC dialog scripts. 2022-04-13 04:25:44 -05:00
KAMKEEL a3414d8d75 New Cape Textures - Daybreak 2022-04-12 03:35:42 -04:00
KAMKEEL e72672ad71 Revert to Original 😦 2022-04-11 23:01:41 -04:00
KAMKEEL 77ed924492 Steve32 Fake Framework
Started Creating Steve32 Fake so that 64x64 Textures can be applied to 64x32 Steve
2022-04-09 21:04:09 -04:00
KAMKEEL 628fd1084e Cloak Reorganization Compatibility Update 2022-04-09 02:36:14 -04:00
KAMKEEL 18a86d30e7 Update build.gradle 2022-04-09 02:15:14 -04:00
KAMKEEL 71216350d8 Merge branch 'master' into dev 2022-04-09 02:14:21 -04:00
KAMKEEL 0732d98ff8 1.5.3 Gradle Update | Add Version Compatibility Changes
Update Version to 1.5.3
Remove Useless String Statements / Comments
Add Temporary Fixes to Version Compatibility as permanent fixes
2022-04-09 01:31:21 -04:00
KAMKEEL 5ad6bb094a Merge branch 'master' into dev 2022-04-09 01:22:15 -04:00
KAMKEEL 465f52b811 Update RenderNPCInterface.java 2022-04-09 01:21:40 -04:00
Kamron Vaswani 32f89f8e92 Merge pull request #45 from c0508383/master
Important script hook fix, additions to dialog and dialog closed hooks for NPCs
2022-04-09 01:20:53 -04:00
Luis C.M 65bb3b5939 Important fix to some NPC hook scripts crashing, added option and dialog object fields to local NPC dialog and NPC dialog closed scripts 2022-04-09 00:17:16 -05:00
KAMKEEL 8c677901d0 Reorganized Cape Textures 2022-04-09 01:11:05 -04:00
KAMKEEL dd67f12818 Cape System Overhaul 2022-04-08 03:40:46 -04:00
KAMKEEL e95eb0ee98 Add Texture Pack 2022-04-06 19:00:27 -04:00
Kamron Vaswani ea3669fed8 Merge pull request #44 from luiz-otavio/dev
Remove redundant files and make support for specific OS for zstd compression
2022-04-06 15:08:11 -04:00
luiz-otavio 6294062d23 chore(gradle): make supported OS for zstd compression 2022-04-06 00:32:55 -03:00
KAMKEEL 5aa5fb335c Remove ME 2022-04-05 20:01:27 -04:00
KAMKEEL be44db63d3 Update Alex Arm Item Offset 2022-04-05 19:33:36 -04:00
KAMKEEL 993e7a9d7c LOTR Capes! 2022-04-05 17:56:05 -04:00
KAMKEEL ebc0b96582 Code Cleanup for Bow Fix 2022-04-05 17:55:13 -04:00
Kamron Vaswani 6101e75306 Merge pull request #43 from c0508383/master
Bow & Solid Legwear Fixes
2022-04-05 17:51:03 -04:00
Luis C.M 4abe8dca92 Merge remote-tracking branch 'origin/master' 2022-04-05 16:48:37 -05:00
Luis C.M 8749ba0280 Fixed bow rendering for mods with custom bow renderers 2022-04-05 16:48:27 -05:00
Luis C.M 6a0af3b0a0 Fixed solid legwear right & left sides being flipped 2022-04-05 16:10:58 -05:00
Kamron Vaswani f59b5d1e87 Merge pull request #42 from c0508383/master
Solid Steve armwear fix
2022-04-05 04:01:54 -04:00
Luis C.M cddada1984 Merge branch 'KAMKEEL:master' into master 2022-04-03 19:14:46 -05:00
Luis C.M 917f0d030a Fixed solid Steve armwear 2022-04-03 19:14:19 -05:00
199 changed files with 414 additions and 731 deletions

No files matched your search

Binary file not shown.
+17 -35
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.5.2" version = "1.6-beta"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus" archivesBaseName = "CustomNPC-Plus"
@@ -29,17 +29,12 @@ minecraft {
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
configurations {
shade
compile.extendsFrom shade
}
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..
//compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version" //compile "some.group:artifact:version"
// real examples // real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
@@ -47,39 +42,26 @@ dependencies {
// for more info... // for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
shade 'com.github.luben:zstd-jni:1.5.2-2'
} }
processResources processResources
{ {
// this will ensure that this task is redone when the versions change. // this will ensure that this task is redone when the versions change.
inputs.property "version", project.version inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else // replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info' include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
tasks.withType(JavaCompile) { // replace version and mcversion
options.encoding = 'UTF-8' expand 'version':project.version, 'mcversion':project.minecraft.version
} }
jar { // copy everything else, thats not the mcmod.info
configurations.shade.each { dep -> from(sourceSets.main.resources.srcDirs) {
from(project.zipTree(dep)) { exclude 'mcmod.info'
exclude 'META-INF', 'META-INF/**' }
} }
}
}
sourceSets {main { output.resourcesDir = output.classesDir }} sourceSets {main { output.resourcesDir = output.classesDir }}
@@ -1,187 +0,0 @@
package foxz.command;
import foxz.commandhelper.ChMcLogger;
import foxz.commandhelper.annotations.Command;
import foxz.commandhelper.annotations.SubCommand;
import foxz.commandhelper.permissions.OpOnly;
import me.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 me.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);
}
}
+1 -1
View File
@@ -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);
} }
} }
+1 -1
View File
@@ -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, CmdCompressor.class} sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
) )
public class CmdNoppes extends ChMcLogger { public class CmdNoppes extends ChMcLogger {
@@ -1,61 +0,0 @@
package me.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();
}
}
}
@@ -1,16 +0,0 @@
package me.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 -16
View File
@@ -10,7 +10,6 @@ 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 me.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;
@@ -31,9 +30,8 @@ import noppes.npcs.entity.old.*;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executors;
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.5.2") @Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6-beta")
public class CustomNpcs { public class CustomNpcs {
@ConfigProp(info = "Disable Chat Bubbles") @ConfigProp(info = "Disable Chat Bubbles")
@@ -41,12 +39,6 @@ public class CustomNpcs {
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") @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; public static boolean ScriptingEnabled = true;
@@ -217,13 +209,6 @@ 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);
+14 -7
View File
@@ -56,6 +56,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT);
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
@@ -69,13 +70,16 @@ public class EventHooks {
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int id, Dialog dialog) { public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null) if(npc == null || npc.wrappedNPC == null)
return; return;
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, id, dialog); NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id);
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
@@ -85,7 +89,10 @@ public class EventHooks {
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
} }
@@ -106,7 +113,7 @@ public class EventHooks {
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target); NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", event, "target", target); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
return result; return result;
} }
@@ -117,7 +124,7 @@ public class EventHooks {
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target); NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", event, "target", target); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
return result; return result;
} }
@@ -138,7 +145,7 @@ public class EventHooks {
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target); NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", event); boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
WrapperNpcAPI.EVENT_BUS.post(event); WrapperNpcAPI.EVENT_BUS.post(event);
return result; return result;
} }
@@ -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;
} }
@@ -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);
EventHooks.onNPCDialog(npc, player, dialog.id, dialog); 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);
@@ -12,11 +12,32 @@ import noppes.npcs.controllers.Lines;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
public class VersionCompatibility { public class VersionCompatibility {
public static int ModRev = 16; public static int ModRev = 18;
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev) if(npc.npcVersion == ModRev)
return; return;
if(npc.npcVersion < 18){
// Fix 64-Texture (Reorganization)
// Fix CloakTexture (Reorganization)
String cloakTexture = compound.getString("CloakTexture");
cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/");
cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/");
cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/");
compound.setString("CloakTexture", cloakTexture);
}
if(npc.npcVersion < 17){
// Fix DialogDarkenScreen
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
// Remove MPM Texture Requirement
String texture = compound.getString("Texture");
texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
compound.setString("Texture", texture);
}
if(npc.npcVersion < 12){ if(npc.npcVersion < 12){
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound())); CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound())); CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
@@ -25,6 +25,7 @@ import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.roles.JobPuppet; import noppes.npcs.roles.JobPuppet;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class ModelMPM extends ModelNPCMale{ public class ModelMPM extends ModelNPCMale{
private ModelPartInterface wings; private ModelPartInterface wings;
@@ -65,13 +66,10 @@ public class ModelMPM extends ModelNPCMale{
public boolean isArmor; public boolean isArmor;
public float alpha = 1; public float alpha = 1;
// Check Legacy Code for Old Version
// Updated False = 64x32 Skin
// Steve 64x64 and Alex 64x64 // Steve 64x64 and Alex 64x64
public ModelMPM(float par1, boolean arms) { public ModelMPM(float par1, boolean alex) {
super(par1, arms); super(par1, alex);
isArmor = par1 > 0; isArmor = par1 > 0;
float par2 = 0; float par2 = 0;
@@ -101,7 +99,7 @@ public class ModelMPM extends ModelNPCMale{
// this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); // this.bipedBodywear.setRotationPoint(0.0F, 0.0F + par2, 0.0F);
// Steve 64x64 Model or Alex 64x64 Model // Steve 64x64 Model or Alex 64x64 Model
if (arms){ if (alex){
// Alex Version // Alex Version
this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16)); this.bipedRightArm = (new ModelScaleRenderer(this, 40, 16));
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1); this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, par1);
@@ -28,10 +28,10 @@ public class ModelNPCMale extends ModelBiped
init(f, 0.0F); init(f, 0.0F);
} }
public ModelNPCMale(float f, boolean arms) public ModelNPCMale(float f, boolean alex)
{ {
super(f, 0.0F, 64, 64); super(f, 0.0F, 64, 64);
init(f, 0.0F, arms); init(f, 0.0F, alex);
} }
@Override @Override
@@ -1,3 +1,5 @@
package noppes.npcs.client.model.part; package noppes.npcs.client.model.part;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
@@ -163,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);
@@ -184,7 +186,7 @@ public class ModelLimbWear extends ModelScaleRenderer {
this.addChild(top); this.addChild(top);
Model2DRenderer bottom = new Model2DRenderer(base, 48, 32, 4, 4, 64, 64); Model2DRenderer bottom = new Model2DRenderer(base, 48, 32, 4, 4, 64, 64);
bottom.setRotationPoint(-4.5f+x, 12.0f+y, -2.545f); bottom.setRotationPoint(-4.5f+x, 12.0f+y, -2.525f);
bottom.setScale(0.32f); bottom.setScale(0.32f);
bottom.setThickness(thick); bottom.setThickness(thick);
setRotation(bottom, (float)(Math.PI / -2), 0, 0); setRotation(bottom, (float)(Math.PI / -2), 0, 0);
@@ -210,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);
@@ -258,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);
@@ -306,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);
@@ -4,6 +4,7 @@ import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@@ -11,7 +12,6 @@ import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -23,8 +23,6 @@ import noppes.npcs.client.model.ModelNPCMale;
import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemClaw;
import noppes.npcs.items.ItemShield;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -36,8 +34,8 @@ public class RenderNPCHumanMale extends RenderNPCInterface
protected ModelNPCMale modelArmor; protected ModelNPCMale modelArmor;
protected final ModelNPCMale originalBipedMain; protected final ModelNPCMale originalBipedMain;
protected final ModelMPM steve = new ModelMPM(0, false); protected final static ModelMPM steve64 = new ModelMPM(0, false);
protected final ModelMPM alex = new ModelMPM(0, true); protected final static ModelMPM alex = new ModelMPM(0, true);
public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor) public RenderNPCHumanMale(ModelNPCMale mainmodel, ModelNPCMale armorChest, ModelNPCMale armor)
{ {
@@ -113,14 +111,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2, public void renderPlayer(EntityNPCInterface npc, double d, double d1, double d2,
float f, float f1) float f, float f1)
{ {
// SEEMS TO WORK FOR NOW. Keeps NPC from outsyncing with Creature Models
if(npc instanceof EntityCustomNpc){ if(npc instanceof EntityCustomNpc){
EntityCustomNpc test = (EntityCustomNpc) npc; EntityCustomNpc test = (EntityCustomNpc) npc;
if(test.modelData.entityClass == null){ if(test.modelData.entityClass == null){
int modelVal = npc.display.modelType; int modelVal = npc.display.modelType;
if(modelVal == 1){ if(modelVal == 1){
this.mainModel = steve; this.mainModel = steve64;
this.modelBipedMain = steve; this.modelBipedMain = steve64;
} }
else if(modelVal == 2){ else if(modelVal == 2){
this.mainModel = alex; this.mainModel = alex;
@@ -177,7 +174,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface
npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture); npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture);
} }
bindTexture((ResourceLocation) npc.textureCloakLocation); bindTexture((ResourceLocation) npc.textureCloakLocation);
//AbstractClientPlayer.func_110307_b(, null);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F); GL11.glTranslatef(0.0F, 0.0F, 0.125F);
double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f); double d = (npc.field_20066_r + (npc.field_20063_u - npc.field_20066_r) * (double)f) - (npc.prevPosX + (npc.posX - npc.prevPosX) * (double)f);
@@ -193,13 +189,12 @@ public class RenderNPCHumanMale extends RenderNPCInterface
f14 = 0.0F; f14 = 0.0F;
} }
float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f; float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f;
//f13 += MathHelper.sin((entityplayer.prevDistanceWalkedModified + (entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified) * f) * 6F) * 32F * f16;
float f13 = 5f; float f13 = 5f;
if (npc.isSneaking()) if (npc.isSneaking())
{ {
f13 += 25F; f13 += 25F;
} }
//System.out.println(entityplayer.prevDistanceWalkedModified);
GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F); GL11.glRotatef(6F + f14 / 2.0F + f13, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F);
@@ -255,7 +250,13 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
} }
this.modelBipedMain.bipedRightArm.postRender(0.0625F); this.modelBipedMain.bipedRightArm.postRender(0.0625F);
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
if(npc.getModelType() == 2){
GL11.glTranslatef(-0.0125F, 0.4375F + y, 0.0625F);
}
else {
GL11.glTranslatef(-0.0625F, 0.4375F + y, 0.0625F);
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D)); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
@@ -269,8 +270,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(-var6, -var6, var6); GL11.glScalef(-var6, -var6, var6);
} }
// CHANGE HERE else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
else if (itemstack2.getItem() instanceof ItemBow)
{ {
var6 = 0.625F; var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -343,8 +343,15 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0); GL11.glTranslatef(x, cnpc.modelData.getBodyY(), 0);
} }
this.modelBipedMain.bipedLeftArm.postRender(0.0625F); this.modelBipedMain.bipedLeftArm.postRender(0.0625F);
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
float var6; if(npc.getModelType() == 2){
GL11.glTranslatef(0.0125F, 0.4375F + y, 0.0625F);
}
else {
GL11.glTranslatef(0.0625F, 0.4375F + y, 0.0625F);
}
float var6;
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack2, EQUIPPED);
boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D)); boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack2, BLOCK_3D));
@@ -362,7 +369,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(var6, -var6, var6); GL11.glScalef(var6, -var6, var6);
} }
else if (itemstack2.getItem() instanceof ItemBow) else if (itemstack2.getItem() instanceof ItemBow && customRenderer == null)
{ {
var6 = 0.625F; var6 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -32,22 +32,22 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
public class RenderNPCInterface extends RenderLiving{ public class RenderNPCInterface extends RenderLiving{
public static long LastTextureTick = 0; public static long LastTextureTick = 0;
public ModelBase originalModel; public ModelBase originalModel;
public RenderNPCInterface(ModelBase model, float f){ public RenderNPCInterface(ModelBase model, float f){
super(model, f); super(model, f);
this.originalModel = model; this.originalModel = model;
} }
protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) { protected void renderName(EntityNPCInterface npc, double d, double d1, double d2) {
if (!this.func_110813_b(npc)) if (!this.func_110813_b(npc))
return; return;
float f2 = npc.getDistanceToEntity(renderManager.livingPlayer); float f2 = npc.getDistanceToEntity(renderManager.livingPlayer);
float f3 = npc.isSneaking() ? 32F : 64F; float f3 = npc.isSneaking() ? 32F : 64F;
if (f2 > f3) if (f2 > f3)
return; return;
if (npc.messages != null){ if (npc.messages != null){
@@ -69,199 +69,201 @@ public class RenderNPCInterface extends RenderLiving{
height = 1; height = 1;
} }
} }
}
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
}
protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
FontRenderer fontrenderer = getFontRendererFromRenderManager();
i = npc.getBrightnessForRender(0);
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
float f1 = (npc.baseHeight / 5f) * npc.display.modelSize;
float f2 = 0.01666667F * f1;
GL11.glPushMatrix();
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
float height = f1 / 6.5f;
for(j = 0; j < obs.length; j += 2){
float scale = (Float) obs[j + 1];
height += f1 / 6.5f * scale;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
String s = obs[j].toString();
GL11.glTranslatef(0, height, 0);
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
tessellator.startDrawingQuads();
int size = fontrenderer.getStringWidth(s) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex(-size - 1, -1, 0.0D);
tessellator.addVertex(-size - 1, 8 , 0.0D);
tessellator.addVertex(size + 1, 8 , 0.0D);
tessellator.addVertex(size + 1, -1 , 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int color = npc.faction.color;
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
protected void renderPlayerScale(EntityNPCInterface npc, float f){
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
}
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
shadowSize = npc.display.modelSize / 10f;
float xOffset = 0;
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
float zOffset = 0;
if(npc.isEntityAlive()){
if(npc.isPlayerSleeping()){
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
yOffset += 0.14f;
}
else if(npc.isRiding()){
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
}
}
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
}
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
xoffset = (xoffset/ 5f) * npc.display.modelSize;
yoffset = (yoffset/ 5f) * npc.display.modelSize;
zoffset = (zoffset/ 5f) * npc.display.modelSize;
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
}
@Override
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.isEntityAlive() && npc.isPlayerSleeping())
{
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
}
else if(npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING){
GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F);
float scale = ((EntityCustomNpc)npc).display.modelSize / 5f;
GL11.glTranslated(-scale +((EntityCustomNpc)npc).modelData.getLegsY() * scale, 0.14f, 0);
GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
}
else {
super.rotateCorpse(npc, f, f1, f2);
}
}
@Override
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
}
@Override
protected void preRenderCallback(EntityLivingBase entityliving, float f){
renderPlayerScale((EntityNPCInterface)entityliving, f);
}
@Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
return;
}
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
BossStatus.setBossStatus(npc, true);
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
}
super.doRender(entityliving, d, d1, d2, f, f1);
} }
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){ public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
EntityNPCInterface npc = (EntityNPCInterface) entityliving; if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
if (!npc.display.glowTexture.isEmpty()) super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
{ }
GL11.glDepthFunc(GL11.GL_LEQUAL);
if(npc.textureGlowLocation == null){
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
}
bindTexture((ResourceLocation) npc.textureGlowLocation);
float f1 = 1.0F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
GL11.glDisable(GL11.GL_LIGHTING);
if (npc.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glScalef(1.001f, 1.001f, 1.001f);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
GL11.glDepthFunc(GL11.GL_LEQUAL); protected void renderLivingLabel(EntityNPCInterface npc, double d, double d1, double d2, int i, Object... obs){
GL11.glDisable(GL11.GL_BLEND); FontRenderer fontrenderer = getFontRendererFromRenderManager();
}
} i = npc.getBrightnessForRender(0);
@Override int j = i % 65536;
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){ int k = i / 65536;
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
if(npc.isKilled() || npc.display.disableLivingAnimation)
return 0; float f1 = (npc.baseHeight / 5f) * npc.display.modelSize;
return super.handleRotationFloat(par1EntityLiving, par2); float f2 = 0.01666667F * f1;
} GL11.glPushMatrix();
GL11.glTranslatef((float)d + 0.0F, (float)d1, (float)d2);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;
float height = f1 / 6.5f;
for(j = 0; j < obs.length; j += 2){
float scale = (Float) obs[j + 1];
height += f1 / 6.5f * scale;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
String s = obs[j].toString();
GL11.glTranslatef(0, height, 0);
GL11.glScalef(-f2 * scale, -f2 * scale, f2 * scale);
tessellator.startDrawingQuads();
int size = fontrenderer.getStringWidth(s) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex(-size - 1, -1, 0.0D);
tessellator.addVertex(-size - 1, 8 , 0.0D);
tessellator.addVertex(size + 1, 8 , 0.0D);
tessellator.addVertex(size + 1, -1 , 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int color = npc.faction.color;
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, color);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING /*GL_LIGHTING*/);
GL11.glDisable(GL11.GL_BLEND /*GL_BLEND*/);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
protected void renderPlayerScale(EntityNPCInterface npc, float f){
GL11.glScalef((npc.scaleX / 5) * npc.display.modelSize, (npc.scaleY / 5) * npc.display.modelSize, (npc.scaleZ / 5) * npc.display.modelSize);
}
protected void renderPlayerSleep(EntityNPCInterface npc, double d, double d1, double d2){
shadowSize = npc.display.modelSize / 10f;
float xOffset = 0;
float yOffset = npc.currentAnimation == EnumAnimation.NONE?npc.ai.bodyOffsetY / 10 - 0.5f:0;
float zOffset = 0;
if(npc.isEntityAlive()){
if(npc.isPlayerSleeping()){
xOffset = (float) -Math.cos(Math.toRadians(180 - npc.ai.orientation));
zOffset = (float) -Math.sin(Math.toRadians(npc.ai.orientation));
yOffset += 0.14f;
}
else if(npc.isRiding()){
yOffset -= 0.5f - ((EntityCustomNpc)npc).modelData.getLegsY() * 0.8f;
}
}
renderLiving(npc, d, d1, d2, xOffset, yOffset, zOffset);
}
private void renderLiving(EntityNPCInterface npc, double d, double d1, double d2,float xoffset,float yoffset,float zoffset){
xoffset = (xoffset/ 5f) * npc.display.modelSize;
yoffset = (yoffset/ 5f) * npc.display.modelSize;
zoffset = (zoffset/ 5f) * npc.display.modelSize;
super.renderLivingAt(npc, d+xoffset, d1+yoffset, d2 + zoffset);
}
@Override
protected void rotateCorpse(EntityLivingBase entity, float f, float f1, float f2){
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.isEntityAlive() && npc.isPlayerSleeping())
{
GL11.glRotatef(npc.ai.orientation, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(getDeathMaxRotation(npc), 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
}
else if(npc.isEntityAlive() && npc.currentAnimation == EnumAnimation.CRAWLING){
GL11.glRotatef(270.0F - f1, 0.0F, 1.0F, 0.0F);
float scale = ((EntityCustomNpc)npc).display.modelSize / 5f;
GL11.glTranslated(-scale +((EntityCustomNpc)npc).modelData.getLegsY() * scale, 0.14f, 0);
GL11.glRotatef(270F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, 1.0F, 0.0F);
}
else {
super.rotateCorpse(npc, f, f1, f2);
}
}
@Override
protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6){
renderName((EntityNPCInterface)par1EntityLivingBase, par2, par4, par6);
}
@Override
protected void preRenderCallback(EntityLivingBase entityliving, float f){
renderPlayerScale((EntityNPCInterface)entityliving, f);
}
@Override
public void doRender(EntityLiving entityliving, double d, double d1, double d2, float f, float f1){
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if(npc.isKilled() && npc.stats.hideKilledBody && npc.deathTime > 20){
return;
}
if((npc.display.showBossBar == 1 || npc.display.showBossBar == 2 && npc.isAttacking()) && !npc.isKilled() && npc.deathTime <= 20 && npc.canSee(Minecraft.getMinecraft().thePlayer))
BossStatus.setBossStatus(npc, true);
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
}
super.doRender(entityliving, d, d1, d2, f, f1);
}
protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){
super.renderModel(entityliving, par2, par3, par4, par5, par6, par7);
EntityNPCInterface npc = (EntityNPCInterface) entityliving;
if (!npc.display.glowTexture.isEmpty())
{
GL11.glDepthFunc(GL11.GL_LEQUAL);
if(npc.textureGlowLocation == null){
npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture);
}
bindTexture((ResourceLocation) npc.textureGlowLocation);
float f1 = 1.0F;
GL11.glEnable(GL11.GL_BLEND);
// Overlay & Glow
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
GL11.glDisable(GL11.GL_LIGHTING);
if (npc.isInvisible())
{
GL11.glDepthMask(false);
}
else
{
GL11.glDepthMask(true);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glScalef(1.001f, 1.001f, 1.001f);
if(mainModel instanceof ModelMPM){
((ModelMPM)mainModel).isArmor = true;
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
((ModelMPM)mainModel).isArmor = false;
}
else
mainModel.render(entityliving, par2, par3, par4, par5, par6, par7);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_BLEND);
}
}
@Override
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;
if(npc.isKilled() || npc.display.disableLivingAnimation)
return 0;
return super.handleRotationFloat(par1EntityLiving, par2);
}
@Override
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
}
@Override
protected void renderLivingAt(EntityLivingBase entityliving, double d, double d1, double d2){
renderPlayerSleep((EntityNPCInterface)entityliving, d, d1, d2);
}
@Override @Override
public ResourceLocation getEntityTexture(Entity entity) { public ResourceLocation getEntityTexture(Entity entity) {
@@ -276,11 +278,11 @@ public class RenderNPCInterface extends RenderLiving{
return AbstractClientPlayer.locationStevePng; return AbstractClientPlayer.locationStevePng;
} }
else if(npc.display.skinType == 1 && npc.display.playerProfile != null){ else if(npc.display.skinType == 1 && npc.display.playerProfile != null){
Minecraft minecraft = Minecraft.getMinecraft(); Minecraft minecraft = Minecraft.getMinecraft();
Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile);
if (map.containsKey(Type.SKIN)){ if (map.containsKey(Type.SKIN)){
npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN); npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
} }
LastTextureTick = 0; LastTextureTick = 0;
} }
else if(npc.display.skinType == 2 || npc.display.skinType == 3){ else if(npc.display.skinType == 2 || npc.display.skinType == 3){
@@ -291,7 +293,6 @@ public class RenderNPCInterface extends RenderLiving{
for(byte b : hash){ for(byte b : hash){
sb.append(String.format("%02x", b&0xff)); sb.append(String.format("%02x", b&0xff));
} }
// SKIN CHANGE
if(npc.display.skinType == 2){ if(npc.display.skinType == 2){
npc.textureLocation = new ResourceLocation("skins/" + sb.toString()); npc.textureLocation = new ResourceLocation("skins/" + sb.toString());
loadSkin(null, npc.textureLocation, npc.display.url, false); loadSkin(null, npc.textureLocation, npc.display.url, false);
@@ -313,10 +314,10 @@ public class RenderNPCInterface extends RenderLiving{
} }
// 64x64 Skin is True // 64x64 Skin is True
private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){ private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version)); ITextureObject object = new ImageDownloadAlt(file, par1Str, SkinManager.field_152793_a, new ImageBufferDownloadAlt(version));
texturemanager.loadTexture(resource, object); texturemanager.loadTexture(resource, object);
} }
} }
@@ -219,7 +219,6 @@ public class RenderNPCPony extends RenderNPCInterface
float f4 = 0.375F * f; float f4 = 0.375F * f;
GL11.glScalef(f4, -f4, f4); GL11.glScalef(f4, -f4, f4);
} else } else
// CHANGE HERE
if(itemstack.getItem() instanceof ItemBow) if(itemstack.getItem() instanceof ItemBow)
{ {
GL11.glTranslatef(0.0F, 0.125F, 0.3125F); GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
@@ -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);
@@ -4,13 +4,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.common.IExtendedEntityProperties;
import noppes.npcs.CustomNpcs; import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter; import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.DataTimers; import noppes.npcs.entity.data.DataTimers;
@@ -1,27 +1,24 @@
package noppes.npcs.controllers; package noppes.npcs.controllers;
import me.luizotavio.compressor.ZstdCompressor; import java.io.EOFException;
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.*; public class PlayerDataController {
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.Map;
import static me.luizotavio.compressor.executor.IOExecutor.IO_EXECUTOR;
public class PlayerDataController {
public static PlayerDataController instance; public static PlayerDataController instance;
public PlayerDataController(){ public PlayerDataController(){
instance = this; instance = this;
} }
@@ -45,24 +42,24 @@ public class PlayerDataController {
filename = "noplayername"; filename = "noplayername";
filename += ".dat"; filename += ".dat";
try { try {
File file = new File(saveDir, filename); File file = new File(saveDir, filename);
if(file.exists()){ if(file.exists()){
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file)); NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
file.delete(); file.delete();
file = new File(saveDir, filename+"_old"); file = new File(saveDir, filename+"_old");
if(file.exists()) if(file.exists())
file.delete(); file.delete();
return comp; return comp;
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
try { try {
File file = new File(saveDir, filename+"_old"); File file = new File(saveDir, filename+"_old");
if(file.exists()){ if(file.exists()){
return CompressedStreamTools.readCompressed(new FileInputStream(file)); return CompressedStreamTools.readCompressed(new FileInputStream(file));
} }
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
@@ -73,52 +70,38 @@ 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())
return new NBTTagCompound(); filename = "noplayername";
} filename += ".json";
if(CustomNpcs.CompressorType.equalsIgnoreCase("zstd")) {
filename += ".zstd";
} else {
filename += ".json";
}
try { try {
return ensureCompressor( File file = new File(saveDir, filename);
new File(saveDir, filename) if(file.exists()){
); return NBTJsonUtil.LoadFile(file);
}
} catch (Exception e) { } catch (Exception e) {
LogWriter.error("Error loading: " + filename, e); LogWriter.error("Error loading: " + filename, e);
} }
return new NBTTagCompound(); return new NBTTagCompound();
} }
public void savePlayerData(PlayerData data){ public void savePlayerData(PlayerData data){
NBTTagCompound compound = data.getNBT(); NBTTagCompound compound = data.getNBT();
String filename; String filename = data.uuid + ".json";
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 file = new File(saveDir, filename); File file1 = new File(saveDir, filename);
NBTJsonUtil.SaveFile(file, compound);
if (file.exists()) { if(file1.exists()){
file.delete(); file1.delete();
} }
file.renameTo(file1);
writeCompressor(file, compound);
} catch (Exception e) { } catch (Exception e) {
LogWriter.except(e); LogWriter.except(e);
} }
} }
public PlayerBankData getBankData(EntityPlayer player, int bankId) { public PlayerBankData getBankData(EntityPlayer player, int bankId) {
Bank bank = BankController.getInstance().getBank(bankId); Bank bank = BankController.getInstance().getBank(bankId);
PlayerBankData data = getPlayerData(player).bankData; PlayerBankData data = getPlayerData(player).bankData;
@@ -127,7 +110,7 @@ public class PlayerDataController {
} }
return data; return data;
} }
public PlayerData getPlayerData(EntityPlayer player){ public PlayerData getPlayerData(EntityPlayer player){
PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData"); PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData");
if(data == null){ if(data == null){
@@ -139,14 +122,14 @@ public class PlayerDataController {
return data; return data;
} }
public String hasPlayer(String username) { public String hasPlayer(String username) {
for(String name : getUsernameData().keySet()){ for(String name : getUsernameData().keySet()){
if(name.equalsIgnoreCase(username)) if(name.equalsIgnoreCase(username))
return name; return name;
} }
return ""; return "";
} }
public PlayerData getDataFromUsername(String username){ public PlayerData getDataFromUsername(String username){
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = null; PlayerData data = null;
@@ -162,91 +145,37 @@ public class PlayerDataController {
} }
else else
data = getPlayerData(player); data = getPlayerData(player);
return data; return data;
} }
public void addPlayerMessage(String username, PlayerMail mail) { public void addPlayerMessage(String username, PlayerMail mail) {
mail.time = System.currentTimeMillis(); mail.time = System.currentTimeMillis();
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username); EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
PlayerData data = getDataFromUsername(username); PlayerData data = getDataFromUsername(username);
data.mailData.playermail.add(mail.copy()); data.mailData.playermail.add(mail.copy());
savePlayerData(data); savePlayerData(data);
} }
public Map<String, NBTTagCompound> getUsernameData(){ public Map<String, NBTTagCompound> getUsernameData(){
Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>(); Map<String, NBTTagCompound> map = new HashMap<String, NBTTagCompound>();
for(File file : getSaveDir().listFiles()){ for(File file : getSaveDir().listFiles()){
if(file.isDirectory() || !file.getName().endsWith(".json")) if(file.isDirectory() || !file.getName().endsWith(".json"))
continue; continue;
try { try {
NBTTagCompound compound = ensureCompressor(file); NBTTagCompound compound = NBTJsonUtil.LoadFile(file);
if(compound.hasKey("PlayerName")){
if(compound.hasKey("PlayerName")){ map.put(compound.getString("PlayerName"), compound);
map.put(compound.getString("PlayerName"), compound); }
}
} catch (Exception e) { } catch (Exception e) {
LogWriter.error("Error loading: " + file.getAbsolutePath(), e); LogWriter.error("Error loading: " + file.getAbsolutePath(), e);
} }
} }
return map; return map;
} }
public boolean hasMail(EntityPlayer player) { public boolean hasMail(EntityPlayer player) {
return getPlayerData(player).mailData.hasMail(); return getPlayerData(player).mailData.hasMail();
} }
}
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);
}
}
@@ -10,9 +10,6 @@ import noppes.npcs.ModelData;
import noppes.npcs.ModelPartData; import noppes.npcs.ModelPartData;
import noppes.npcs.client.EntityUtil; import noppes.npcs.client.EntityUtil;
// FLY CHANGE
// extends EntityNPCInterface
// extends EntityNPCFlying
public class EntityCustomNpc extends EntityNPCFlying { public class EntityCustomNpc extends EntityNPCFlying {
public ModelData modelData = new ModelData(); public ModelData modelData = new ModelData();
@@ -140,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);
@@ -399,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);
@@ -1062,7 +1061,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
jobInterface.reset(); jobInterface.reset();
EventHooks.onNPCInit(this); EventHooks.onNPCInit(this);
script.callScript(EnumScriptType.INIT);
} }
public void onCollide() { public void onCollide() {
@@ -1288,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);
} }
@@ -113,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){
@@ -123,12 +123,14 @@ public class NpcEvent extends CustomNPCsEvent {
public static class DialogEvent extends NpcEvent { public static class DialogEvent extends NpcEvent {
public final IPlayer player; public final IPlayer player;
public final int id; public final int id;
public final int optionId;
public final Dialog dialog; public final Dialog dialog;
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, Dialog dialog) { public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc); super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id; this.id = id;
this.optionId = optionId;
this.dialog = dialog; this.dialog = dialog;
} }
} }
@@ -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 IPlayer player;
public int dialog;
public int option;
public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.dialog = dialog;
this.option = option;
this.dialogObj = dialogObj;
}
public IPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return dialog;
}
public int getOptionId() {
return option;
}
/** /**
* @deprecated * @deprecated
*/ */
Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 491 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 496 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 513 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 974 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 719 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 465 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 748 B

After

Width:  |  Height:  |  Size: 748 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 364 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 602 B

After

Width:  |  Height:  |  Size: 602 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 497 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 560 B

After

Width:  |  Height:  |  Size: 560 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 610 B

After

Width:  |  Height:  |  Size: 610 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 507 B

After

Width:  |  Height:  |  Size: 507 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 714 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 946 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 674 B

After

Width:  |  Height:  |  Size: 674 B

Loaded 100 of 199 files, more files were not shown because too many files have changed in this diff. Show more