diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/GroundMistEffect.java b/src/main/java/com/vinlanx/explosionoverhaul/client/GroundMistEffect.java index e78245e..e1d4841 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/GroundMistEffect.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/GroundMistEffect.java @@ -1,145 +1,15 @@ -/* - * Decompiled with CFR 0.152. - */ package com.vinlanx.explosionoverhaul.client; -import com.vinlanx.explosionoverhaul.Config; -import com.vinlanx.explosionoverhaul.SmokeParticleOptions; -import java.awt.Color; -import java.util.Random; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.util.Mth; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; public class GroundMistEffect { - private final ClientLevel level; - private final Vec3 initialPosition; - private final float power; - private final Random random = new Random(); - private int age = 0; - private final int maxAge; - private final float maxRadius; - private final float particleBaseSize; - private final int particlesPerTick; - private Color currentMistColor = new Color(255, 255, 255); - private boolean finished = false; - private final int raycastFrequency; - public GroundMistEffect(Vec3 position, float power) { - this.level = Minecraft.getInstance().f_91073_; - this.initialPosition = position; - this.power = power; - double qualityMultiplier = (Double)Config.CLIENT.groundMistQuality.get(); - this.raycastFrequency = (Integer)Config.CLIENT.groundMistRaycastFrequency.get(); - float powerFraction = Mth.m_14036_((float)(power / 100.0f), (float)0.0f, (float)1.0f); - int calculatedParticles = (int)((double)Mth.m_14179_((float)powerFraction, (float)40.0f, (float)200.0f) * qualityMultiplier * 1.5); - int calculatedMaxAge = (int)((double)Mth.m_14179_((float)powerFraction, (float)30.0f, (float)70.0f) * qualityMultiplier / 3.0); - if (qualityMultiplier > 0.0) { - if (calculatedParticles == 0) { - calculatedParticles = 1; - } - if (calculatedMaxAge == 0) { - calculatedMaxAge = 1; - } - } - this.particlesPerTick = calculatedParticles; - this.maxAge = calculatedMaxAge; - this.maxRadius = power * this.calculateRadiusMultiplier(power) * 3.0f; - this.particleBaseSize = Mth.m_14179_((float)powerFraction, (float)1.0f, (float)12.0f); - } - - private float calculateRadiusMultiplier(float power) { - if (power <= 5.0f) { - return 2.0f; - } - if (power <= 40.0f) { - return Mth.m_14179_((float)((power - 5.0f) / 35.0f), (float)2.0f, (float)4.0f); - } - if (power <= 80.0f) { - return Mth.m_14179_((float)((power - 40.0f) / 40.0f), (float)4.0f, (float)5.0f); - } - if (power <= 100.0f) { - return Mth.m_14179_((float)((power - 80.0f) / 20.0f), (float)5.0f, (float)7.0f); - } - return 7.0f; } public void tick() { - double checkZ; - double checkAngle; - double checkX; - BlockHitResult hitResult; - if (this.finished || this.level == null) { - return; - } - ++this.age; - if (this.age > this.maxAge) { - this.finished = true; - return; - } - float progress = (float)this.age / (float)this.maxAge; - float easedProgress = 1.0f - (float)Math.pow(1.0f - progress, 3.0); - float currentRadius = this.maxRadius * easedProgress; - if (this.age % 10 == 0 && (hitResult = this.level.m_45547_(new ClipContext(new Vec3(checkX = this.initialPosition.f_82479_ + Math.cos(checkAngle = this.random.nextDouble() * 2.0 * Math.PI) * (double)currentRadius, this.initialPosition.f_82480_ + 15.0, checkZ = this.initialPosition.f_82481_ + Math.sin(checkAngle) * (double)currentRadius), new Vec3(checkX, this.initialPosition.f_82480_ - 15.0, checkZ), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null))).m_6662_() == HitResult.Type.BLOCK) { - BlockPos blockPos = hitResult.m_82425_(); - BlockState blockState = this.level.m_8055_(blockPos); - } - double cachedY = this.initialPosition.f_82480_; - for (int i = 0; i < this.particlesPerTick; ++i) { - float scale; - float a; - float r; - float g; - float b; - double angle = (double)i / (double)this.particlesPerTick * 2.0 * Math.PI + (this.random.nextDouble() - 0.5) * 0.1; - double radiusFrac = this.random.nextDouble(); - double spawnRadius = (double)currentRadius * (0.6 + radiusFrac * 0.4); - double spawnX = this.initialPosition.f_82479_ + Math.cos(angle) * spawnRadius; - double spawnZ = this.initialPosition.f_82481_ + Math.sin(angle) * spawnRadius; - if (i % this.raycastFrequency == 0) { - BlockHitResult hitResult2 = this.level.m_45547_(new ClipContext(new Vec3(spawnX, this.initialPosition.f_82480_ + 15.0, spawnZ), new Vec3(spawnX, this.initialPosition.f_82480_ - 15.0, spawnZ), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)); - if (hitResult2.m_6662_() != HitResult.Type.BLOCK) continue; - cachedY = hitResult2.m_82450_().f_82480_; - } - double spawnY = cachedY; - Vec3 direction = new Vec3(spawnX - this.initialPosition.f_82479_, 0.0, spawnZ - this.initialPosition.f_82481_).m_82541_(); - double motionStrength = Mth.m_14179_((float)(1.0f - progress), (float)0.02f, (float)0.15f); - double motionX = direction.f_82479_ * motionStrength + (this.random.nextDouble() - 0.5) * 0.02; - double motionZ = direction.f_82481_ * motionStrength + (this.random.nextDouble() - 0.5) * 0.02; - double motionY = -0.01 - this.random.nextDouble() * 0.02; - int lifetime = 100 + this.random.nextInt(60); - if (radiusFrac <= 0.2) { - b = 0.8f; - g = 0.8f; - r = 0.8f; - a = 0.3f; - scale = this.particleBaseSize * 0.1667f; - } else if (radiusFrac <= 0.65) { - b = 0.9f; - g = 0.9f; - r = 0.9f; - a = 0.2f; - scale = this.particleBaseSize * 0.25f; - } else { - r = (float)this.currentMistColor.getRed() / 255.0f; - g = (float)this.currentMistColor.getGreen() / 255.0f; - b = (float)this.currentMistColor.getBlue() / 255.0f; - a = 0.15f; - scale = this.particleBaseSize * 0.333f; - } - SmokeParticleOptions options = new SmokeParticleOptions(scale * (0.8f + this.random.nextFloat() * 0.4f), lifetime, r, g, b, a, false, 0.0f, 0.0f, null); - this.level.m_6493_((ParticleOptions)options, true, spawnX, spawnY + 0.05, spawnZ, motionX, motionY, motionZ); - } } public boolean isFinished() { - return this.finished; + return true; } } diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/PlasmaParticle.java b/src/main/java/com/vinlanx/explosionoverhaul/client/PlasmaParticle.java index 73063f5..00ddedd 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/PlasmaParticle.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/PlasmaParticle.java @@ -1,116 +1,35 @@ -/* - * Decompiled with CFR 0.152. - */ package com.vinlanx.explosionoverhaul.client; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.vinlanx.explosionoverhaul.Config; import com.vinlanx.explosionoverhaul.PlasmaParticleOptions; -import com.vinlanx.explosionoverhaul.SmokeParticleOptions; -import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.TextureSheetParticle; -import net.minecraft.core.particles.ParticleOptions; -import net.minecraft.util.Mth; -import net.minecraft.world.phys.Vec3; -import org.joml.Quaternionf; -import org.joml.Quaternionfc; -import org.joml.Vector3f; -public class PlasmaParticle -extends TextureSheetParticle { - private final SpriteSet sprites; - private final float initialQuadSize; - - protected PlasmaParticle(ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed, PlasmaParticleOptions options, SpriteSet pSpriteSet) { - super(pLevel, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed); - this.sprites = pSpriteSet; - this.f_172258_ = 0.96f; - this.f_107226_ = 0.2f; - this.f_107215_ = pXSpeed; - this.f_107216_ = pYSpeed; - this.f_107217_ = pZSpeed; - float power = options.getPower(); - float powerFraction = Mth.m_14036_((float)(power / 100.0f), (float)0.0f, (float)1.0f); - this.f_107663_ = this.initialQuadSize = Mth.m_14179_((float)powerFraction, (float)0.4f, (float)2.5f); - this.f_107225_ = 200 + this.f_107223_.m_188503_(40) - 20; - this.f_107227_ = 0.8f; - this.f_107228_ = 0.8f; - this.f_107229_ = 0.8f; - this.m_108335_(pSpriteSet); +public class PlasmaParticle extends TextureSheetParticle { + protected PlasmaParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, PlasmaParticleOptions options, SpriteSet sprites) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.lifetime = 1; + this.pickSprite(sprites); } - public ParticleRenderType m_7556_() { - return ParticleRenderType.f_107431_; + @Override + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; } - public int m_6355_(float pPartialTick) { - return 240; - } - - public void m_5744_(VertexConsumer pBuffer, Camera pRenderInfo, float pPartialTicks) { - RenderSystem.disableDepthTest(); - Vec3 vec3 = pRenderInfo.m_90583_(); - float f = (float)(Mth.m_14139_((double)pPartialTicks, (double)this.f_107209_, (double)this.f_107212_) - vec3.m_7096_()); - float f1 = (float)(Mth.m_14139_((double)pPartialTicks, (double)this.f_107210_, (double)this.f_107213_) - vec3.m_7098_()); - float f2 = (float)(Mth.m_14139_((double)pPartialTicks, (double)this.f_107211_, (double)this.f_107214_) - vec3.m_7094_()); - Quaternionf quaternion = new Quaternionf((Quaternionfc)pRenderInfo.m_253121_()); - if (this.f_107231_ != 0.0f) { - float f3 = Mth.m_14179_((float)pPartialTicks, (float)this.f_107204_, (float)this.f_107231_); - quaternion.rotateZ(f3); - } - Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0f, -1.0f, 0.0f), new Vector3f(-1.0f, 1.0f, 0.0f), new Vector3f(1.0f, 1.0f, 0.0f), new Vector3f(1.0f, -1.0f, 0.0f)}; - float f4 = this.m_5902_(pPartialTicks); - for (int i = 0; i < 4; ++i) { - Vector3f vector3f = avector3f[i]; - vector3f.rotate((Quaternionfc)quaternion); - vector3f.mul(f4); - vector3f.add(f, f1, f2); - } - float f7 = this.m_5970_(); - float f8 = this.m_5952_(); - float f5 = this.m_5951_(); - float f6 = this.m_5950_(); - int j = this.m_6355_(pPartialTicks); - pBuffer.m_5483_((double)avector3f[0].x(), (double)avector3f[0].y(), (double)avector3f[0].z()).m_7421_(f8, f6).m_85950_(this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_).m_85969_(j).m_5752_(); - pBuffer.m_5483_((double)avector3f[1].x(), (double)avector3f[1].y(), (double)avector3f[1].z()).m_7421_(f8, f5).m_85950_(this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_).m_85969_(j).m_5752_(); - pBuffer.m_5483_((double)avector3f[2].x(), (double)avector3f[2].y(), (double)avector3f[2].z()).m_7421_(f7, f5).m_85950_(this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_).m_85969_(j).m_5752_(); - pBuffer.m_5483_((double)avector3f[3].x(), (double)avector3f[3].y(), (double)avector3f[3].z()).m_7421_(f7, f6).m_85950_(this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_).m_85969_(j).m_5752_(); - RenderSystem.enableDepthTest(); - } - - public void m_5989_() { - super.m_5989_(); - this.m_108339_(this.sprites); - if (!this.f_107220_) { - float lifeProgress = (float)this.f_107224_ / (float)this.f_107225_; - float flicker = 1.0f - this.f_107223_.m_188501_() * 0.3f; - this.f_107230_ = Mth.m_14036_((float)(flicker * (1.0f - lifeProgress * lifeProgress)), (float)0.0f, (float)1.0f); - this.f_107663_ = this.initialQuadSize * (0.9f + this.f_107223_.m_188501_() * 0.2f); - if (((Boolean)Config.CLIENT.enablePlasmaSmokeTrail.get()).booleanValue() && this.f_107224_ > 2 && (double)this.f_107223_.m_188501_() < (Double)Config.CLIENT.plasmaSmokeFrequency.get()) { - int smokeCount = (Integer)Config.CLIENT.plasmaSmokeCount.get(); - for (int i = 0; i < smokeCount; ++i) { - this.f_107208_.m_7106_((ParticleOptions)new SmokeParticleOptions(0.5f, 200, 0.6f, 0.6f, 0.6f, 0.4f, false, 0.0f, 0.0f, null), this.f_107212_, this.f_107213_, this.f_107214_, (this.f_107223_.m_188500_() - 0.5) * 0.03, (this.f_107223_.m_188500_() - 0.5) * 0.03, (this.f_107223_.m_188500_() - 0.5) * 0.03); - } - } - } - } - - public static class Provider - implements ParticleProvider { + public static class Provider implements ParticleProvider { private final SpriteSet sprites; - public Provider(SpriteSet pSprites) { - this.sprites = pSprites; + public Provider(SpriteSet sprites) { + this.sprites = sprites; } - public Particle createParticle(PlasmaParticleOptions pType, ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed) { - return new PlasmaParticle(pLevel, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed, pType, this.sprites); + @Override + public Particle createParticle(PlasmaParticleOptions type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { + return new PlasmaParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, type, this.sprites); } } }