Skip to content

Commit

Permalink
update structure nbts + add particle
Browse files Browse the repository at this point in the history
  • Loading branch information
warior456 committed Aug 26, 2024
1 parent 28f86d3 commit 9eed30d
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/client/java/net/ugi/sculk_depths/SculkDepthsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
Expand All @@ -20,8 +19,6 @@
import net.ugi.sculk_depths.render.SculkDepthsSkyRendererClient;
import net.ugi.sculk_depths.screen.ModScreenHandlers;
import net.ugi.sculk_depths.screen.ZygrinFurnaceScreen;
import net.ugi.sculk_depths.sound.ConditionalSoundPlayerClient;
import net.ugi.sculk_depths.sound.SoundPlayerGetterClient;
import net.ugi.sculk_depths.world.dimension.ModDimensions;

public class SculkDepthsClient implements ClientModInitializer {
Expand Down Expand Up @@ -106,6 +103,7 @@ public void onInitializeClient() {


ParticleFactoryRegistry.getInstance().register(ModParticleTypes.PENEBRIUM_SPORES, PenebriumSporeParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ModParticleTypes.SCULK_DEPTHS_PORTAL_PARTICLE, ModPortalParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ModParticleTypes.AURIC_SPORES, AuricSporeParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ModParticleTypes.SURFACE_WIND, SurfaceWindParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(ModParticleTypes.CAVE_FALLING_PARTICLE, CaveFallingParticle.Factory::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package net.ugi.sculk_depths.particle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.AscendingParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;

public class ModPortalParticle
extends AscendingParticle {



protected ModPortalParticle(ClientWorld world, double x, double y, double z, float randomVelocityXMultiplier, float randomVelocityYMultiplier, float randomVelocityZMultiplier, double velocityX, double velocityY, double velocityZ, float scaleMultiplier, SpriteProvider spriteProvider, float colorMultiplier, int baseMaxAge, float gravityStrength, boolean collidesWithWorld) {
super(world, x, y, z, randomVelocityXMultiplier, randomVelocityYMultiplier, randomVelocityZMultiplier, velocityX, velocityY, velocityZ, scaleMultiplier, spriteProvider, colorMultiplier, baseMaxAge, gravityStrength, collidesWithWorld);
}

@Override
protected int getBrightness(float tint) {
return 15728880; //look at original and it's methods to see why
}

@Environment(value = EnvType.CLIENT)
public static class Factory
implements ParticleFactory<SimpleParticleType> {
private final SpriteProvider spriteProvider;

public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}

@Nullable
@Override
public Particle createParticle(SimpleParticleType parameters, ClientWorld clientWorld, double x, double y, double z, double g, double h, double i) {

ModPortalParticle particle = new ModPortalParticle(clientWorld, x, y, z, 0.3f, 0.1f, 0.3f, 0f, -0.01f, 0f, 0.18f, this.spriteProvider, 1f, 40, -0.001f, false);
particle.setColor(1,1,1);
particle.maxAge = MathHelper.nextBetween(clientWorld.random, 40, 200);
//particle.gravityStrength = -0.01f;//not needed?
return particle;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public Factory(SpriteProvider spriteProvider) {
@Override
public Particle createParticle(SimpleParticleType parameters, ClientWorld clientWorld, double x, double y, double z, double g, double h, double i) {

PenebriumSporeParticle particle = new PenebriumSporeParticle(clientWorld, x, y, z, 0.3f, 0.1f, 0.3f, 0f, -0.01f, 0f, 0.18f, this.spriteProvider, 1f, 40, 0.01f, false);
PenebriumSporeParticle particle = new PenebriumSporeParticle(clientWorld, x, y, z, 0.3f, 0.1f, 0.3f, 0f, -0.01f, 0f, 0.18f, this.spriteProvider, 1f, 500, 0.01f, true);
particle.setColor(1,1,1);
particle.maxAge = MathHelper.nextBetween(clientWorld.random, 500, 1000);
particle.gravityStrength = 0.01f;
//particle.gravityStrength = 0.01f;
return particle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.particle.SculkChargeParticleEffect;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -123,7 +120,7 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando
j = (double)(random.nextFloat() * 2.0F * (float)k);
}

world.addParticle((ParticleEffect) ModParticleTypes.PENEBRIUM_SPORES, d, e, f, g, h, j);
world.addParticle((ParticleEffect) ModParticleTypes.SCULK_DEPTHS_PORTAL_PARTICLE, d, e, f, g, h, j);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
public class ModParticleTypes {

public static final ParticleType<SimpleParticleType> PENEBRIUM_SPORES = FabricParticleTypes.simple();
public static final ParticleType<SimpleParticleType> SCULK_DEPTHS_PORTAL_PARTICLE = FabricParticleTypes.simple();

public static final ParticleType<SimpleParticleType> AURIC_SPORES = FabricParticleTypes.simple();
public static final ParticleType<SimpleParticleType> SURFACE_WIND = FabricParticleTypes.simple();
public static final ParticleType<SimpleParticleType> CAVE_FALLING_PARTICLE = FabricParticleTypes.simple();

public static void registerModParticles() {
Registry.register(Registries.PARTICLE_TYPE, SculkDepths.identifier( "penebrium_spores"), PENEBRIUM_SPORES);
Registry.register(Registries.PARTICLE_TYPE, SculkDepths.identifier( "sculk_depths_portal_particle"), SCULK_DEPTHS_PORTAL_PARTICLE);
Registry.register(Registries.PARTICLE_TYPE, SculkDepths.identifier( "auric_spores"), AURIC_SPORES);
Registry.register(Registries.PARTICLE_TYPE, SculkDepths.identifier( "surface_wind"), SURFACE_WIND);
Registry.register(Registries.PARTICLE_TYPE, SculkDepths.identifier( "cave_falling_particle"), CAVE_FALLING_PARTICLE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"textures": [
"sculk_depths:sculk_depths_portal_particle"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 9eed30d

Please sign in to comment.