diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/CustomGlowParticle.java b/src/main/java/com/vinlanx/explosionoverhaul/client/CustomGlowParticle.java index d0fd491..5a67dce 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/CustomGlowParticle.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/CustomGlowParticle.java @@ -1,346 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package com.vinlanx.explosionoverhaul.client; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.vinlanx.explosionoverhaul.Config; import com.vinlanx.explosionoverhaul.CustomGlowParticleOptions; -import com.vinlanx.explosionoverhaul.client.ExplosionTextureManager; -import com.vinlanx.explosionoverhaul.client.ExplosionWindController; -import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.TextureSheetParticle; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.resources.ResourceLocation; -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 CustomGlowParticle -extends TextureSheetParticle { - private final float power; - private final float initialQuadSize; - private final int animationDuration; - private final int animationType; - private final float centerY; - private final float maxRadius; - private float currentHeightPercent; - private final int peakFireEndTick; - private final int fireTransitionEndTick; - private final int smokeStartTick; - private static final int GLOW_FRAME_COUNT = 239; - private static final int SGLOW_FRAME_COUNT = 224; - private static final int FRAMES_PER_SHEET = 64; - private static final int FRAMES_PER_ROW = 8; - private int baseSheetIndex; - private int baseFrameOnSheet; - private int emissiveSheetIndex; - private int emissiveFrameOnSheet; - - public CustomGlowParticle(ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed, CustomGlowParticleOptions options) { - super(pLevel, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed); - int fadeOutDurationTicks; - this.f_172258_ = 0.98f; - this.f_107226_ = 0.0f; - this.f_107215_ = pXSpeed; - this.f_107216_ = pYSpeed; - this.f_107217_ = pZSpeed; - this.power = options.getPower(); - this.initialQuadSize = options.getScale(); - this.animationType = options.getAnimationType(); - this.f_107663_ = this.initialQuadSize; - this.centerY = options.getCenterY(); - this.maxRadius = options.getMaxRadius(); - this.currentHeightPercent = options.getHeightPercent(); - if (this.power <= 1.0f) { - this.animationDuration = 40; - fadeOutDurationTicks = 40; - } else if (this.power <= 10.0f) { - this.animationDuration = this.interpolate(this.power, 1.0f, 40.0f, 10.0f, 100.0f); - fadeOutDurationTicks = this.interpolate(this.power, 1.0f, 40.0f, 10.0f, 60.0f); - } else if (this.power <= 60.0f) { - this.animationDuration = this.interpolate(this.power, 10.0f, 100.0f, 60.0f, 140.0f); - fadeOutDurationTicks = this.interpolate(this.power, 10.0f, 60.0f, 60.0f, 80.0f); - } else if (this.power <= 100.0f) { - this.animationDuration = this.interpolate(this.power, 60.0f, 140.0f, 100.0f, 200.0f); - fadeOutDurationTicks = this.interpolate(this.power, 60.0f, 80.0f, 100.0f, 120.0f); - } else { - this.animationDuration = 200; - fadeOutDurationTicks = 120; - } - this.f_107225_ = this.animationDuration + fadeOutDurationTicks; - float powerFraction = Mth.m_14036_((float)(this.power / 100.0f), (float)0.0f, (float)1.0f); - float totalFirePercent = Mth.m_14179_((float)powerFraction, (float)0.02f, (float)0.2f); - float cooldownToSmokePercent = Mth.m_14179_((float)powerFraction, (float)0.04f, (float)0.08f); - int totalFireDuration = (int)((float)this.f_107225_ * totalFirePercent); - this.peakFireEndTick = (int)((float)totalFireDuration * 0.9f); - this.fireTransitionEndTick = totalFireDuration; - int cooldownDuration = (int)((float)this.f_107225_ * cooldownToSmokePercent); - this.smokeStartTick = this.fireTransitionEndTick + cooldownDuration; - if (Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.VANILA) { - this.f_107230_ = 1.0f; - this.f_107227_ = 1.0f; - this.f_107228_ = 0.85f; - this.f_107229_ = 0.5f; - } +public class CustomGlowParticle extends TextureSheetParticle { + public CustomGlowParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, CustomGlowParticleOptions options) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.lifetime = 1; } - public void m_5989_() { - double targetSpeed; - this.f_107209_ = this.f_107212_; - this.f_107210_ = this.f_107213_; - this.f_107211_ = this.f_107214_; - if (this.f_107224_++ >= this.f_107225_) { - this.m_107274_(); - return; - } - if (Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.VANILA) { - this.tickVanila(); - } else if (Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.REALISTIC_2) { - this.tickRealistic2(); - } else { - this.tickRealistic(); - } - this.m_6257_(this.f_107215_, this.f_107216_, this.f_107217_); - this.f_107215_ *= (double)this.f_172258_; - this.f_107216_ *= (double)this.f_172258_; - this.f_107217_ *= (double)this.f_172258_; - float heightPercent = this.updateHeightPercent(); - Vec3 direction = ExplosionWindController.getWindDirection(); - if (direction != Vec3.f_82478_ && (targetSpeed = ExplosionWindController.computeGlowSpeed(heightPercent)) > 0.0) { - double targetX = direction.f_82479_ * targetSpeed; - double targetZ = direction.f_82481_ * targetSpeed; - this.f_107215_ += (targetX - this.f_107215_) * 0.1; - this.f_107217_ += (targetZ - this.f_107217_) * 0.1; - } - } - - private void tickVanila() { - this.baseSheetIndex = 0; - this.f_107663_ = this.initialQuadSize; - if (this.f_107224_ < this.peakFireEndTick) { - this.f_107230_ = 1.0f; - this.f_107227_ = 1.0f; - this.f_107228_ = 0.85f; - this.f_107229_ = 0.5f; - } else if (this.f_107224_ < this.fireTransitionEndTick) { - float progress = (float)(this.f_107224_ - this.peakFireEndTick) / (float)(this.fireTransitionEndTick - this.peakFireEndTick); - this.f_107230_ = 1.0f; - this.f_107227_ = 1.0f; - this.f_107228_ = Mth.m_14179_((float)progress, (float)0.85f, (float)0.5f); - this.f_107229_ = Mth.m_14179_((float)progress, (float)0.5f, (float)0.1f); - } else if (this.f_107224_ < this.smokeStartTick) { - float progress = (float)(this.f_107224_ - this.fireTransitionEndTick) / (float)(this.smokeStartTick - this.fireTransitionEndTick); - float smokeCol = 0.15f; - this.f_107227_ = Mth.m_14179_((float)progress, (float)1.0f, (float)(smokeCol + 0.1f)); - this.f_107228_ = Mth.m_14179_((float)progress, (float)0.5f, (float)smokeCol); - this.f_107229_ = Mth.m_14179_((float)progress, (float)0.1f, (float)smokeCol); - this.f_107230_ = Mth.m_14179_((float)progress, (float)1.0f, (float)0.9f); - } else { - float progress = (float)(this.f_107224_ - this.smokeStartTick) / (float)(this.f_107225_ - this.smokeStartTick); - float finalSmokeCol = 0.05f; - this.f_107228_ = this.f_107229_ = Mth.m_14179_((float)progress, (float)0.15f, (float)finalSmokeCol); - this.f_107227_ = this.f_107229_; - this.f_107230_ = 0.9f * (1.0f - progress * progress * progress); - } - } - - private void tickRealistic2() { - int frameIndex; - int emissiveSheetStart; - int baseSheetStart; - int frameCountForAnim; - this.f_107663_ = this.initialQuadSize * 2.0f; - if (this.animationType == 2) { - frameCountForAnim = 224; - baseSheetStart = 18; - emissiveSheetStart = 22; - } else if (this.animationType == 1) { - frameCountForAnim = 239; - baseSheetStart = 10; - emissiveSheetStart = 14; - } else { - frameCountForAnim = 239; - baseSheetStart = 2; - emissiveSheetStart = 6; - } - if (this.f_107224_ < this.animationDuration) { - float animProgress = (float)this.f_107224_ / (float)this.animationDuration; - float easedProgress = 1.0f - (float)Math.pow(1.0f - animProgress, 3.0); - frameIndex = (int)(easedProgress * (float)(frameCountForAnim - 1)); - this.f_107230_ = 1.0f; - } else { - frameIndex = frameCountForAnim - 1; - int fadeDuration = this.f_107225_ - this.animationDuration; - int ageInFade = this.f_107224_ - this.animationDuration; - this.f_107230_ = 1.0f - (float)ageInFade / (float)fadeDuration; - } - frameIndex = Mth.m_14045_((int)frameIndex, (int)0, (int)(frameCountForAnim - 1)); - this.baseSheetIndex = baseSheetStart + frameIndex / 64; - this.baseFrameOnSheet = frameIndex % 64; - this.emissiveSheetIndex = emissiveSheetStart + frameIndex / 64; - this.emissiveFrameOnSheet = frameIndex % 64; - } - - private void tickRealistic() { - int frameIndex; - int emissiveSheetStart; - int baseSheetStart; - int frameCountForAnim; - if (this.animationType == 2) { - frameCountForAnim = 224; - baseSheetStart = 18; - emissiveSheetStart = 22; - } else if (this.animationType == 1) { - frameCountForAnim = 239; - baseSheetStart = 10; - emissiveSheetStart = 14; - } else { - frameCountForAnim = 239; - baseSheetStart = 2; - emissiveSheetStart = 6; - } - if (this.f_107224_ < this.animationDuration) { - float animProgress = (float)this.f_107224_ / (float)this.animationDuration; - float easedProgress = 1.0f - (float)Math.pow(1.0f - animProgress, 3.0); - frameIndex = (int)(easedProgress * (float)(frameCountForAnim - 1)); - this.f_107230_ = 1.0f; - } else { - frameIndex = frameCountForAnim - 1; - int fadeDuration = this.f_107225_ - this.animationDuration; - int ageInFade = this.f_107224_ - this.animationDuration; - this.f_107230_ = 1.0f - (float)ageInFade / (float)fadeDuration; - } - frameIndex = Mth.m_14045_((int)frameIndex, (int)0, (int)(frameCountForAnim - 1)); - this.baseSheetIndex = baseSheetStart + frameIndex / 64; - this.baseFrameOnSheet = frameIndex % 64; - this.emissiveSheetIndex = emissiveSheetStart + frameIndex / 64; - this.emissiveFrameOnSheet = frameIndex % 64; - } - - public void m_5744_(VertexConsumer pBuffer, Camera pRenderInfo, float pPartialTicks) { - Vector3f[] avector3f; - 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); - } - if (this.animationType == 2) { - float aspectRatio = 0.5629139f; - avector3f = new Vector3f[]{new Vector3f(-0.5629139f, -1.0f, 0.0f), new Vector3f(-0.5629139f, 1.0f, 0.0f), new Vector3f(0.5629139f, 1.0f, 0.0f), new Vector3f(0.5629139f, -1.0f, 0.0f)}; - } else { - 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); - } - int worldLight = this.m_6355_(pPartialTicks); - int frameToRender = Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.VANILA ? 0 : this.baseFrameOnSheet; - ResourceLocation baseTexture = ExplosionTextureManager.getInstance().getTexture(this.baseSheetIndex); - this.renderFrame(avector3f, baseTexture, frameToRender, this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_, worldLight); - if (Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.REALISTIC || Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.REALISTIC_2) { - ResourceLocation emissiveTexture = ExplosionTextureManager.getInstance().getTexture(this.emissiveSheetIndex); - int fullBright = 240; - this.renderFrame(avector3f, emissiveTexture, this.emissiveFrameOnSheet, this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_, fullBright); - } else if (this.f_107224_ < this.smokeStartTick) { - ResourceLocation emissiveTexture = ExplosionTextureManager.getInstance().getTexture(1); - int fullBright = 240; - this.renderFrame(avector3f, emissiveTexture, 0, this.f_107227_, this.f_107228_, this.f_107229_, this.f_107230_ * 0.8f, fullBright); - } - } - - private void renderFrame(Vector3f[] vertices, ResourceLocation texture, int frame, float r, float g, float b, float a, int light) { - float v1; - float u1; - float v0; - float u0; - if (texture == null) { - return; - } - RenderSystem.setShader(GameRenderer::m_172829_); - RenderSystem.setShaderTexture((int)0, (ResourceLocation)texture); - RenderSystem.enableDepthTest(); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.depthMask((boolean)true); - Tesselator tesselator = Tesselator.m_85913_(); - BufferBuilder buffer = tesselator.m_85915_(); - buffer.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85813_); - if (frame == 0 && Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.VANILA) { - u0 = 0.0f; - v0 = 0.0f; - u1 = 1.0f; - v1 = 1.0f; - } else { - float frameUWidth = 0.125f; - float frameVHeight = 0.125f; - int col = frame % 8; - int row = frame / 8; - u0 = (float)col * frameUWidth; - v0 = (float)row * frameVHeight; - u1 = u0 + frameUWidth; - v1 = v0 + frameVHeight; - } - buffer.m_5483_((double)vertices[0].x(), (double)vertices[0].y(), (double)vertices[0].z()).m_7421_(u0, v1).m_85950_(r, g, b, a).m_85969_(light).m_5752_(); - buffer.m_5483_((double)vertices[1].x(), (double)vertices[1].y(), (double)vertices[1].z()).m_7421_(u0, v0).m_85950_(r, g, b, a).m_85969_(light).m_5752_(); - buffer.m_5483_((double)vertices[2].x(), (double)vertices[2].y(), (double)vertices[2].z()).m_7421_(u1, v0).m_85950_(r, g, b, a).m_85969_(light).m_5752_(); - buffer.m_5483_((double)vertices[3].x(), (double)vertices[3].y(), (double)vertices[3].z()).m_7421_(u1, v1).m_85950_(r, g, b, a).m_85969_(light).m_5752_(); - tesselator.m_85914_(); - } - - public ParticleRenderType m_7556_() { - return ParticleRenderType.f_107433_; - } - - private int interpolate(float power, float p1, float v1, float p2, float v2) { - if (p2 == p1) { - return (int)v1; - } - float fraction = (power - p1) / (p2 - p1); - return (int)(v1 + fraction * (v2 - v1)); - } - - private float updateHeightPercent() { - if (this.maxRadius <= 0.0f) { - return 0.5f; - } - return Math.max(0.25f, this.currentHeightPercent); - } - - public int m_6355_(float pPartialTick) { - if (Config.CLIENT.particleRenderMode.get() == Config.Client.ParticleRenderMode.VANILA) { - float currentAge = (float)this.f_107224_ + pPartialTick; - if (currentAge < (float)this.fireTransitionEndTick) { - return 240; - } - if (currentAge > (float)this.smokeStartTick) { - return super.m_6355_(pPartialTick); - } - float progress = (currentAge - (float)this.fireTransitionEndTick) / (float)(this.smokeStartTick - this.fireTransitionEndTick); - int packedAmbient = super.m_6355_(pPartialTick); - int skyLightAmbient = packedAmbient >> 20 & 0xF; - int blockLightAmbient = packedAmbient >> 4 & 0xF; - int skyLightCurrent = (int)Mth.m_14179_((float)progress, (float)15.0f, (float)skyLightAmbient); - int blockLightCurrent = (int)Mth.m_14179_((float)progress, (float)15.0f, (float)blockLightAmbient); - return skyLightCurrent << 20 | blockLightCurrent << 4; - } - return super.m_6355_(pPartialTick); + @Override + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT; } } diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/GroundDustEffect.java b/src/main/java/com/vinlanx/explosionoverhaul/client/GroundDustEffect.java index 2ef8a59..24bc0d0 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/GroundDustEffect.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/GroundDustEffect.java @@ -1,173 +1,15 @@ -/* - * Decompiled with CFR 0.152. - */ package com.vinlanx.explosionoverhaul.client; -import com.vinlanx.explosionoverhaul.Config; -import com.vinlanx.explosionoverhaul.SmokeParticleOptions; -import com.vinlanx.explosionoverhaul.client.ExplosionWindController; -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.tags.BlockTags; -import net.minecraft.util.Mth; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.ClipContext; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.MapColor; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; public class GroundDustEffect { - 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 currentDustColor = new Color(128, 128, 128); - private boolean finished = false; - private final int raycastFrequency; - public GroundDustEffect(Vec3 position, float power) { - this.level = Minecraft.getInstance().f_91073_; - this.initialPosition = position; - this.power = power; - double qualityMultiplier = (Double)Config.CLIENT.groundDustQuality.get(); - this.raycastFrequency = (Integer)Config.CLIENT.groundDustRaycastFrequency.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); - int calculatedMaxAge = (int)((double)Mth.m_14179_((float)powerFraction, (float)30.0f, (float)70.0f) * qualityMultiplier); - 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); - 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; - } - - private Color getDustColorForState(BlockState state) { - if (state.m_204336_(BlockTags.f_13035_) || state.m_284242_((BlockGetter)this.level, BlockPos.f_121853_) == MapColor.f_283808_) { - return null; - } - if (state.m_60713_(Blocks.f_50440_)) { - return new Color(Blocks.f_50493_.m_49966_().m_284242_((BlockGetter)this.level, (BlockPos)BlockPos.f_121853_).f_283871_); - } - if (state.m_60713_(Blocks.f_50125_) || state.m_60713_(Blocks.f_50127_)) { - return new Color(Blocks.f_50127_.m_49966_().m_284242_((BlockGetter)this.level, (BlockPos)BlockPos.f_121853_).f_283871_); - } - return new Color(state.m_284242_((BlockGetter)this.level, (BlockPos)BlockPos.f_121853_).f_283871_); } public void tick() { - BlockPos blockPos; - BlockState blockState; - Color newColor; - 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 && (newColor = this.getDustColorForState(blockState = this.level.m_8055_(blockPos = hitResult.m_82425_()))) != null) { - this.currentDustColor = newColor; - } - 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.05f, (float)0.45f); - double motionX = direction.f_82479_ * motionStrength + (this.random.nextDouble() - 0.5) * 0.05; - double motionZ = direction.f_82481_ * motionStrength + (this.random.nextDouble() - 0.5) * 0.05; - double motionY = (this.random.nextDouble() - 0.5) * 0.02; - double heightPercent = 0.0; - Vec3 windDirection = ExplosionWindController.getWindDirection(); - double windSpeed = ExplosionWindController.computeDustSpeed(0.0); - double initialBoostFactor = 0.65; - if (windDirection != Vec3.f_82478_ && windSpeed > 0.0) { - motionX += windDirection.f_82479_ * windSpeed * initialBoostFactor; - motionZ += windDirection.f_82481_ * windSpeed * initialBoostFactor; - } - int lifetime = 100 + this.random.nextInt(60); - if (radiusFrac <= 0.2) { - b = 0.2f; - g = 0.2f; - r = 0.2f; - a = 0.9f; - scale = this.particleBaseSize * 0.5f; - } else if (radiusFrac <= 0.65) { - b = 0.4f; - g = 0.4f; - r = 0.4f; - a = 0.6f; - scale = this.particleBaseSize * 0.75f; - } else { - r = (float)this.currentDustColor.getRed() / 255.0f; - g = (float)this.currentDustColor.getGreen() / 255.0f; - b = (float)this.currentDustColor.getBlue() / 255.0f; - a = 0.35f; - scale = this.particleBaseSize; - } - SmokeParticleOptions options = new SmokeParticleOptions(scale * (0.8f + this.random.nextFloat() * 0.4f), lifetime, r, g, b, a, false, (float)windSpeed, (float)heightPercent, null); - this.level.m_6493_((ParticleOptions)options, true, spawnX, spawnY + 0.2, spawnZ, motionX, motionY, motionZ); - } } public boolean isFinished() { - return this.finished; + return true; } } diff --git a/src/main/java/com/vinlanx/explosionoverhaul/client/PositionalSoundInstance.java b/src/main/java/com/vinlanx/explosionoverhaul/client/PositionalSoundInstance.java index 5e2f4aa..951a8e6 100644 --- a/src/main/java/com/vinlanx/explosionoverhaul/client/PositionalSoundInstance.java +++ b/src/main/java/com/vinlanx/explosionoverhaul/client/PositionalSoundInstance.java @@ -1,6 +1,3 @@ -/* - * Decompiled with CFR 0.152. - */ package com.vinlanx.explosionoverhaul.client; import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; @@ -10,27 +7,27 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.phys.Vec3; -public class PositionalSoundInstance -extends AbstractTickableSoundInstance { - public PositionalSoundInstance(SoundEvent pSound, SoundSource pSource, float pVolume, float pPitch, RandomSource pRandom, double pX, double pY, double pZ) { - super(pSound, pSource, pRandom); - this.f_119573_ = pVolume; - this.f_119574_ = pPitch; - this.f_119575_ = pX; - this.f_119576_ = pY; - this.f_119577_ = pZ; - this.f_119578_ = false; - this.f_119579_ = 0; - this.f_119582_ = false; - this.f_119580_ = SoundInstance.Attenuation.LINEAR; +public class PositionalSoundInstance extends AbstractTickableSoundInstance { + public PositionalSoundInstance(SoundEvent sound, SoundSource source, float volume, float pitch, RandomSource random, double x, double y, double z) { + super(sound, source, random); + this.volume = volume; + this.pitch = pitch; + this.x = x; + this.y = y; + this.z = z; + this.looping = false; + this.delay = 0; + this.relative = false; + this.attenuation = SoundInstance.Attenuation.LINEAR; } - public void m_7788_() { + @Override + public void tick() { } public void updatePosition(Vec3 newPosition) { - this.f_119575_ = newPosition.m_7096_(); - this.f_119576_ = newPosition.m_7098_(); - this.f_119577_ = newPosition.m_7094_(); + this.x = newPosition.x(); + this.y = newPosition.y(); + this.z = newPosition.z(); } }