From 400c511aba927f470c79e94cace6b5d1e8c6aa5e Mon Sep 17 00:00:00 2001 From: Hugo Landrin Date: Tue, 7 Nov 2023 17:46:43 +0100 Subject: [PATCH 1/3] Move leaves particles to leaves blocks instead of biomes --- .../fr/hugman/promenade/PromenadeClient.java | 5 ++- .../fr/hugman/promenade/PromenadeFactory.java | 20 +++++++++++ .../promenade/block/DecoratedLeavesBlock.java | 36 +++++++++++++++++++ .../registry/content/MapleContent.java | 16 +++++---- .../registry/content/SakuraContent.java | 8 ++--- .../particles/fulvous_maple_leaf.json | 5 +++ .../promenade/particles/maple_leaf.json | 7 ---- .../particles/mikado_maple_leaf.json | 5 +++ .../particles/vermilion_maple_leaf.json | 5 +++ .../worldgen/biome/blush_sakura_grove.json | 6 ---- .../worldgen/biome/carnelian_treeway.json | 6 ---- .../worldgen/biome/cotton_sakura_grove.json | 6 ---- 12 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 src/main/java/fr/hugman/promenade/block/DecoratedLeavesBlock.java create mode 100644 src/main/resources/assets/promenade/particles/fulvous_maple_leaf.json delete mode 100644 src/main/resources/assets/promenade/particles/maple_leaf.json create mode 100644 src/main/resources/assets/promenade/particles/mikado_maple_leaf.json create mode 100644 src/main/resources/assets/promenade/particles/vermilion_maple_leaf.json diff --git a/src/main/java/fr/hugman/promenade/PromenadeClient.java b/src/main/java/fr/hugman/promenade/PromenadeClient.java index 03e3bc46..3d157da0 100644 --- a/src/main/java/fr/hugman/promenade/PromenadeClient.java +++ b/src/main/java/fr/hugman/promenade/PromenadeClient.java @@ -35,7 +35,10 @@ public void onInitializeClient() { ParticleFactoryRegistry.getInstance().register(SakuraContent.BLUSH_SAKURA_BLOSSOM, FloatingParticle.BlossomFactory::new); ParticleFactoryRegistry.getInstance().register(SakuraContent.COTTON_SAKURA_BLOSSOM, FloatingParticle.BlossomFactory::new); - ParticleFactoryRegistry.getInstance().register(MapleContent.MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); + + ParticleFactoryRegistry.getInstance().register(MapleContent.MIKADO_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); + ParticleFactoryRegistry.getInstance().register(MapleContent.FULVOUS_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); + ParticleFactoryRegistry.getInstance().register(MapleContent.VERMILION_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); ClientRegistrar.add(SakuraContent.SAKURA_SIGNS); ClientRegistrar.add(SakuraContent.SAKURA_BOAT_TYPE); diff --git a/src/main/java/fr/hugman/promenade/PromenadeFactory.java b/src/main/java/fr/hugman/promenade/PromenadeFactory.java index 1398fd74..492d50b5 100644 --- a/src/main/java/fr/hugman/promenade/PromenadeFactory.java +++ b/src/main/java/fr/hugman/promenade/PromenadeFactory.java @@ -1,15 +1,19 @@ package fr.hugman.promenade; +import fr.hugman.dawn.DawnFactory; import fr.hugman.dawn.block.DawnBlockSettings; import fr.hugman.dawn.item.DawnItemSettings; import fr.hugman.promenade.block.CarpetedGrassBlock; +import fr.hugman.promenade.block.DecoratedLeavesBlock; import fr.hugman.promenade.block.PileBlock; import fr.hugman.promenade.block.SnowyLeavesBlock; import fr.hugman.promenade.registry.content.GlaglaglaContent; import net.minecraft.block.Block; +import net.minecraft.block.LeavesBlock; import net.minecraft.block.MapColor; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.EntityType; +import net.minecraft.particle.ParticleEffect; import net.minecraft.sound.BlockSoundGroup; public final class PromenadeFactory { @@ -65,4 +69,20 @@ public static SnowyLeavesBlock snowyLeaves(BlockSoundGroup soundGroup) { .pistonBehavior(PistonBehavior.DESTROY) .solidBlock((state, world, pos) -> false)); } + + public static DecoratedLeavesBlock decoratedLeaves(MapColor mapColor, BlockSoundGroup soundGroup, int bound, ParticleEffect particle) { + return new DecoratedLeavesBlock(DawnFactory.leavesSettings(mapColor, soundGroup), bound, particle); + } + + public static DecoratedLeavesBlock decoratedLeaves(MapColor mapColor, BlockSoundGroup soundGroup, ParticleEffect particle) { + return decoratedLeaves(mapColor, soundGroup, 10, particle); + } + + public static DecoratedLeavesBlock decoratedLeaves(MapColor mapColor, int bound, ParticleEffect particle) { + return decoratedLeaves(mapColor, BlockSoundGroup.GRASS, bound, particle); + } + + public static DecoratedLeavesBlock decoratedLeaves(MapColor mapColor, ParticleEffect particle) { + return decoratedLeaves(mapColor, BlockSoundGroup.GRASS, 10, particle); + } } diff --git a/src/main/java/fr/hugman/promenade/block/DecoratedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/DecoratedLeavesBlock.java new file mode 100644 index 00000000..2c4b6d5f --- /dev/null +++ b/src/main/java/fr/hugman/promenade/block/DecoratedLeavesBlock.java @@ -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); + } +} diff --git a/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java b/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java index 06129df0..d261edce 100644 --- a/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java +++ b/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java @@ -65,26 +65,27 @@ public class MapleContent { public static final Block SAP_MAPLE_LEAVES = DawnFactory.leaves(SAP_LEAVES_COLOR); public static final Block SAP_MAPLE_LEAF_PILE = PromenadeFactory.leafPile(); + public static final DefaultParticleType VERMILION_MAPLE_LEAF = FabricParticleTypes.simple(); public static final Block VERMILION_MAPLE_SAPLING = DawnFactory.sapling(VERMILION_LEAVES_COLOR, OakLikeSaplingGenerator.of(Promenade.id("maple/vermilion"))); public static final Block POTTED_VERMILION_MAPLE_SAPLING = DawnFactory.potted(VERMILION_MAPLE_SAPLING); public static final Block VERMILION_MAPLE_LEAVES = DawnFactory.leaves(VERMILION_LEAVES_COLOR); - public static final Block VERMILION_MAPLE_LEAF_PILE = PromenadeFactory.leafPile(VERMILION_LEAVES_COLOR); + public static final Block VERMILION_MAPLE_LEAF_PILE = PromenadeFactory.decoratedLeaves(VERMILION_LEAVES_COLOR, VERMILION_MAPLE_LEAF); public static final Block VERMILION_CARPETED_GRASS_BLOCK = PromenadeFactory.carpetedGrassBlock(VERMILION_LEAVES_COLOR); + public static final DefaultParticleType FULVOUS_MAPLE_LEAF = FabricParticleTypes.simple(); public static final Block FULVOUS_MAPLE_SAPLING = DawnFactory.sapling(FULVOUS_LEAVES_COLOR, OakLikeSaplingGenerator.of(Promenade.id("maple/fulvous"))); public static final Block POTTED_FULVOUS_MAPLE_SAPLING = DawnFactory.potted(FULVOUS_MAPLE_SAPLING); - public static final Block FULVOUS_MAPLE_LEAVES = DawnFactory.leaves(FULVOUS_LEAVES_COLOR); + public static final Block FULVOUS_MAPLE_LEAVES = PromenadeFactory.decoratedLeaves(FULVOUS_LEAVES_COLOR, FULVOUS_MAPLE_LEAF); public static final Block FULVOUS_MAPLE_LEAF_PILE = PromenadeFactory.leafPile(FULVOUS_LEAVES_COLOR); public static final Block FULVOUS_CARPETED_GRASS_BLOCK = PromenadeFactory.carpetedGrassBlock(FULVOUS_LEAVES_COLOR); + public static final DefaultParticleType MIKADO_MAPLE_LEAF = FabricParticleTypes.simple(); public static final Block MIKADO_MAPLE_SAPLING = DawnFactory.sapling(MIKADO_LEAVES_COLOR, OakLikeSaplingGenerator.of(Promenade.id("maple/mikado"))); public static final Block POTTED_MIKADO_MAPLE_SAPLING = DawnFactory.potted(MIKADO_MAPLE_SAPLING); - public static final Block MIKADO_MAPLE_LEAVES = DawnFactory.leaves(MIKADO_LEAVES_COLOR); + public static final Block MIKADO_MAPLE_LEAVES = PromenadeFactory.decoratedLeaves(MIKADO_LEAVES_COLOR, MIKADO_MAPLE_LEAF); public static final Block MIKADO_MAPLE_LEAF_PILE = PromenadeFactory.leafPile(MIKADO_LEAVES_COLOR); public static final Block MIKADO_CARPETED_GRASS_BLOCK = PromenadeFactory.carpetedGrassBlock(MIKADO_LEAVES_COLOR); - public static final DefaultParticleType MAPLE_LEAF = FabricParticleTypes.simple(); - public static final RegistryKey CARNELIAN_TREEWAY = DawnFactory.biome(Promenade.id("carnelian_treeway")); public static void register(Registrar r) { @@ -113,26 +114,27 @@ public static void register(Registrar r) { r.add(("sap_maple_leaves"), SAP_MAPLE_LEAVES); r.add(("sap_maple_leaf_pile"), SAP_MAPLE_LEAF_PILE); + r.add(("vermilion_maple_leaf"), VERMILION_MAPLE_LEAF); r.add(("vermilion_maple_sapling"), VERMILION_MAPLE_SAPLING); r.add(("potted_vermilion_maple_sapling"), POTTED_VERMILION_MAPLE_SAPLING); r.add(("vermilion_maple_leaves"), VERMILION_MAPLE_LEAVES); r.add(("vermilion_maple_leaf_pile"), VERMILION_MAPLE_LEAF_PILE); r.add(("vermilion_carpeted_grass_block"), VERMILION_CARPETED_GRASS_BLOCK); + r.add(("fulvous_maple_leaf"), FULVOUS_MAPLE_LEAF); r.add(("fulvous_maple_sapling"), FULVOUS_MAPLE_SAPLING); r.add(("potted_fulvous_maple_sapling"), POTTED_FULVOUS_MAPLE_SAPLING); r.add(("fulvous_maple_leaves"), FULVOUS_MAPLE_LEAVES); r.add(("fulvous_maple_leaf_pile"), FULVOUS_MAPLE_LEAF_PILE); r.add(("fulvous_carpeted_grass_block"), FULVOUS_CARPETED_GRASS_BLOCK); + r.add(("mikado_maple_leaf"), MIKADO_MAPLE_LEAF); r.add(("mikado_maple_sapling"), MIKADO_MAPLE_SAPLING); r.add(("potted_mikado_maple_sapling"), POTTED_MIKADO_MAPLE_SAPLING); r.add(("mikado_maple_leaves"), MIKADO_MAPLE_LEAVES); r.add(("mikado_maple_leaf_pile"), MIKADO_MAPLE_LEAF_PILE); r.add(("mikado_carpeted_grass_block"), MIKADO_CARPETED_GRASS_BLOCK); - r.add(("maple_leaf"), MAPLE_LEAF); - appendItemGroups(); appendVillagerTrades(); appendWorldGen(); diff --git a/src/main/java/fr/hugman/promenade/registry/content/SakuraContent.java b/src/main/java/fr/hugman/promenade/registry/content/SakuraContent.java index 681398cb..3988e952 100644 --- a/src/main/java/fr/hugman/promenade/registry/content/SakuraContent.java +++ b/src/main/java/fr/hugman/promenade/registry/content/SakuraContent.java @@ -52,17 +52,17 @@ public class SakuraContent { public static final SignBlocks SAKURA_SIGNS = DawnFactory.signs(Promenade.id("sakura"), SAKURA_PLANKS); public static final TerraformBoatType SAKURA_BOAT_TYPE = DawnFactory.boat(Promenade.id("sakura"), Items.OAK_PLANKS); //TODO change when possible (PR #72 on TerraformersMC/Terraform) + public static final DefaultParticleType BLUSH_SAKURA_BLOSSOM = FabricParticleTypes.simple(); public static final Block BLUSH_SAKURA_SAPLING = DawnFactory.sapling(BLUSH_BLOSSOMS_COLOR, OakLikeSaplingGenerator.of(Promenade.id("sakura/blush"))); public static final Block POTTED_BLUSH_SAKURA_SAPLING = DawnFactory.potted(BLUSH_SAKURA_SAPLING); - public static final Block BLUSH_SAKURA_BLOSSOMS = DawnFactory.leaves(BLUSH_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES); + public static final Block BLUSH_SAKURA_BLOSSOMS = PromenadeFactory.decoratedLeaves(BLUSH_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES, BLUSH_SAKURA_BLOSSOM); public static final Block BLUSH_SAKURA_BLOSSOM_PILE = PromenadeFactory.leafPile(BLUSH_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES); - public static final DefaultParticleType BLUSH_SAKURA_BLOSSOM = FabricParticleTypes.simple(); + public static final DefaultParticleType COTTON_SAKURA_BLOSSOM = FabricParticleTypes.simple(); public static final Block COTTON_SAKURA_SAPLING = DawnFactory.sapling(COTTON_BLOSSOMS_COLOR, OakLikeSaplingGenerator.of(Promenade.id("sakura/cotton"))); public static final Block POTTED_COTTON_SAKURA_SAPLING = DawnFactory.potted(COTTON_SAKURA_SAPLING); - public static final Block COTTON_SAKURA_BLOSSOMS = DawnFactory.leaves(COTTON_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES); + public static final Block COTTON_SAKURA_BLOSSOMS = PromenadeFactory.decoratedLeaves(COTTON_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES, COTTON_SAKURA_BLOSSOM); public static final Block COTTON_SAKURA_BLOSSOM_PILE = PromenadeFactory.leafPile(COTTON_BLOSSOMS_COLOR, BlockSoundGroup.CHERRY_LEAVES); - public static final DefaultParticleType COTTON_SAKURA_BLOSSOM = FabricParticleTypes.simple(); public static final RegistryKey BLUSH_SAKURA_GROVE = DawnFactory.biome(Promenade.id("blush_sakura_grove")); public static final RegistryKey COTTON_SAKURA_GROVE = DawnFactory.biome(Promenade.id("cotton_sakura_grove")); diff --git a/src/main/resources/assets/promenade/particles/fulvous_maple_leaf.json b/src/main/resources/assets/promenade/particles/fulvous_maple_leaf.json new file mode 100644 index 00000000..be051488 --- /dev/null +++ b/src/main/resources/assets/promenade/particles/fulvous_maple_leaf.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "promenade:maple_leaf/fulvous" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/promenade/particles/maple_leaf.json b/src/main/resources/assets/promenade/particles/maple_leaf.json deleted file mode 100644 index 58b0fddb..00000000 --- a/src/main/resources/assets/promenade/particles/maple_leaf.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "textures": [ - "promenade:maple_leaf/vermilion", - "promenade:maple_leaf/fulvous", - "promenade:maple_leaf/mikado" - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/promenade/particles/mikado_maple_leaf.json b/src/main/resources/assets/promenade/particles/mikado_maple_leaf.json new file mode 100644 index 00000000..c67ba768 --- /dev/null +++ b/src/main/resources/assets/promenade/particles/mikado_maple_leaf.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "promenade:maple_leaf/mikado" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/promenade/particles/vermilion_maple_leaf.json b/src/main/resources/assets/promenade/particles/vermilion_maple_leaf.json new file mode 100644 index 00000000..e48d339d --- /dev/null +++ b/src/main/resources/assets/promenade/particles/vermilion_maple_leaf.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "promenade:maple_leaf/vermilion" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/promenade/worldgen/biome/blush_sakura_grove.json b/src/main/resources/data/promenade/worldgen/biome/blush_sakura_grove.json index a4e755b6..574a4855 100644 --- a/src/main/resources/data/promenade/worldgen/biome/blush_sakura_grove.json +++ b/src/main/resources/data/promenade/worldgen/biome/blush_sakura_grove.json @@ -14,12 +14,6 @@ "block_search_extent": 8, "offset": 2 }, - "particle": { - "options": { - "type": "promenade:blush_sakura_blossom" - }, - "probability": 0.001 - }, "music": { "sound": "promenade:music.overworld.sakura_groves", "min_delay": 12000, diff --git a/src/main/resources/data/promenade/worldgen/biome/carnelian_treeway.json b/src/main/resources/data/promenade/worldgen/biome/carnelian_treeway.json index 84a72d38..534059c0 100644 --- a/src/main/resources/data/promenade/worldgen/biome/carnelian_treeway.json +++ b/src/main/resources/data/promenade/worldgen/biome/carnelian_treeway.json @@ -14,12 +14,6 @@ "tick_delay": 6000, "block_search_extent": 8, "offset": 2 - }, - "particle": { - "options": { - "type": "promenade:maple_leaf" - }, - "probability": 0.001 } }, "spawners": { diff --git a/src/main/resources/data/promenade/worldgen/biome/cotton_sakura_grove.json b/src/main/resources/data/promenade/worldgen/biome/cotton_sakura_grove.json index 72c18722..f3830810 100644 --- a/src/main/resources/data/promenade/worldgen/biome/cotton_sakura_grove.json +++ b/src/main/resources/data/promenade/worldgen/biome/cotton_sakura_grove.json @@ -14,12 +14,6 @@ "block_search_extent": 8, "offset": 2 }, - "particle": { - "options": { - "type": "promenade:cotton_sakura_blossom" - }, - "probability": 0.001 - }, "music": { "sound": "promenade:music.overworld.sakura_groves", "min_delay": 12000, From bcf8890cbac1783f92bf79e4a9045729e718d00a Mon Sep 17 00:00:00 2001 From: Hugman Date: Thu, 9 Nov 2023 23:31:52 +0100 Subject: [PATCH 2/3] Fix the vermillion leaf pile and clone cherry particles --- .../fr/hugman/promenade/PromenadeClient.java | 13 ++- .../particle/FallingLeafParticle.java | 95 +++++++++++++++++++ .../registry/content/MapleContent.java | 4 +- 3 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java diff --git a/src/main/java/fr/hugman/promenade/PromenadeClient.java b/src/main/java/fr/hugman/promenade/PromenadeClient.java index 3d157da0..d002f298 100644 --- a/src/main/java/fr/hugman/promenade/PromenadeClient.java +++ b/src/main/java/fr/hugman/promenade/PromenadeClient.java @@ -6,6 +6,7 @@ import fr.hugman.promenade.client.render.entity.DuckRenderer; import fr.hugman.promenade.client.render.entity.LushCreeperRenderer; import fr.hugman.promenade.client.render.entity.SunkenSkeletonRenderer; +import fr.hugman.promenade.particle.FallingLeafParticle; import fr.hugman.promenade.particle.FloatingParticle; import fr.hugman.promenade.registry.content.*; import net.fabricmc.api.ClientModInitializer; @@ -20,6 +21,8 @@ import net.minecraft.client.color.world.BiomeColors; import net.minecraft.client.color.world.FoliageColors; import net.minecraft.client.color.world.GrassColors; +import net.minecraft.client.particle.CherryLeavesParticle; +import net.minecraft.client.particle.SpriteProvider; import net.minecraft.client.render.RenderLayer; import net.minecraft.item.BlockItem; @@ -33,12 +36,12 @@ public void onInitializeClient() { PromenadeClient.registerItemColors(); PromenadeClient.registerEntityRenderers(); - ParticleFactoryRegistry.getInstance().register(SakuraContent.BLUSH_SAKURA_BLOSSOM, FloatingParticle.BlossomFactory::new); - ParticleFactoryRegistry.getInstance().register(SakuraContent.COTTON_SAKURA_BLOSSOM, FloatingParticle.BlossomFactory::new); + ParticleFactoryRegistry.getInstance().register(SakuraContent.BLUSH_SAKURA_BLOSSOM, FallingLeafParticle.BlossomFactory::new); + ParticleFactoryRegistry.getInstance().register(SakuraContent.COTTON_SAKURA_BLOSSOM, FallingLeafParticle.BlossomFactory::new); - ParticleFactoryRegistry.getInstance().register(MapleContent.MIKADO_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); - ParticleFactoryRegistry.getInstance().register(MapleContent.FULVOUS_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); - ParticleFactoryRegistry.getInstance().register(MapleContent.VERMILION_MAPLE_LEAF, FloatingParticle.MapleLeafFactory::new); + ParticleFactoryRegistry.getInstance().register(MapleContent.MIKADO_MAPLE_LEAF, FallingLeafParticle.MapleLeafFactory::new); + ParticleFactoryRegistry.getInstance().register(MapleContent.FULVOUS_MAPLE_LEAF, FallingLeafParticle.MapleLeafFactory::new); + ParticleFactoryRegistry.getInstance().register(MapleContent.VERMILION_MAPLE_LEAF, FallingLeafParticle.MapleLeafFactory::new); ClientRegistrar.add(SakuraContent.SAKURA_SIGNS); ClientRegistrar.add(SakuraContent.SAKURA_BOAT_TYPE); diff --git a/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java b/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java new file mode 100644 index 00000000..8d462367 --- /dev/null +++ b/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java @@ -0,0 +1,95 @@ +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 field_43372 = 0.0025f; + private static final int field_43373 = 300; + private static final int field_43366 = 300; + private static final float field_43367 = 0.25f; + private static final float field_43368 = 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 = 300; + 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 = 300 - this.maxAge; + float g = Math.min(f / 300.0f, 1.0f); + double d = Math.cos(Math.toRadians(this.field_43370 * 60.0f)) * 2.0 * Math.pow(g, 1.25); + double e = Math.sin(Math.toRadians(this.field_43370 * 60.0f)) * 2.0 * Math.pow(g, 1.25); + this.velocityX += d * (double)field_43372; + this.velocityZ += e * (double)field_43372; + 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 { + @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 { + @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; + } + } +} diff --git a/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java b/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java index d261edce..46776fff 100644 --- a/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java +++ b/src/main/java/fr/hugman/promenade/registry/content/MapleContent.java @@ -68,8 +68,8 @@ public class MapleContent { public static final DefaultParticleType VERMILION_MAPLE_LEAF = FabricParticleTypes.simple(); public static final Block VERMILION_MAPLE_SAPLING = DawnFactory.sapling(VERMILION_LEAVES_COLOR, OakLikeSaplingGenerator.of(Promenade.id("maple/vermilion"))); public static final Block POTTED_VERMILION_MAPLE_SAPLING = DawnFactory.potted(VERMILION_MAPLE_SAPLING); - public static final Block VERMILION_MAPLE_LEAVES = DawnFactory.leaves(VERMILION_LEAVES_COLOR); - public static final Block VERMILION_MAPLE_LEAF_PILE = PromenadeFactory.decoratedLeaves(VERMILION_LEAVES_COLOR, VERMILION_MAPLE_LEAF); + public static final Block VERMILION_MAPLE_LEAVES = PromenadeFactory.decoratedLeaves(VERMILION_LEAVES_COLOR, VERMILION_MAPLE_LEAF); + public static final Block VERMILION_MAPLE_LEAF_PILE = PromenadeFactory.leafPile(VERMILION_LEAVES_COLOR); public static final Block VERMILION_CARPETED_GRASS_BLOCK = PromenadeFactory.carpetedGrassBlock(VERMILION_LEAVES_COLOR); public static final DefaultParticleType FULVOUS_MAPLE_LEAF = FabricParticleTypes.simple(); From 0ef0d439364a967a452f866b01efb0ecc4a4032a Mon Sep 17 00:00:00 2001 From: Hugman Date: Wed, 6 Mar 2024 00:09:47 +0100 Subject: [PATCH 3/3] Update maple leaf particle textures --- .../particle/FallingLeafParticle.java | 22 ++++++++---------- .../textures/particle/maple_leaf/fulvous.png | Bin 206 -> 145 bytes .../textures/particle/maple_leaf/mikado.png | Bin 206 -> 145 bytes .../particle/maple_leaf/vermilion.png | Bin 206 -> 145 bytes 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java b/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java index 8d462367..d0161656 100644 --- a/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java +++ b/src/main/java/fr/hugman/promenade/particle/FallingLeafParticle.java @@ -8,11 +8,9 @@ @Environment(value = EnvType.CLIENT) public class FallingLeafParticle extends SpriteBillboardParticle { - private static final float field_43372 = 0.0025f; - private static final int field_43373 = 300; - private static final int field_43366 = 300; - private static final float field_43367 = 0.25f; - private static final float field_43368 = 2.0f; + 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; @@ -24,7 +22,7 @@ public FallingLeafParticle(ClientWorld world, double x, double y, double z, Spri 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 = 300; + this.maxAge = MAX_AGE; this.gravityStrength = 7.5E-4f; this.scale = f = this.random.nextBoolean() ? 0.05f : 0.075f; this.setBoundingBoxSpacing(f, f); @@ -48,12 +46,12 @@ public void tick() { if (this.dead) { return; } - float f = 300 - this.maxAge; - float g = Math.min(f / 300.0f, 1.0f); - double d = Math.cos(Math.toRadians(this.field_43370 * 60.0f)) * 2.0 * Math.pow(g, 1.25); - double e = Math.sin(Math.toRadians(this.field_43370 * 60.0f)) * 2.0 * Math.pow(g, 1.25); - this.velocityX += d * (double)field_43372; - this.velocityZ += e * (double)field_43372; + 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; diff --git a/src/main/resources/assets/promenade/textures/particle/maple_leaf/fulvous.png b/src/main/resources/assets/promenade/textures/particle/maple_leaf/fulvous.png index 2f5b2585ab13e5944b331d2036ba2972bf0be9be..2c70b76b6843adb65844a22e3215eeb5d6223eb8 100644 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$63?z4LymlQ(F%}28J29*~C-V}>;ScZ$aRt)d z*33sUxo_9=e4NhWDkN?L6k;t2@(X784+Jt7)IcW5d%8G=aLg1v*2&4hz|-vT`Hg+C k^aSUiUq?A3($;fYG4EqAi&B5+3slPB>FVdQ&MBb@04(w-hyVZp literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~p#Yx{S0H`6 zp66&L_wsPI2xSg0DYhTZnSMY~wvr&fV21x7P*wThA5bL1)5S4FVrpxDAm0H64rk3N zzvC-IkGs^nB{{`&yKG)xU}ErK14F)pZcX#W*Og~ITB4pd1$v#q}N-Ez5x_Y6NA84oN2+QH!I>gTe~DWM4fL4rfy diff --git a/src/main/resources/assets/promenade/textures/particle/maple_leaf/mikado.png b/src/main/resources/assets/promenade/textures/particle/maple_leaf/mikado.png index c9bdbd044a457dc8cd5a189529e79fb4e0612d0d..60d343cb8d8b765e55637728662c0a49e88a3bee 100644 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$63?z4LymlQ(F%}28J29*~C-V}>;ScZ$aRt(K zA*_cx*`Fs3I1Njapa5!sD z`5j*wdfcVnEy*dK+hz0m0uzG=8yNB(bZeR~zOFp$(NeuZU1B4{wO;~)t0jFbo%ApA v1;ScZ$aRt($ z?0l_);FVdQ&MBb@0NPV0rvLx| literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~p#Yx{S0H^> zLw%>T)N(%F6h1L09+plX|4%?swvr&fV21x7P*wThA5bL1)5S4FVrpxDAm0H64rk3N zzvC-IkGs^nB{{`&yKG)xU}ErK14F)pZcX#W*Og~ITB4pd1$v#q}N-Ez5x_Y6NA84oN2+QH!I>gTe~DWM4ftq(%k