mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 16:55:12 +00:00
ScriptEntityParticle:
-Added scripted particles which can not face the player, having their angles be absolute in the world instead of relative to the camera. -set/getFacePlayer() functions added.
This commit is contained in:
1 parent
1cd3ff31b6
commit
f16e2402a6
6 files changed
+44
-67
No files matched your search
@@ -320,6 +320,7 @@ public class NoppesUtilServer {
|
||||
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||
boolean facePlayer,
|
||||
int entityID
|
||||
){
|
||||
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||
@@ -331,6 +332,7 @@ public class NoppesUtilServer {
|
||||
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||
facePlayer,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ public class NoppesUtil {
|
||||
float rotationZRate = buffer.readFloat();
|
||||
int rotationZRateStart = buffer.readInt();
|
||||
|
||||
boolean facePlayer = buffer.readBoolean();
|
||||
|
||||
int entityID = buffer.readInt();
|
||||
|
||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||
@@ -131,7 +133,7 @@ public class NoppesUtil {
|
||||
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||
maxAge
|
||||
maxAge, facePlayer
|
||||
);
|
||||
|
||||
for(int i = 0; i < amount; i++){
|
||||
|
||||
@@ -44,6 +44,8 @@ public class EntityCustomFX extends EntityFX {
|
||||
public float rotationZRate = 0.0F;
|
||||
public int rotationZRateStart = 0;
|
||||
|
||||
public boolean facePlayer = true;
|
||||
|
||||
public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||
@@ -51,7 +53,7 @@ public class EntityCustomFX extends EntityFX {
|
||||
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart,
|
||||
int age) {
|
||||
int age, boolean facePlayer) {
|
||||
super(entity.worldObj, x, y, z, motionX, motionY, motionZ);
|
||||
|
||||
this.scale1 = scale1;
|
||||
@@ -116,6 +118,8 @@ public class EntityCustomFX extends EntityFX {
|
||||
}
|
||||
|
||||
location = new ResourceLocation(directory);
|
||||
|
||||
this.facePlayer = facePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,16 +182,29 @@ public class EntityCustomFX extends EntityFX {
|
||||
double yaw = (player.rotationYaw/180)*Math.PI;
|
||||
double pitch = (player.rotationPitch/180)*Math.PI;
|
||||
|
||||
if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) {
|
||||
rotationX += 180*Math.signum(rotationX);
|
||||
}
|
||||
if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) {
|
||||
rotationY += 180*Math.signum(rotationY);
|
||||
}
|
||||
if(facePlayer) {
|
||||
if (Math.abs(rotationX % 360) >= 90 && Math.abs(rotationX % 360) < 270) {
|
||||
rotationX += 180 * Math.signum(rotationX);
|
||||
}
|
||||
if (Math.abs(rotationY % 360) >= 90 && Math.abs(rotationY % 360) < 270) {
|
||||
rotationY += 180 * Math.signum(rotationY);
|
||||
}
|
||||
|
||||
GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch));
|
||||
GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch));
|
||||
GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch));
|
||||
GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch));
|
||||
GL11.glRotated(rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch));
|
||||
GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch));
|
||||
} else {
|
||||
GL11.glRotated(player.rotationYaw % 360, 0.0, 1.0, 0.0);
|
||||
GL11.glRotated(rotationY, 0.0, 1.0, 0.0);
|
||||
GL11.glRotated(rotationX, Math.cos(yaw), 0.0, Math.sin(yaw));
|
||||
GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw));
|
||||
GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw));
|
||||
}
|
||||
/*
|
||||
if(Minecraft.getMinecraft().currentScreen == null){
|
||||
System.out.println();
|
||||
}
|
||||
*/
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(240);
|
||||
|
||||
@@ -33,6 +33,8 @@ public class ScriptEntityParticle {
|
||||
public float rotationZRate = 0.0F;
|
||||
public int rotationZRateStart = 0;
|
||||
|
||||
public boolean facePlayer = true;
|
||||
|
||||
public ScriptEntityParticle(String directory){
|
||||
this.directory = directory;
|
||||
}
|
||||
@@ -47,10 +49,14 @@ public class ScriptEntityParticle {
|
||||
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||
facePlayer,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
|
||||
public boolean getFacePlayer() { return facePlayer; }
|
||||
public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; }
|
||||
|
||||
public String getDirectory() {
|
||||
return directory;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
rotationX1, rotationX2, rotationXRate, rotationXRateStart,
|
||||
rotationY1, rotationY2, rotationYRate, rotationYRateStart,
|
||||
rotationZ1, rotationZ2, rotationZRate, rotationZRateStart,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
@@ -100,6 +101,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
@@ -117,6 +119,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
@@ -133,6 +136,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
@@ -148,6 +152,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
@@ -162,6 +167,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
true,
|
||||
entityID
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,62 +10,6 @@ import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
|
||||
public interface IEntity<T extends Entity> {
|
||||
/**
|
||||
* @param directory The particle's directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png"
|
||||
* @param HEXcolor The particle's color as a HEX integer
|
||||
* @param amount The amount of particles to spawn
|
||||
* @param maxAge The particle's maximum age in MC ticks
|
||||
|
||||
* @param x The particle's x position
|
||||
* @param y The particle's y position
|
||||
* @param z The particle's z position
|
||||
|
||||
* @param motionX The particle's speed in the x axis
|
||||
* @param motionY The particle's speed in the y axis
|
||||
* @param motionZ The particle's speed in the z axis
|
||||
* @param gravity The particle's gravity
|
||||
|
||||
* @param scale1 The particle's starting scale
|
||||
* @param scale2 The particle's ending scale
|
||||
* @param scaleRate Multiplier for the particle's scale growth rate
|
||||
* @param scaleRateStart The time at which the particle begins growing/shrinking
|
||||
|
||||
* @param alpha1 The particle's starting transparency
|
||||
* @param alpha2 The particle's ending transparency
|
||||
* @param scaleRate Multiplier for the particle's transparency growth rate
|
||||
* @param alphaRateStart The time at which the particle begins appearing/fading
|
||||
*
|
||||
* @param rotation1 The particle's starting rotation angle with respect to the player's vision
|
||||
* @param rotation2 The particle's final rotation angle with respect to the player's vision
|
||||
* @param rotationRate The rate at which the particle rotates with respect to the player's vision
|
||||
* @param rotationRateStart The time at which the particle begins rotating
|
||||
|
||||
* @param rotationX1 The particle's starting rotation angle with respect to the X-axis
|
||||
* @param rotationX2 The particle's final rotation angle with respect to the X-axis
|
||||
* @param rotationXRate The rate at which the particle rotates with respect to the X-axis
|
||||
* @param rotationXRateStart The time at which the particle begins rotating over the X-axis
|
||||
|
||||
* @param rotationY1 The particle's starting rotation angle with respect to the Y-axis
|
||||
* @param rotationY2 The particle's final rotation angle with respect to the Y-axis
|
||||
* @param rotationYRate The rate at which the particle rotates with respect to the Y-axis
|
||||
* @param rotationYRateStart The time at which the particle begins rotating over the Y-axis
|
||||
|
||||
* @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis
|
||||
* @param rotationZ2 The particle's final rotation angle with respect to the Z-axis
|
||||
* @param rotationZRate The rate at which the particle rotates with respect to the Z-axis
|
||||
* @param rotationZRateStart The time at which the particle begins rotating over the Z-axis
|
||||
*/
|
||||
void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
float scale1, float scale2, float scaleRate, int scaleRateStart,
|
||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart,
|
||||
float rotation1, float rotation2, float rotationRate, int rotationRateStart,
|
||||
float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart,
|
||||
float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart,
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
|
||||
);
|
||||
|
||||
public double getYOffset();
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user