diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index ca5b640dd..2c977d3f4 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -11,6 +11,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringUtils; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.data.AnimationData; +import noppes.npcs.controllers.data.CustomTintData; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.data.DataSkinOverlays; @@ -61,12 +62,15 @@ public class DataDisplay { //0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players public int collidesWith = 1; + public CustomTintData customTintData; + public DataDisplay(EntityNPCInterface npc){ this.npc = npc; markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1); skinOverlayData = new DataSkinOverlays(npc); name = getRandomName(); animationData = new AnimationData(this); + customTintData = new CustomTintData(); } public String getRandomName() { @@ -89,6 +93,8 @@ public class DataDisplay { nbttagcompound = animationData.writeToNBT(nbttagcompound); + nbttagcompound = customTintData.writeToNBT(nbttagcompound); + if (this.playerProfile != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); @@ -166,6 +172,8 @@ public class DataDisplay { animationData.readFromNBT(nbttagcompound); + customTintData.readFromNBT(nbttagcompound); + modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); if(modelSize > ConfigMain.NpcSizeLimit) modelSize = ConfigMain.NpcSizeLimit; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java new file mode 100644 index 000000000..54b72821e --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcTint.java @@ -0,0 +1,105 @@ +package noppes.npcs.client.gui; + +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.DataStats; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.controllers.data.CustomTintData; +import noppes.npcs.controllers.data.DialogImage; + +public class SubGuiNpcTint extends SubGuiInterface implements ISubGuiListener, ITextfieldListener { + private CustomTintData tintData; + private int lastColorClicked = -1; + + public SubGuiNpcTint(CustomTintData tintData) { + this.tintData = tintData; + setBackground("menubg.png"); + xSize = 256; + ySize = 216; + closeOnEsc = true; + } + + @Override + public void initGui() { + super.initGui(); + int y = 30; + addLabel(new GuiNpcLabel(0, "Enable Custom Tint", guiLeft + 5, guiTop + y + 5)); + addButton(new GuiNpcButtonYesNo(0, guiLeft + 122, guiTop + y, 56, 20, tintData.isEnableCustomTint())); + y+=22; + if (tintData.isEnableCustomTint()) { + addLabel(new GuiNpcLabel(1, "Enable Npc Tint", guiLeft + 5, guiTop + y + 5)); + addButton(new GuiNpcButtonYesNo(1, guiLeft + 122, guiTop + y, 56, 20, tintData.isEnableNpcTint())); + y+=22; + if(tintData.isEnableNpcTint()) { + String color = Integer.toHexString(tintData.getColorNpcTint()); + while (color.length() < 6) color = 0 + color; + addLabel(new GuiNpcLabel(2, "Npc Tint", guiLeft + 4, guiTop + y + 5)); + addButton(new GuiNpcButton(2, guiLeft + 122, guiTop + y, 60, 20, color)); + getButton(2).setTextColor(tintData.getColorNpcTint()); + y+=22; + addLabel(new GuiNpcLabel(3,"Npc Tint Alpha", guiLeft + 5, guiTop + y + 5)); + addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 122, guiTop + y, 60, 20, tintData.getColorNpcTintAlpha() + "")); + getTextField(3).integersOnly = true; + getTextField(3).setMinMaxDefault(1, 100, 40); + y+=22; + } + addLabel(new GuiNpcLabel(4, "Enable Hurt Tint", guiLeft + 5, guiTop + y + 5)); + addButton(new GuiNpcButtonYesNo(4, guiLeft + 122, guiTop + y, 56, 20, tintData.isEnableHurtTint())); + y+=22; + if (tintData.isEnableHurtTint()) { + String color2 = Integer.toHexString(tintData.getColorHurtTint()); + while (color2.length() < 6) color2 = 0 + color2; + addLabel(new GuiNpcLabel(5, "Hurt Tint", guiLeft + 4, guiTop + y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 122, guiTop + y, 60, 20, color2)); + getButton(5).setTextColor(tintData.getColorHurtTint()); + } + } + addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 190, 98, 20, "gui.done")); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + int id = guibutton.id; + GuiNpcButton button = (GuiNpcButton) guibutton; + if (id == 0) { + tintData.setEnableCustomTint(((GuiNpcButtonYesNo) button).getBoolean()); + initGui(); + } + if (id == 1) { + tintData.setEnableNpcTint(((GuiNpcButtonYesNo) button).getBoolean()); + initGui(); + } + if (id == 4) { + tintData.setEnableHurtTint(((GuiNpcButtonYesNo) button).getBoolean()); + initGui(); + } + if (button.id == 2) { + setSubGui(new SubGuiColorSelector(tintData.getColorNpcTint())); + lastColorClicked = 0; + } + if (button.id == 5) { + setSubGui(new SubGuiColorSelector(tintData.getColorHurtTint())); + lastColorClicked = 1; + } + if (id == 66) { + close(); + } + } + + @Override + public void subGuiClosed(SubGuiInterface subgui) { + if (lastColorClicked == 0) { + tintData.setColorNpcTint(((SubGuiColorSelector) subgui).color); + } else if (lastColorClicked == 1) { + tintData.setColorHurtTint(((SubGuiColorSelector) subgui).color); + } + initGui(); + save(); + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if(textfield.id==3){ + tintData.setColorNpcTintAlpha(textfield.getInteger()); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 42de415d7..13a1a68e5 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -7,10 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.DataDisplay; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.GuiNPCTextures; -import noppes.npcs.client.gui.GuiNpcTextureCloaks; -import noppes.npcs.client.gui.GuiNpcTextureOverlays; -import noppes.npcs.client.gui.SubGuiNpcName; +import noppes.npcs.client.gui.*; import noppes.npcs.client.gui.model.GuiCreationScreen; import noppes.npcs.client.gui.util.*; import noppes.npcs.config.ConfigMain; @@ -46,6 +43,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene y+=23; addLabel(new GuiNpcLabel(11,"gui.title", guiLeft + 5, y + 5)); addTextField(new GuiNpcTextField(11,this, fontRendererObj, guiLeft + 50, y, 206, 20, display.title)); + this.addButton(new GuiNpcButton(13, guiLeft + 259, y , 80, 20, "Tint settings")); y+=23; addLabel(new GuiNpcLabel(1,"display.model", guiLeft + 5, y + 5)); @@ -185,6 +183,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene npc.display.skinOverlayData.overlayList.get(0).setBlend(button.getValue() == 0); initGui(); } + else if (button.id == 13){ + setSubGui(new SubGuiNpcTint(display.customTintData)); + } else if(button.id == 14){ String name = display.getRandomName(); display.setName(name); diff --git a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java index 8d1ad6ab0..cc959b665 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelLegs.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelLegs.java @@ -11,6 +11,7 @@ import noppes.npcs.client.model.part.legs.ModelMermaidLegs2; import noppes.npcs.client.model.part.legs.ModelNagaLegs; import noppes.npcs.client.model.util.ModelScaleRenderer; import noppes.npcs.constants.EnumAnimation; +import noppes.npcs.controllers.data.CustomTintData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; @@ -386,7 +387,9 @@ public class ModelLegs extends ModelScaleRenderer{ y *= 2f; } } - boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor; + CustomTintData customTintData = entity.display.customTintData; + boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor && + !(customTintData.isEnableCustomTint() && customTintData.isEnableNpcTint()); if(bo){ float red = (entity.modelData.legParts.color >> 16 & 255) / 255f; float green = (entity.modelData.legParts.color >> 8 & 255) / 255f; diff --git a/src/main/java/noppes/npcs/client/model/part/ModelTail.java b/src/main/java/noppes/npcs/client/model/part/ModelTail.java index 1cd310381..7541a7168 100644 --- a/src/main/java/noppes/npcs/client/model/part/ModelTail.java +++ b/src/main/java/noppes/npcs/client/model/part/ModelTail.java @@ -10,6 +10,7 @@ import noppes.npcs.client.model.ModelMPM; import noppes.npcs.client.model.part.tails.*; import noppes.npcs.client.model.util.ModelScaleRenderer; import noppes.npcs.constants.EnumAnimation; +import noppes.npcs.controllers.data.CustomTintData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelPartData; import org.lwjgl.opengl.GL11; @@ -150,7 +151,9 @@ public class ModelTail extends ModelScaleRenderer { base.currentlyPlayerTexture = true; } } - boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0; + CustomTintData customTintData = entity.display.customTintData; + boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor && + !(customTintData.isEnableCustomTint() && customTintData.isEnableNpcTint()); if(bo){ float red = (color >> 16 & 255) / 255f; float green = (color >> 8 & 255) / 255f; diff --git a/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java b/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java index d8c9384ca..25d9d70e6 100644 --- a/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java +++ b/src/main/java/noppes/npcs/client/model/util/ModelPartInterface.java @@ -6,6 +6,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ClientProxy; import noppes.npcs.client.model.ModelMPM; +import noppes.npcs.controllers.data.CustomTintData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.data.ModelData; import noppes.npcs.entity.data.ModelPartData; @@ -59,7 +60,9 @@ public abstract class ModelPartInterface extends ModelRenderer { base.currentlyPlayerTexture = true; } } - boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor; + CustomTintData customTintData = entity.display.customTintData; + boolean bo = entity.hurtTime <= 0 && entity.deathTime <= 0 && !base.isArmor && + !(customTintData.isEnableCustomTint() && customTintData.isEnableNpcTint()); if(bo){ float red = (color >> 16 & 255) / 255f; float green = (color >> 8 & 255) / 255f; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index b611c9d5f..01eeffc30 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -18,17 +18,22 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.common.MinecraftForge; import noppes.npcs.api.ISkinOverlay; import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumStandingType; +import noppes.npcs.controllers.data.CustomTintData; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -213,9 +218,261 @@ public class RenderNPCInterface extends RenderLiving{ } staticRenderManager = this.renderManager; - super.doRender(entityliving, d, d1, d2, f, f1); + + doRenderLiving(npc, d, d1, d2, f, f1); } + public void doRenderLiving(EntityNPCInterface p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) + { + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_); + + if (this.renderPassModel != null) + { + this.renderPassModel.onGround = this.mainModel.onGround; + } + + this.mainModel.isRiding = p_76986_1_.isRiding(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isRiding = this.mainModel.isRiding; + } + + this.mainModel.isChild = p_76986_1_.isChild(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isChild = this.mainModel.isChild; + } + + try + { + float f2 = this.interpolateRotation(p_76986_1_.prevRenderYawOffset, p_76986_1_.renderYawOffset, p_76986_9_); + float f3 = this.interpolateRotation(p_76986_1_.prevRotationYawHead, p_76986_1_.rotationYawHead, p_76986_9_); + float f4; + + if (p_76986_1_.isRiding() && p_76986_1_.ridingEntity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_76986_1_.ridingEntity; + f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, p_76986_9_); + f4 = MathHelper.wrapAngleTo180_float(f3 - f2); + + if (f4 < -85.0F) + { + f4 = -85.0F; + } + + if (f4 >= 85.0F) + { + f4 = 85.0F; + } + + f2 = f3 - f4; + + if (f4 * f4 > 2500.0F) + { + f2 += f4 * 0.2F; + } + } + + float f13 = p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_; + this.renderLivingAt(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_); + f4 = this.handleRotationFloat(p_76986_1_, p_76986_9_); + this.rotateCorpse(p_76986_1_, f4, f2, p_76986_9_); + float f5 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.preRenderCallback(p_76986_1_, p_76986_9_); + GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F); + float f6 = p_76986_1_.prevLimbSwingAmount + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_; + float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_); + + if (p_76986_1_.isChild()) + { + f7 *= 3.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.mainModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_); + this.renderModel(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + int j; + float f8; + float f9; + float f10; + + for (int i = 0; i < 4; ++i) + { + j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_); + + if (j > 0) + { + this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + if ((j & 240) == 16) + { + this.func_82408_c(p_76986_1_, i, p_76986_9_); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + + if ((j & 15) == 15) + { + f8 = (float)p_76986_1_.ticksExisted + p_76986_9_; + this.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png")); + GL11.glEnable(GL11.GL_BLEND); + f9 = 0.5F; + GL11.glColor4f(f9, f9, f9, 1.0F); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDepthMask(false); + + for (int k = 0; k < 2; ++k) + { + GL11.glDisable(GL11.GL_LIGHTING); + f10 = 0.76F; + GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F; + float f12 = 0.33333334F; + GL11.glScalef(f12, f12, f12); + GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, f11, 0.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glDepthMask(true); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + GL11.glDepthMask(true); + this.renderEquippedItems(p_76986_1_, p_76986_9_); + float f14 = p_76986_1_.getBrightness(p_76986_9_); + j = this.getColorMultiplier(p_76986_1_, f14, p_76986_9_); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + CustomTintData customTintData = p_76986_1_.display.customTintData; + if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0 || (customTintData.isEnableCustomTint() && customTintData.isEnableNpcTint())) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + + if ((p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) && (!customTintData.isEnableCustomTint() || customTintData.isEnableHurtTint())) + { + float r, g, b; + if(customTintData.isEnableCustomTint()) { + r = (float) (customTintData.getColorHurtTint() >> 16 & 255) / 255.0F * f14; + g = (float) (customTintData.getColorHurtTint() >> 8 & 255) / 255.0F * f14; + b = (float) (customTintData.getColorHurtTint() & 255) / 255.0F * f14; + }else{ + r=f14; + g=0; + b=0; + } + GL11.glColor4f(r,g,b, 0.4F); + this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + for (int l = 0; l < 4; ++l) + { + if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0) + { + GL11.glColor4f(r,g,b, 0.4F); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + if ((j >> 24 & 255) > 0) + { + f8 = (float)(j >> 16 & 255) / 255.0F; + f9 = (float)(j >> 8 & 255) / 255.0F; + float f15 = (float)(j & 255) / 255.0F; + f10 = (float)(j >> 24 & 255) / 255.0F; + GL11.glColor4f(f8, f9, f15, f10); + this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + + for (int i1 = 0; i1 < 4; ++i1) + { + if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0) + { + GL11.glColor4f(f8, f9, f15, f10); + this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + catch (Exception exception) + { + + } + + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + this.passSpecialRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_); + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_)); + this.func_110827_b(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } + + private float interpolateRotation(float p_77034_1_, float p_77034_2_, float p_77034_3_) + { + float f3; + + for (f3 = p_77034_2_ - p_77034_1_; f3 < -180.0F; f3 += 360.0F) + { + ; + } + + while (f3 >= 180.0F) + { + f3 -= 360.0F; + } + + return p_77034_1_ + p_77034_3_ * f3; + } + + protected int getColorMultiplier(EntityLivingBase p_77030_1_, float p_77030_2_, float p_77030_3_) + { + EntityNPCInterface npc = (EntityNPCInterface) p_77030_1_; + CustomTintData tintData = npc.display.customTintData; + int alpha = (int) (0xff*((double)tintData.getColorNpcTintAlpha()/100d)) << 24; + return (tintData.isEnableCustomTint() && tintData.isEnableNpcTint())?tintData.getColorNpcTint()+alpha:0; + } + protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) { EntityNPCInterface npc = (EntityNPCInterface) entityliving; if(GeckoAddonClient.Instance.isGeckoModel(mainModel)){ diff --git a/src/main/java/noppes/npcs/controllers/data/CustomTintData.java b/src/main/java/noppes/npcs/controllers/data/CustomTintData.java new file mode 100644 index 000000000..c19c425ac --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/CustomTintData.java @@ -0,0 +1,83 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.nbt.NBTTagCompound; + +public class CustomTintData { + private boolean enableCustomTint = false; + private boolean enableHurtTint = true; + private boolean enableNpcTint = false; + private int colorHurtTint = 0xff0000; + private int colorNpcTint = 0x000000; + private int colorNpcTintAlpha = 40; + + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setBoolean("EnableCustomTint", enableCustomTint); + if(enableCustomTint) { + nbttagcompound.setBoolean("EnableHurtTint", enableHurtTint); + nbttagcompound.setBoolean("EnableNpcTint", enableNpcTint); + nbttagcompound.setInteger("ColorHurtTint", colorHurtTint); + nbttagcompound.setInteger("ColorNpcTint", colorNpcTint); + nbttagcompound.setInteger("ColorNpcTintAlpha", colorNpcTintAlpha); + } + return nbttagcompound; + } + + public void readFromNBT(NBTTagCompound nbttagcompound) { + enableCustomTint = nbttagcompound.getBoolean("EnableCustomTint"); + if(enableCustomTint) { + enableHurtTint = nbttagcompound.getBoolean("EnableHurtTint"); + enableNpcTint = nbttagcompound.getBoolean("EnableNpcTint"); + colorHurtTint = nbttagcompound.getInteger("ColorHurtTint"); + colorNpcTint = nbttagcompound.getInteger("ColorNpcTint"); + colorNpcTintAlpha = nbttagcompound.getInteger("ColorNpcTintAlpha"); + } + } + + public boolean isEnableHurtTint() { + return enableHurtTint; + } + + public void setEnableHurtTint(boolean enableHurtTint) { + this.enableHurtTint = enableHurtTint; + } + + public int getColorHurtTint() { + return colorHurtTint; + } + + public void setColorHurtTint(int colorHurtTint) { + this.colorHurtTint = colorHurtTint; + } + + public int getColorNpcTint() { + return colorNpcTint; + } + + public void setColorNpcTint(int colorNpcTint) { + this.colorNpcTint = colorNpcTint; + } + + public boolean isEnableCustomTint() { + return enableCustomTint; + } + + public void setEnableCustomTint(boolean enableCustomTint) { + this.enableCustomTint = enableCustomTint; + } + + public boolean isEnableNpcTint() { + return enableNpcTint; + } + + public void setEnableNpcTint(boolean enableNpcTint) { + this.enableNpcTint = enableNpcTint; + } + + public int getColorNpcTintAlpha() { + return colorNpcTintAlpha; + } + + public void setColorNpcTintAlpha(int colorNpcTintAlpha) { + this.colorNpcTintAlpha = colorNpcTintAlpha; + } +}