Compare commits

..
19 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 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
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
162 changed files with 321 additions and 698 deletions

No files matched your search

+17 -50
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge' apply plugin: 'forge'
version = "1.5.3" 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,27 +29,12 @@ 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..
//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
@@ -57,44 +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' - Remove almost implementations of zstd
for (os in supportedOS) {
shade ("com.github.luben:zstd-jni:1.5.2-2:${os}")
}
} }
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 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);
}
}
+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 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 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 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.3") @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);
+8 -2
View File
@@ -76,7 +76,10 @@ public class EventHooks {
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, 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,dialogId,optionId,dialog));
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);
} }
@@ -86,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, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
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);
} }
@@ -12,11 +12,22 @@ 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 = 17; 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){ if(npc.npcVersion < 17){
// Fix DialogDarkenScreen // Fix DialogDarkenScreen
if(compound.hasKey("DialogDarkenScreen")){ if(compound.hasKey("DialogDarkenScreen")){
@@ -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
@@ -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);
@@ -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);
} }
} }
@@ -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 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 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();
@@ -6,19 +6,19 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IPlayer; import noppes.npcs.scripted.interfaces.IPlayer;
public class ScriptEventDialog extends ScriptEvent{ public class ScriptEventDialog extends ScriptEvent{
public EntityPlayer player; public IPlayer player;
public int dialog; public int dialog;
public int option; public int option;
public Dialog dialogObj; public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){ public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = player; this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.dialog = dialog; this.dialog = dialog;
this.option = option; this.option = option;
this.dialogObj = dialogObj; this.dialogObj = dialogObj;
} }
public EntityPlayer getPlayer() { public IPlayer getPlayer() {
return player; return player;
} }
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

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 870 B

After

Width:  |  Height:  |  Size: 870 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 367 B

After

Width:  |  Height:  |  Size: 367 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: 710 B

After

Width:  |  Height:  |  Size: 710 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 536 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 431 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 521 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

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