diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 318cf8152..3ba3a02d6 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -74,6 +74,15 @@ public class EntityCustomFX extends EntityFX { location = new ResourceLocation(directory); } + /* + par2 = partial tick time + par3 = ActiveRenderInfo.rotationX; + par4 = ActiveRenderInfo.rotationZ; + par5 = ActiveRenderInfo.rotationYZ; + par6 = ActiveRenderInfo.rotationXY; + par7 = ActiveRenderInfo.rotationXZ; + */ + @Override public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { @@ -121,12 +130,16 @@ public class EntityCustomFX extends EntityFX { Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = minecraft.thePlayer; - double yaw = (player.rotationYaw/180)*Math.PI; - double pitch = (player.rotationPitch/180)*Math.PI; - double angle = Minecraft.getMinecraft().theWorld.getWorldTime()%360; double angleRad = (angle/180)*Math.PI; + double diffX = player.posX - this.startX; + double diffY = player.posY - player.getYOffset() - this.startY; + double diffZ = player.posZ - this.startZ; + + double yaw = (player.rotationYaw/180)*Math.PI; + double pitch = (player.rotationPitch/180)*Math.PI; + double angleX = Math.sin(yaw)*Math.cos(pitch); if(Math.abs(angleX) < 0.0001){ angleX = 0.0D; @@ -140,13 +153,62 @@ public class EntityCustomFX extends EntityFX { angleZ = 0.0D; } - double translateX = 0; + double angleXtranslateX = 0.0D; + double angleXtranslateY = 0.0D;//(-diffY + Math.cos(angleRad)*diffY) + (-Math.sin(angleRad)*diffZ); + double angleXtranslateZ = 0.0D;//(Math.sin(angleRad)*diffY) + (-diffZ + Math.cos(angleRad)*diffZ); + + double angleYtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (Math.sin(angleRad)*diffZ); + double angleYtranslateY = 0.0D; + double angleYtranslateZ = 0.0D;//(-Math.sin(angleRad)*diffX) + (-diffZ + Math.cos(angleRad)*diffZ); + + double angleZtranslateX = 0.0D;//(-diffX + Math.cos(angleRad)*diffX) + (-Math.sin(angleRad)*diffY); + double angleZtranslateY = 0.0D;//(Math.sin(angleRad)*diffX) + (-diffY + Math.cos(angleRad)*diffY); + double angleZtranslateZ = 0.0D; + + double translateX = angleXtranslateX + angleYtranslateX + angleZtranslateX; + double translateY = angleXtranslateY + angleYtranslateY + angleZtranslateY; + double translateZ = angleXtranslateZ + angleYtranslateZ + angleZtranslateZ; + + //distance in the X & Z plane + double distXZ = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffZ,2)); + //distance in the X & Y plane + double distXY = Math.sqrt(Math.pow(diffX,2) + Math.pow(diffY,2)); + //distance in the Y & Z plane + double distYZ = Math.sqrt(Math.pow(diffY,2) + Math.pow(diffZ,2)); + + double signDiffX = Math.signum(diffX); + double signDiffY = Math.signum(diffY); + double signDiffZ = Math.signum(diffZ); + + double angleXtoNorm = Math.sin(Math.acos(diffX/distXZ)); + double angleZtoNorm = Math.sin(Math.acos(diffZ/distXZ)); + + double angleDiffX = (Math.abs(Math.cos(yaw))-angleXtoNorm); + double angleDiffZ = (Math.abs(Math.cos(yaw))-angleZtoNorm); + + double translateX = -Math.abs(angleDiffX*angleZ*distXZ)*signDiffX; double translateY = 0; - double translateZ = 0; + double translateZ = -Math.abs(angleDiffX*angleX*distXZ)*signDiffZ + Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ; + + if(minecraft.currentScreen == null) { + System.out.println(); + //System.out.printf("diffX: %f, diffY: %f, diffZ: %f\n", diffX, diffY, diffZ); + //System.out.printf("angleX: %f, angleY: %f, angleZ: %f\n", angleX, angleY, angleZ); + //System.out.printf("angleXtoNorm: %f, angleZtoNorm: %f\n", angleXtoNorm, angleZtoNorm); + System.out.printf("Math.sin(yaw): %f\n", Math.sin(yaw)); + System.out.printf("Math.cos(yaw): %f\n", Math.cos(yaw)); + //System.out.printf("Math.sin(pitch): %f\n", Math.sin(pitch)); + //System.out.printf("Math.cos(pitch): %f\n", Math.cos(pitch)); + System.out.printf("angleDiffX: %f\n", angleDiffX); + System.out.printf("angleDiffZ: %f\n", angleDiffZ); + System.out.printf("translateX: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleZ*distXZ)*signDiffX); + System.out.printf("translateZ: %f\n", Math.cos(angleRad)*Math.abs(angleDiffX*angleX*distXZ)*signDiffZ); + } */ GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 1.0F); + //GL11.glTranslated(translateX,translateY,translateZ); //GL11.glRotated(angle, angleX, angleY, angleZ); diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 32a1321fd..31eb61e01 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -28,6 +28,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { int id; int border = 2; boolean labelBgEnabled = true; + boolean labelShadowEnabled = false; protected int field_146167_a; protected int field_146161_f; @@ -45,13 +46,14 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { private int field_146163_s; private static final String __OBFID = "CL_00000671"; - public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height){ + public CustomGuiLabel(int id, String fullLabel, int x, int y, int width, int height, boolean shadow){ this.id = id; this.fullLabel = fullLabel; this.x = x; this.y = y; this.width = width; this.height = height; + this.labelShadowEnabled = shadow; } public void setParent(GuiCustom parent) { @@ -75,7 +77,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } public static CustomGuiLabel fromComponent(ScriptGuiLabel component) { - CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight()); + CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow()); lbl.scale = 1.0F; lbl.color = component.getColor(); lbl.field_146172_j = true; @@ -83,6 +85,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { if (component.hasHoverText()) { lbl.hoverText = component.getHoverText(); } + lbl.labelShadowEnabled = component.hasShadow(); return lbl; } @@ -90,6 +93,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { public ICustomGuiComponent toComponent() { ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color); component.setHoverText(this.hoverText); + component.enableShadow(this.labelShadowEnabled); return component; } @@ -100,8 +104,13 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawLabelBackground(); - this.drawString(Minecraft.getMinecraft().fontRenderer, fullLabel, this.x, this.y, this.color); + GL11.glPushMatrix(); + GL11.glTranslatef(this.x,this.y,0.0F); + GL11.glScalef(this.scale, this.scale, this.scale); + Minecraft.getMinecraft().fontRenderer.drawString(fullLabel, 0, 0, this.color, this.labelShadowEnabled); + GL11.glPopMatrix(); } } @@ -109,8 +118,8 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { { if (this.labelBgEnabled) { - int k = this.width + this.border * 2; - int l = this.height + this.border * 2; + int k = (int)(this.width*this.scale) + this.border * 2; + int l = (int)(this.height*this.scale) + this.border * 2; int i1 = this.x - this.border; int j1 = this.y - this.border; drawRect(i1, j1, i1 + k, j1 + l, this.color);//backColor diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 229e8e311..992e024ca 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -56,7 +56,11 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; mc.getTextureManager().bindTexture(this.texture); - this.drawTexturedModalRect(this.x + this.textureX, this.y + this.textureY, 0, 0, (int)(this.width*this.scale), (int)(this.height*this.scale)); + GL11.glPushMatrix(); + GL11.glColor4f(1.0F,1.0F,1.0F,1.0F); + GL11.glScalef(this.scale, this.scale, this.scale); + this.drawTexturedModalRect((int) (this.x/this.scale), (int) (this.y/this.scale), this.textureX, this.textureY, (int)(this.width), (int)(this.height)); + GL11.glPopMatrix(); if (hovered && this.hoverText != null && this.hoverText.length > 0) { this.parent.hoverText = this.hoverText; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 4c7aed224..2d029b97c 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -472,10 +472,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti @Override public boolean attackEntityFrom(DamageSource damagesource, float i) { - if (this.worldObj.isRemote || CustomNpcs.FreezeNPCs || damagesource.damageType.equals("inWall")){ + if (this.worldObj.isRemote || CustomNpcs.FreezeNPCs || (damagesource.damageType != null && damagesource.damageType.equals("inWall"))){ return false; } - if(damagesource.damageType.equals("outOfWorld") && isKilled()){ + if(damagesource.damageType != null && damagesource.damageType.equals("outOfWorld") && isKilled()){ reset(); } i = stats.resistances.applyResistance(damagesource, i); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 843a402fd..e6ef07d7d 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -41,7 +41,10 @@ public class ScriptLivingBase extends ScriptEntity