Cape Invisibility | MPM Dependency Fix

This commit is contained in:
KAMKEEL committed 2022-06-15 01:58:46 -04:00
1 parent 5785b643b0
commit 16edeabb9a
5 files changed
+88 -72

No files matched your search

@@ -35,10 +35,6 @@ public class ModelPartData {
type = compound.getByte("Type");
color = compound.getInteger("Color");
texture = compound.getString("Texture");
// Disable MPM Dependency for Part Textures
// if(VersionCompatibility.ModRev < 19){
// texture = texture.replace("moreplayermodels:textures", "customnpcs:textures/parts");
// }
playerTexture = compound.getBoolean("PlayerTexture");
location = null;
}
@@ -14,7 +14,7 @@ import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.Sys;
public class VersionCompatibility {
public static int ModRev = 18;
public static int ModRev = 19;
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev)
@@ -32,33 +32,6 @@ public class VersionCompatibility {
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
// Remove MPM Texture Requirement
if(compound.hasKey("NpcModelData")) {
NBTTagCompound partData = compound.getCompoundTag("NpcModelData");
// Fix Leg MPM Dependency
if(partData.hasKey("LegParts")){
partData.setString("LegParts", partData.getCompoundTag("LegParts").getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
// Fix Part MPM Dependency
if(partData.hasKey("Parts")){
NBTTagList list = partData.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
if(item.hasKey("Texture")){
item.setString("Texture", item.getString("Texture"));
}
list.func_150304_a(i, item);
}
partData.setTag("Parts", list);
}
compound.setTag("NpcModelData", partData);
((EntityCustomNpc)npc).readEntityFromNBT(compound);
}
}
if(npc.npcVersion < 12){
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
@@ -132,6 +105,40 @@ public class VersionCompatibility {
}
npc.npcVersion = ModRev;
}
public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev)
return;
if(npc.npcVersion < 19) {
NBTTagCompound partData = compound.getCompoundTag("NpcModelData");
// Fix Leg MPM Dependency
if(partData.hasKey("LegParts")){
NBTTagCompound legParts = partData.getCompoundTag("LegParts");
if(legParts.hasKey("Texture")){
legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
partData.setTag("LegParts", legParts);
}
// Fix Part MPM Dependency
if(partData.hasKey("Parts")){
NBTTagList list = partData.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
if(item.hasKey("Texture")){
item.setString("Texture", item.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
list.func_150304_a(i, item);
}
partData.setTag("Parts", list);
}
compound.setTag("NpcModelData", partData);
}
}
public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){
if(compatibilty.getVersion() == ModRev)
return;
@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomItems;
import noppes.npcs.ModelPartConfig;
import noppes.npcs.ModelPartData;
@@ -27,6 +28,8 @@ import noppes.npcs.roles.JobPuppet;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import static noppes.npcs.client.ClientProxy.bindTexture;
public class ModelMPM extends ModelNPCMale{
private ModelPartInterface wings;
private ModelPartInterface mohawk;
@@ -413,6 +416,7 @@ public class ModelMPM extends ModelNPCMale{
renderArms(npc, par7,false);
renderBody(npc, par7);
renderLegs(npc, par7);
renderCloak(npc, par7);
}
}
@@ -514,7 +518,7 @@ public class ModelMPM extends ModelNPCMale{
public void loadPlayerTexture(EntityCustomNpc npc){
if(!isArmor && !currentlyPlayerTexture){
ClientProxy.bindTexture(npc.textureLocation);
bindTexture(npc.textureLocation);
currentlyPlayerTexture = true;
}
}
@@ -763,4 +767,46 @@ public class ModelMPM extends ModelNPCMale{
return bipedBody;
}
public void renderCloak(EntityCustomNpc entity, float f)
{
if (!entity.display.cloakTexture.isEmpty() && !entity.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
{
if(entity.textureCloakLocation == null){
entity.textureCloakLocation = new ResourceLocation(entity.display.cloakTexture);
}
bindTexture((ResourceLocation) entity.textureCloakLocation);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
double d = (entity.field_20066_r + (entity.field_20063_u - entity.field_20066_r) * (double)f) - (entity.prevPosX + (entity.posX - entity.prevPosX) * (double)f);
double d1 = (entity.field_20065_s + (entity.field_20062_v - entity.field_20065_s) * (double)f) - (entity.prevPosY + (entity.posY - entity.prevPosY) * (double)f);
double d2 = (entity.field_20064_t + (entity.field_20061_w - entity.field_20064_t) * (double)f) - (entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)f);
float f11 = entity.prevRenderYawOffset + (entity.renderYawOffset - entity.prevRenderYawOffset) * f;
double d3 = MathHelper.sin((f11 * 3.141593F) / 180F);
double d4 = -MathHelper.cos((f11 * 3.141593F) / 180F);
float f14 = (float)(d * d3 + d2 * d4) * 100F;
float f15 = (float)(d * d4 - d2 * d3) * 100F;
if (f14 < 0.0F)
{
f14 = 0.0F;
}
float f13 = 5f;
if (entity.isSneaking())
{
f13 += 25F;
}
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, 1.0F, 0.0F);
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, alpha);
super.renderCloak(f);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
}
@@ -180,43 +180,6 @@ public class RenderNPCHumanMale extends RenderNPCInterface
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
if (!npc.display.cloakTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
{
if(npc.textureCloakLocation == null){
npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture);
}
bindTexture((ResourceLocation) npc.textureCloakLocation);
GL11.glPushMatrix();
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 d1 = (npc.field_20065_s + (npc.field_20062_v - npc.field_20065_s) * (double)f) - (npc.prevPosY + (npc.posY - npc.prevPosY) * (double)f);
double d2 = (npc.field_20064_t + (npc.field_20061_w - npc.field_20064_t) * (double)f) - (npc.prevPosZ + (npc.posZ - npc.prevPosZ) * (double)f);
float f11 = npc.prevRenderYawOffset + (npc.renderYawOffset - npc.prevRenderYawOffset) * f;
double d3 = MathHelper.sin((f11 * 3.141593F) / 180F);
double d4 = -MathHelper.cos((f11 * 3.141593F) / 180F);
float f14 = (float)(d * d3 + d2 * d4) * 100F;
float f15 = (float)(d * d4 - d2 * d3) * 100F;
if (f14 < 0.0F)
{
f14 = 0.0F;
}
float f16 = npc.prevRotationYaw + (npc.rotationYaw - npc.prevRotationYaw) * f;
float f13 = 5f;
if (npc.isSneaking())
{
f13 += 25F;
}
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, 1.0F, 0.0F);
GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
GL11.glColor4f(1.0F,1.0F,1.0F, npc.isInvisible() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) ? 0.2F : 1.0F);
GL11.glEnable(GL11.GL_BLEND);
modelBipedMain.renderCloak(0.0625F);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glColor3f(1,1,1);
ItemStack itemstack = npc.inventory.armorItemInSlot(0);
if(itemstack != null)
@@ -8,6 +8,7 @@ import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.ModelData;
import noppes.npcs.ModelPartData;
import noppes.npcs.VersionCompatibility;
import noppes.npcs.client.EntityUtil;
public class EntityCustomNpc extends EntityNPCFlying {
@@ -19,9 +20,12 @@ public class EntityCustomNpc extends EntityNPCFlying {
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
if(compound.hasKey("NpcModelData"))
modelData.readFromNBT(compound.getCompoundTag("NpcModelData"));
super.readEntityFromNBT(compound);
if(compound.hasKey("NpcModelData")) {
npcVersion = compound.getInteger("ModRev");
VersionCompatibility.CheckModelCompatibility(this, compound);
modelData.readFromNBT(compound.getCompoundTag("NpcModelData"));
}
}
@Override