-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make particles in sakura groves and carnelian treeways spawn from lea…
…ves (#169)
- Loading branch information
Showing
16 changed files
with
186 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/fr/hugman/promenade/block/DecoratedLeavesBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fr.hugman.promenade.block; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.CherryLeavesBlock; | ||
import net.minecraft.block.LeavesBlock; | ||
import net.minecraft.client.util.ParticleUtil; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.random.Random; | ||
import net.minecraft.world.World; | ||
|
||
public class DecoratedLeavesBlock extends LeavesBlock { | ||
private final int bound; | ||
private final ParticleEffect particle; | ||
|
||
public DecoratedLeavesBlock(Settings settings, int bound, ParticleEffect particle) { | ||
super(settings); | ||
this.bound = bound; | ||
this.particle = particle; | ||
} | ||
|
||
@Override | ||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { | ||
super.randomDisplayTick(state, world, pos, random); | ||
if (random.nextInt(this.bound) != 0) { | ||
return; | ||
} | ||
BlockPos blockPos = pos.down(); | ||
BlockState blockState = world.getBlockState(blockPos); | ||
if (CherryLeavesBlock.isFaceFullSquare(blockState.getCollisionShape(world, blockPos), Direction.UP)) { | ||
return; | ||
} | ||
ParticleUtil.spawnParticle(world, pos, random, this.particle); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package fr.hugman.promenade.particle; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.particle.*; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.particle.DefaultParticleType; | ||
|
||
@Environment(value = EnvType.CLIENT) | ||
public class FallingLeafParticle extends SpriteBillboardParticle { | ||
private static final float velocityIncrement = 0.0025f; | ||
private static final int MAX_AGE = 300; | ||
private static final float SPEED = 2.0f; | ||
private float field_43369; | ||
private final float field_43370; | ||
private final float field_43371; | ||
|
||
public FallingLeafParticle(ClientWorld world, double x, double y, double z, SpriteProvider spriteProvider) { | ||
super(world, x, y, z); | ||
float f; | ||
this.setSprite(spriteProvider.getSprite(this.random.nextInt(12), 12)); | ||
this.field_43369 = (float)Math.toRadians(this.random.nextBoolean() ? -30.0 : 30.0); | ||
this.field_43370 = this.random.nextFloat(); | ||
this.field_43371 = (float)Math.toRadians(this.random.nextBoolean() ? -5.0 : 5.0); | ||
this.maxAge = MAX_AGE; | ||
this.gravityStrength = 7.5E-4f; | ||
this.scale = f = this.random.nextBoolean() ? 0.05f : 0.075f; | ||
this.setBoundingBoxSpacing(f, f); | ||
this.velocityMultiplier = 1.0f; | ||
} | ||
|
||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; | ||
} | ||
|
||
|
||
@Override | ||
public void tick() { | ||
this.prevPosX = this.x; | ||
this.prevPosY = this.y; | ||
this.prevPosZ = this.z; | ||
if (this.maxAge-- <= 0) { | ||
this.markDead(); | ||
} | ||
if (this.dead) { | ||
return; | ||
} | ||
float f = MAX_AGE - this.maxAge; | ||
float g = Math.min(f / MAX_AGE, 1.0f); | ||
double d = Math.cos(Math.toRadians(this.field_43370 * 60.0f)) * SPEED * Math.pow(g, 1.25); | ||
double e = Math.sin(Math.toRadians(this.field_43370 * 60.0f)) * SPEED * Math.pow(g, 1.25); | ||
this.velocityX += d * (double) velocityIncrement; | ||
this.velocityZ += e * (double) velocityIncrement; | ||
this.velocityY -= this.gravityStrength; | ||
this.field_43369 += this.field_43371 / 20.0f; | ||
this.prevAngle = this.angle; | ||
this.angle += this.field_43369 / 20.0f; | ||
this.move(this.velocityX, this.velocityY, this.velocityZ); | ||
if (this.onGround || this.maxAge < 299 && (this.velocityX == 0.0 || this.velocityZ == 0.0)) { | ||
this.markDead(); | ||
} | ||
if (this.dead) { | ||
return; | ||
} | ||
this.velocityX *= this.velocityMultiplier; | ||
this.velocityY *= this.velocityMultiplier; | ||
this.velocityZ *= this.velocityMultiplier; | ||
} | ||
|
||
@Environment(value = EnvType.CLIENT) | ||
public record BlossomFactory(SpriteProvider spriteProvider) implements ParticleFactory<DefaultParticleType> { | ||
@Override | ||
public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { | ||
FallingLeafParticle particle = new FallingLeafParticle(clientWorld, x, y, z, this.spriteProvider); | ||
//particle.bobbingAmplitude = MathHelper.nextBetween(clientWorld.random, 0.9f, 1.2f); | ||
//particle.maxAge = MathHelper.nextBetween(clientWorld.random, 500, 1000); | ||
return particle; | ||
} | ||
} | ||
|
||
@Environment(value = EnvType.CLIENT) | ||
public record MapleLeafFactory(SpriteProvider spriteProvider) implements ParticleFactory<DefaultParticleType> { | ||
@Override | ||
public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { | ||
FallingLeafParticle particle = new FallingLeafParticle(clientWorld, x, y, z, this.spriteProvider); | ||
//particle.bobbingAmplitude = MathHelper.nextBetween(world.random, 0.6f, 0.8f); | ||
//particle.maxAge = MathHelper.nextBetween(world.random, 500, 1000); | ||
//particle.scale *= world.random.nextFloat() * 0.1f + 1.4f; | ||
return particle; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/promenade/particles/fulvous_maple_leaf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"textures": [ | ||
"promenade:maple_leaf/fulvous" | ||
] | ||
} |
7 changes: 0 additions & 7 deletions
7
src/main/resources/assets/promenade/particles/maple_leaf.json
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/promenade/particles/mikado_maple_leaf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"textures": [ | ||
"promenade:maple_leaf/mikado" | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/resources/assets/promenade/particles/vermilion_maple_leaf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"textures": [ | ||
"promenade:maple_leaf/vermilion" | ||
] | ||
} |
Binary file modified
BIN
-61 Bytes
(70%)
src/main/resources/assets/promenade/textures/particle/maple_leaf/fulvous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-61 Bytes
(70%)
src/main/resources/assets/promenade/textures/particle/maple_leaf/mikado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-61 Bytes
(70%)
src/main/resources/assets/promenade/textures/particle/maple_leaf/vermilion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters