From f3f209820c5063e68c8d95d4aa68f3c4d4407d75 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 2 Jul 2022 03:10:11 -0500 Subject: [PATCH] IParticle: -Added glow option. --- .../java/noppes/npcs/NoppesUtilServer.java | 4 +- .../java/noppes/npcs/client/NoppesUtil.java | 3 +- .../java/noppes/npcs/client/fx/CustomFX.java | 40 ++++++++++++++++++- .../noppes/npcs/scripted/ScriptParticle.java | 10 +++-- .../npcs/scripted/entity/ScriptEntity.java | 12 +++--- .../npcs/scripted/interfaces/IParticle.java | 7 ++++ 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 363d31516..6dbb9c3d5 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -325,7 +325,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 width, int height, int offsetX, int offsetY, + boolean facePlayer, boolean glows, int width, int height, int offsetX, int offsetY, int animRate, boolean animLoop, int animStart, int animEnd, int entityID, int dimensionID ){ @@ -340,7 +340,7 @@ public class NoppesUtilServer { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, + facePlayer, glows, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, entityID, dimensionID ); diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 46ccab73a..47bf01af2 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -131,6 +131,7 @@ public class NoppesUtil { int rotationZRateStart = buffer.readInt(); boolean facePlayer = buffer.readBoolean(); + boolean glows = buffer.readBoolean(); int width = buffer.readInt(); int height = buffer.readInt(); @@ -162,7 +163,7 @@ public class NoppesUtil { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - maxAge, facePlayer, + maxAge, facePlayer, glows, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd ); diff --git a/src/main/java/noppes/npcs/client/fx/CustomFX.java b/src/main/java/noppes/npcs/client/fx/CustomFX.java index 941da61a9..fa159a89d 100644 --- a/src/main/java/noppes/npcs/client/fx/CustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/CustomFX.java @@ -1,7 +1,11 @@ package noppes.npcs.client.fx; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; @@ -11,7 +15,9 @@ import net.minecraft.client.resources.SkinManager; import net.minecraft.client.resources.data.TextureMetadataSection; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; @@ -58,6 +64,7 @@ public class CustomFX extends EntityFX { public int rotationZRateStart = 0; public boolean facePlayer = true; + public boolean glows = true; private int totalWidth, totalHeight; public int width, height; @@ -79,6 +86,8 @@ public class CustomFX extends EntityFX { private boolean isUrl = false; private boolean gotWidthHeight = false; + double renderPosX, renderPosY, renderPosZ; + public CustomFX(World worldObj, Entity entity, String directory, int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart, double x, double y, double z, @@ -88,7 +97,7 @@ public class CustomFX 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, boolean facePlayer, int width, int height, int offsetX, int offsetY, + int age, boolean facePlayer, boolean glows, int width, int height, int offsetX, int offsetY, int animRate, boolean animLoop, int animStart, int animEnd ) { super(worldObj, x, y, z, motionX, motionY, motionZ); @@ -179,6 +188,7 @@ public class CustomFX extends EntityFX { } this.facePlayer = facePlayer; + this.glows = glows; } @Override @@ -283,6 +293,10 @@ public class CustomFX extends EntityFX { float posZ = (float)((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ; GL11.glPushMatrix(); + renderPosX = startX + posX + this.posX; + renderPosY = startY + posY + this.posY; + renderPosZ = startZ + posZ + this.posZ; + GL11.glTranslated(posX,posY,posZ); GL11.glScalef(renderScale, renderScale, renderScale); if(facePlayer) { @@ -299,7 +313,11 @@ public class CustomFX extends EntityFX { } tessellator.startDrawingQuads(); - tessellator.setBrightness(240); + if (!this.glows) { + tessellator.setBrightness(this.getBrightnessForRender(partialTick)); + } else { + tessellator.setBrightness(240); + } tessellator.setColorOpaque_F(1, 1, 1); tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); tessellator.addVertexWithUV( (u2-u1)/2, 0, (v2-v1)/2, u2, v2); @@ -310,6 +328,24 @@ public class CustomFX extends EntityFX { GL11.glPopMatrix(); } + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) + { + int i = MathHelper.floor_double(renderPosX); + int j = MathHelper.floor_double(renderPosZ); + + if (this.worldObj.blockExists(i, 0, j)) + { + double d0 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D; + int k = MathHelper.floor_double(renderPosY - (double)this.yOffset + d0); + return this.worldObj.getLightBrightnessForSkyBlocks(i, k, j, 0); + } + else + { + return 0; + } + } + public void getWidthHeight() throws IOException { InputStream inputstream = null; diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 2d8481c6c..ec2e9edf2 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -44,6 +44,7 @@ public class ScriptParticle implements IParticle { public int animStart = 0, animEnd = -1; public boolean facePlayer = true; + public boolean glows = true; public ScriptParticle(String directory){ this.directory = directory; @@ -61,7 +62,7 @@ public class ScriptParticle implements IParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, + facePlayer, glows, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, entityID, entity.getWorld().getDimensionID() ); @@ -78,7 +79,7 @@ public class ScriptParticle implements IParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, + facePlayer, glows, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, -1, world.getDimensionID() ); @@ -95,12 +96,15 @@ public class ScriptParticle implements IParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, + facePlayer, glows, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, -1, world.getDimensionID() ); } + public void setGlows(boolean glows) { this.glows = glows; } + public boolean getGlows() { return this.glows; } + public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } public boolean getFacePlayer() { return facePlayer; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 72e94f68c..8c6de080d 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -90,7 +90,7 @@ public class ScriptEntity implements IEntity { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); @@ -114,7 +114,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); @@ -137,7 +137,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); @@ -159,7 +159,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); @@ -180,7 +180,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); @@ -200,7 +200,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0, + true, true, -1, -1, 0,0, 0, true, 0, 0, entityID, entity.dimension ); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java index ba718d2f3..c8d0fca03 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -42,6 +42,13 @@ public interface IParticle { */ void spawnInWorld(ScriptWorld world, double x, double y, double z); + /** + * + * @param glows If true, this particle ignores all lighting and always renders with full brightness. + */ + void setGlows(boolean glows); + boolean getGlows(); + /** * * @param facePlayer Whether the particle is always facing the player's camera. If this is disabled, the particle will appear to be laying flat face down on the ground if its rotation is unchanged.