From d93415c69c7e0412c1349654b123e22a8cdc66b8 Mon Sep 17 00:00:00 2001 From: KekeCreations <89083260+KekeCreations@users.noreply.github.com> Date: Fri, 9 Aug 2024 01:36:15 +0100 Subject: [PATCH] My gradle broke so can't test --- .../client/particles/SMDripParticle.java | 86 +++++++++++++++++++ .../sullysmod/core/events/SMClientEvents.java | 3 + .../core/registry/SMParticleTypes.java | 3 + .../sullysmod/particles/amber_drip.json | 5 ++ 4 files changed, 97 insertions(+) create mode 100644 src/main/java/com/uraneptus/sullysmod/client/particles/SMDripParticle.java create mode 100644 src/main/resources/assets/sullysmod/particles/amber_drip.json diff --git a/src/main/java/com/uraneptus/sullysmod/client/particles/SMDripParticle.java b/src/main/java/com/uraneptus/sullysmod/client/particles/SMDripParticle.java new file mode 100644 index 00000000..c57acefd --- /dev/null +++ b/src/main/java/com/uraneptus/sullysmod/client/particles/SMDripParticle.java @@ -0,0 +1,86 @@ +package com.uraneptus.sullysmod.client.particles; + +import com.uraneptus.sullysmod.core.registry.SMFluids; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import org.jetbrains.annotations.NotNull; + +public class SMDripParticle extends TextureSheetParticle { + private final Fluid type; + protected boolean isGlowing; + + protected SMDripParticle(ClientLevel pLevel, double pX, double pY, double pZ, Fluid pType) { + super(pLevel, pX, pY, pZ); + type = pType; + this.setSize(0.01F, 0.01F); + this.gravity = 0.06F; + } + + @Override + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_OPAQUE; + } + + public int getLightColor(float pPartialTick) { + return this.isGlowing ? 240 : super.getLightColor(pPartialTick); + } + + public void tick() { + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + this.preMoveUpdate(); + if (!this.removed) { + this.yd -= (double)this.gravity; + this.move(this.xd, this.yd, this.zd); + this.postMoveUpdate(); + if (!this.removed) { + this.xd *= 0.9800000190734863; + this.yd *= 0.9800000190734863; + this.zd *= 0.9800000190734863; + if (this.type != Fluids.EMPTY) { + BlockPos $$0 = BlockPos.containing(this.x, this.y, this.z); + FluidState $$1 = this.level.getFluidState($$0); + if ($$1.getType() == this.type && this.y < (double)((float)$$0.getY() + $$1.getHeight(this.level, $$0))) { + this.remove(); + } + + } + } + } + } + + protected void preMoveUpdate() { + if (this.lifetime-- <= 0) { + this.remove(); + } + + } + + protected void postMoveUpdate() { + if (this.onGround) { + this.remove(); + } + } + + @OnlyIn(Dist.CLIENT) + public static class Factory implements ParticleProvider { + private final SpriteSet spriteProvider; + + public Factory(SpriteSet spriteProvider) { + this.spriteProvider = spriteProvider; + } + + public Particle createParticle(@NotNull SimpleParticleType defaultParticleType, @NotNull ClientLevel clientWorld, double d, double e, double f, double g, double h, double i) { + return new SMDripParticle(clientWorld, d, e, f, SMFluids.SOURCE_MOLTEN_AMBER.get()); + } + } +} diff --git a/src/main/java/com/uraneptus/sullysmod/core/events/SMClientEvents.java b/src/main/java/com/uraneptus/sullysmod/core/events/SMClientEvents.java index f4d4d215..2d65e2b4 100644 --- a/src/main/java/com/uraneptus/sullysmod/core/events/SMClientEvents.java +++ b/src/main/java/com/uraneptus/sullysmod/core/events/SMClientEvents.java @@ -7,6 +7,7 @@ import com.uraneptus.sullysmod.client.model.ancient_skulls.*; import com.uraneptus.sullysmod.client.particles.BlotEyesParticle; import com.uraneptus.sullysmod.client.particles.RicochetParticle; +import com.uraneptus.sullysmod.client.particles.SMDripParticle; import com.uraneptus.sullysmod.client.renderer.be.AmberBER; import com.uraneptus.sullysmod.client.renderer.be.ItemStandBER; import com.uraneptus.sullysmod.client.renderer.entities.*; @@ -18,6 +19,7 @@ import com.uraneptus.sullysmod.core.registry.SMItems; import com.uraneptus.sullysmod.core.registry.SMParticleTypes; import net.minecraft.Util; +import net.minecraft.client.particle.DripParticle; import net.minecraft.client.renderer.blockentity.SkullBlockRenderer; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.item.ItemProperties; @@ -76,6 +78,7 @@ public static void registerLayerLocation(EntityRenderersEvent.RegisterLayerDefin public static void registerParticleProvider(RegisterParticleProvidersEvent event) { event.registerSpriteSet(SMParticleTypes.RICOCHET.get(), RicochetParticle.RicochetParticleProvider::new); event.registerSpriteSet(SMParticleTypes.BLOT_EYES.get(), BlotEyesParticle.Factory::new); + event.registerSpriteSet(SMParticleTypes.AMBER_DRIP.get(), SMDripParticle.Factory::new); } @SubscribeEvent diff --git a/src/main/java/com/uraneptus/sullysmod/core/registry/SMParticleTypes.java b/src/main/java/com/uraneptus/sullysmod/core/registry/SMParticleTypes.java index a3eac921..f4031e1c 100644 --- a/src/main/java/com/uraneptus/sullysmod/core/registry/SMParticleTypes.java +++ b/src/main/java/com/uraneptus/sullysmod/core/registry/SMParticleTypes.java @@ -2,6 +2,7 @@ import com.uraneptus.sullysmod.SullysMod; import com.uraneptus.sullysmod.common.particletypes.ParticleWithDirectionType; +import net.minecraft.client.particle.DripParticle; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.particles.SimpleParticleType; import net.minecraftforge.fml.common.Mod; @@ -16,4 +17,6 @@ public class SMParticleTypes { public static final RegistryObject RICOCHET = PARTICLES.register("ricochet", () -> new ParticleWithDirectionType(false)); public static final RegistryObject BLOT_EYES = PARTICLES.register("blot_eyes", () -> new SimpleParticleType(false)); + + public static final RegistryObject AMBER_DRIP = PARTICLES.register("amber_drip", () -> new SimpleParticleType(false)); } diff --git a/src/main/resources/assets/sullysmod/particles/amber_drip.json b/src/main/resources/assets/sullysmod/particles/amber_drip.json new file mode 100644 index 00000000..987e9f30 --- /dev/null +++ b/src/main/resources/assets/sullysmod/particles/amber_drip.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "minecraft:drip_hang" + ] +} \ No newline at end of file