mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 09:09:08 +00:00
ScriptParticle:
-Added HEXColor2, HEXColorRate, and HEXColorRateStart fields, and respective setters and getters, allowing for changes in HEX color over time. Marked plenty of old ScriptEntityParticle functions as deprecated. This includes any functions referring to scripted particles as "Entity Particles" and functions outside the API or ScriptParticle class used to spawn or create particles.
This commit is contained in:
1 parent
d49a31a4fe
commit
5520fc5f2b
7 files changed
+138
-42
No files matched your search
@@ -312,7 +312,9 @@ public class NoppesUtilServer {
|
||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
public static void spawnScriptedParticle(String directory,
|
||||
int HEXColor, int HEXColor2, float colorRate, int rateStart,
|
||||
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,
|
||||
@@ -325,7 +327,9 @@ public class NoppesUtilServer {
|
||||
int entityID, int dimensionID
|
||||
){
|
||||
Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE,
|
||||
directory, HEXcolor, amount, maxAge,
|
||||
directory,
|
||||
HEXColor, HEXColor2, colorRate, rateStart,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
|
||||
@@ -75,7 +75,11 @@ public class NoppesUtil {
|
||||
|
||||
String directory = Server.readString(buffer);
|
||||
|
||||
int HEXcolor = buffer.readInt();
|
||||
int HEXColor = buffer.readInt();
|
||||
int HEXColor2 = buffer.readInt();
|
||||
float colorRate = buffer.readFloat();
|
||||
int colorRateStart = buffer.readInt();
|
||||
|
||||
int amount = buffer.readInt();
|
||||
int maxAge = buffer.readInt();
|
||||
|
||||
@@ -136,7 +140,8 @@ public class NoppesUtil {
|
||||
|
||||
CustomFX fx = new CustomFX(
|
||||
worldObj, entity,
|
||||
directory, HEXcolor,
|
||||
directory,
|
||||
HEXColor,HEXColor2,colorRate,colorRateStart,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
|
||||
@@ -70,11 +70,18 @@ public class CustomFX extends EntityFX {
|
||||
private int animPosX;
|
||||
private int animPosY;
|
||||
|
||||
public int HEXColor = 0xFFFFFF;
|
||||
public int HEXColor2 = 0xFFFFFF;
|
||||
public float HEXColorRate = 0.0F;
|
||||
public int HEXColorStart = 0;
|
||||
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private boolean isUrl = false;
|
||||
private boolean gotWidthHeight = false;
|
||||
|
||||
public CustomFX(World worldObj, Entity entity, String directory, int HEXColor, double x, double y, double z,
|
||||
public CustomFX(World worldObj, Entity entity, String directory,
|
||||
int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart,
|
||||
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,
|
||||
@@ -86,6 +93,14 @@ public class CustomFX extends EntityFX {
|
||||
) {
|
||||
super(worldObj, x, y, z, motionX, motionY, motionZ);
|
||||
|
||||
this.HEXColor = HEXColor;
|
||||
this.HEXColor2 = HEXColor2;
|
||||
this.HEXColorRate = HEXColorRate;
|
||||
this.HEXColorStart = HEXColorStart;
|
||||
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||
particleBlue = (HEXColor & 255) / 255f;
|
||||
|
||||
this.scale1 = scale1;
|
||||
this.scale2 = scale2;
|
||||
this.scaleRate = Math.abs(scaleRate);
|
||||
@@ -136,10 +151,6 @@ public class CustomFX extends EntityFX {
|
||||
this.entity = entity;
|
||||
noClip = true;
|
||||
|
||||
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||
particleBlue = (HEXColor & 255) / 255f;
|
||||
|
||||
location = new ResourceLocation(directory);
|
||||
|
||||
this.width = width;
|
||||
@@ -196,6 +207,13 @@ public class CustomFX extends EntityFX {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
particleRed = (HEXColor >> 16 & 255) / 255f;
|
||||
particleGreen = (HEXColor >> 8 & 255) / 255f;
|
||||
particleBlue = (HEXColor & 255) / 255f;
|
||||
|
||||
if(timeSinceStart >= HEXColorStart)
|
||||
HEXColor = lerpColor(HEXColor, HEXColor2, HEXColorRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,31 +235,31 @@ public class CustomFX extends EntityFX {
|
||||
float scaleChange = this.scaleRate / (float)particleMaxAge;
|
||||
if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2))
|
||||
particleScale = this.scale2;
|
||||
else if(particleAge >= this.scaleRateStart)
|
||||
else if(timeSinceStart >= this.scaleRateStart)
|
||||
particleScale += scaleChange;
|
||||
|
||||
float alphaChange = this.alphaRate / (float)particleMaxAge;
|
||||
if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2))
|
||||
particleAlpha = this.alpha2;
|
||||
else if(particleAge >= this.alphaRateStart)
|
||||
else if(timeSinceStart >= this.alphaRateStart)
|
||||
particleAlpha += alphaChange;
|
||||
|
||||
float rotationXChange = this.rotationXRate / (float)particleMaxAge;
|
||||
if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2))
|
||||
rotationX = this.rotationX2;
|
||||
else if(particleAge >= this.rotationXRateStart)
|
||||
else if(timeSinceStart >= this.rotationXRateStart)
|
||||
rotationX += rotationXChange;
|
||||
|
||||
float rotationYChange = this.rotationYRate / (float)particleMaxAge;
|
||||
if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2))
|
||||
rotationY = this.rotationY2;
|
||||
else if(particleAge >= this.rotationYRateStart)
|
||||
else if(timeSinceStart >= this.rotationYRateStart)
|
||||
rotationY += rotationYChange;
|
||||
|
||||
float rotationZChange = this.rotationZRate / (float)particleMaxAge;
|
||||
if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2))
|
||||
rotationZ = this.rotationZ2;
|
||||
else if(particleAge >= this.rotationZRateStart)
|
||||
else if(timeSinceStart >= this.rotationZRateStart)
|
||||
rotationZ += rotationZChange;
|
||||
|
||||
renderParticleSide(true, tessellator, partialTick);
|
||||
@@ -325,6 +343,22 @@ public class CustomFX extends EntityFX {
|
||||
this.width = width < 0 ? totalWidth : width;
|
||||
this.height = height < 0 ? totalHeight : height;
|
||||
}
|
||||
|
||||
public int lerpColor(int from, int to, float ratio) {
|
||||
float ar = (from & 0xFF0000) >> 16;
|
||||
float ag = (from & 0x00FF00) >> 8;
|
||||
float ab = (from & 0x0000FF);
|
||||
|
||||
float br = (to & 0xFF0000) >> 16;
|
||||
float bg = (to & 0x00FF00) >> 8;
|
||||
float bb = (to & 0x0000FF);
|
||||
|
||||
float rr = ar + ratio * (br - ar);
|
||||
float rg = ag + ratio * (bg - ag);
|
||||
float rb = ab + ratio * (bb - ab);
|
||||
|
||||
return (int)(((int)rr << 16) + ((int)rg << 8) + (rb));
|
||||
}
|
||||
|
||||
public int getFXLayer(){
|
||||
return 0;
|
||||
|
||||
@@ -8,7 +8,12 @@ import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
*/
|
||||
public class ScriptParticle {
|
||||
private String directory;
|
||||
private int HEXcolor = 0xFFFFFF;
|
||||
|
||||
private int HEXColor = 0xFFFFFF;
|
||||
private int HEXColor2 = 0xFFFFFF;
|
||||
private float HEXColorRate = 0.0f;
|
||||
private int HEXColorStart = 0;
|
||||
|
||||
private int amount = 1;
|
||||
private int maxAge = 20;
|
||||
private double x = 0,y = 0,z = 0;
|
||||
@@ -48,7 +53,9 @@ public class ScriptParticle {
|
||||
|
||||
public void spawnOnEntity(ScriptEntity entity){
|
||||
int entityID = entity.getMCEntity().getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXColor, HEXColor2, HEXColorRate, HEXColorStart,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -63,7 +70,9 @@ public class ScriptParticle {
|
||||
}
|
||||
|
||||
public void spawnInWorld(ScriptWorld world){
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXColor, HEXColor2, HEXColorRate, HEXColorStart,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -78,7 +87,9 @@ public class ScriptParticle {
|
||||
}
|
||||
|
||||
public void spawnInWorld(ScriptWorld world, double x, double y, double z){
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXColor, HEXColor2, HEXColorRate, HEXColorStart,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -128,8 +139,41 @@ public class ScriptParticle {
|
||||
return directory;
|
||||
}
|
||||
|
||||
public int getHEXcolor() {
|
||||
return HEXcolor;
|
||||
public void setHEXColor(int HEXColor) {
|
||||
this.HEXColor = HEXColor;
|
||||
}
|
||||
public int getHEXColor() {
|
||||
return HEXColor;
|
||||
}
|
||||
public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) {
|
||||
this.HEXColor = HEXColor;
|
||||
this.HEXColor2 = HEXColor2;
|
||||
this.HEXColorRate = HEXColorRate;
|
||||
this.HEXColorStart = HEXColorStart;
|
||||
}
|
||||
public int getHEXColor1() {
|
||||
return HEXColor;
|
||||
}
|
||||
public int getHEXColor2() {
|
||||
return HEXColor2;
|
||||
}
|
||||
public float getHEXColorRate() {
|
||||
return HEXColorRate;
|
||||
}
|
||||
public int getHEXColorStart() {
|
||||
return HEXColorStart;
|
||||
}
|
||||
public void setHEXColor1(int HEXColor) {
|
||||
this.HEXColor = HEXColor;
|
||||
}
|
||||
public void setHEXColor2(int HEXColor2) {
|
||||
this.HEXColor2 = HEXColor2;
|
||||
}
|
||||
public void setHEXColorRate(float HEXColorRate) {
|
||||
this.HEXColorRate = HEXColorRate;
|
||||
}
|
||||
public void setHEXColorStart(int HEXColorStart) {
|
||||
this.HEXColorStart = HEXColorStart;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
@@ -208,10 +252,6 @@ public class ScriptParticle {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
public void setHEXColor(int HEXcolor) {
|
||||
this.HEXcolor = HEXcolor;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@@ -333,22 +333,11 @@ public class ScriptWorld implements IWorld {
|
||||
* @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/bubble.png"
|
||||
* @return Returns ScriptParticle object
|
||||
*/
|
||||
@Deprecated
|
||||
public ScriptParticle createEntityParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
public ScriptParticle createParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
public void spawnParticle(ScriptParticle particle){
|
||||
particle.spawnInWorld(this);
|
||||
}
|
||||
|
||||
public void spawnParticle(ScriptParticle particle, double x, double y, double z){
|
||||
particle.spawnInWorld(this,x,y,z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key Get temp data for this key
|
||||
* @return Returns the stored temp data
|
||||
|
||||
@@ -62,6 +62,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
* @param scaleRate Multiplier for the particle's transparency growth rate
|
||||
* @param alphaRateStart The time at which the particle begins appearing/fading
|
||||
*/
|
||||
@Deprecated
|
||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
@@ -73,7 +74,9 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -86,6 +89,8 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID, entity.dimension
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity,
|
||||
@@ -93,7 +98,9 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
float alpha1, float alpha2, float alphaRate, int alphaRateStart
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -106,13 +113,17 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID, entity.dimension
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public 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
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
scale1, scale2, scaleRate, scaleRateStart,
|
||||
@@ -125,12 +136,16 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID, entity.dimension
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float gravity
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
motionX, motionY, motionZ, gravity,
|
||||
0, 0, 0, 0,
|
||||
@@ -143,11 +158,15 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID, entity.dimension
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge,
|
||||
double x, double y, double z
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
x, y, z,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
@@ -160,10 +179,14 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
entityID, entity.dimension
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge
|
||||
) {
|
||||
int entityID = entity.getEntityId();
|
||||
NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge,
|
||||
NoppesUtilServer.spawnScriptedParticle(directory,
|
||||
HEXcolor, HEXcolor, 0, 0,
|
||||
amount, maxAge,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
|
||||
@@ -287,6 +287,7 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ScriptParticle createEntityParticle(String directory){
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user