mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 16:37:45 +00:00
7 files changed
+108
-15
No files matched your search
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -41,7 +41,10 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
}
|
||||
|
||||
public void hurt(float damage, ScriptEntity source) {
|
||||
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage);
|
||||
if(source.getType() == 1)//if player
|
||||
entity.attackEntityFrom(new EntityDamageSource("player",source.getMCEntity()),damage);
|
||||
else
|
||||
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage);
|
||||
}
|
||||
|
||||
public void hurt(float damage, ScriptDamageSource damageSource) {
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
int height;
|
||||
int color;
|
||||
float scale;
|
||||
boolean shadow;
|
||||
|
||||
public ScriptGuiLabel() {
|
||||
this.color = 16777215;
|
||||
@@ -22,6 +23,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
this.setText(label);
|
||||
this.setPos(x, y);
|
||||
this.setSize(width, height);
|
||||
this.enableShadow(false);
|
||||
}
|
||||
|
||||
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) {
|
||||
@@ -70,6 +72,14 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasShadow(){
|
||||
return this.shadow;
|
||||
}
|
||||
|
||||
public void enableShadow(boolean shadow){
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 1;
|
||||
}
|
||||
@@ -80,6 +90,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
nbt.setInteger("color", this.color);
|
||||
nbt.setFloat("scale", this.scale);
|
||||
nbt.setBoolean("shadow",this.shadow);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@@ -89,6 +100,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
this.setColor(nbt.getInteger("color"));
|
||||
this.setScale(nbt.getFloat("scale"));
|
||||
this.enableShadow(this.shadow);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,10 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
}
|
||||
|
||||
public IDamageSource getIDamageSource(IEntity entity) {
|
||||
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity()));
|
||||
if(entity.getType() == 1)//if player
|
||||
return new ScriptDamageSource(new EntityDamageSource("player",entity.getMCEntity()));
|
||||
else
|
||||
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity()));
|
||||
}
|
||||
|
||||
public void executeCommand(IWorld world, String command) {
|
||||
|
||||
Reference in new issue
Block a user