diff --git a/CHANGELOG.md b/CHANGELOG.md index 76521cb97..849d4014b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 1.4.5 - Add Spanish (Chile) Translations (es_cl) (Credits: Ganbare-Lucifer) (#172) +- Generalize Particle Registration # 1.4.4 - Add Russian Translations (ru_ru) (Credits: j-tap) diff --git a/Common/src/main/java/net/potionstudios/biomeswevegone/client/BiomesWeveGoneClient.java b/Common/src/main/java/net/potionstudios/biomeswevegone/client/BiomesWeveGoneClient.java index 52a911eaf..685272308 100644 --- a/Common/src/main/java/net/potionstudios/biomeswevegone/client/BiomesWeveGoneClient.java +++ b/Common/src/main/java/net/potionstudios/biomeswevegone/client/BiomesWeveGoneClient.java @@ -5,11 +5,14 @@ import net.minecraft.client.model.ChestBoatModel; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.renderer.Sheets; import net.minecraft.client.renderer.blockentity.*; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.SimpleParticleType; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.block.entity.BlockEntity; @@ -17,6 +20,9 @@ import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.levelgen.XoroshiroRandomSource; import net.minecraft.world.level.levelgen.synth.ImprovedNoise; +import net.potionstudios.biomeswevegone.client.particle.BWGParticles; +import net.potionstudios.biomeswevegone.client.particle.particles.FallingLeafParticle; +import net.potionstudios.biomeswevegone.client.particle.particles.FireFlyParticle; import net.potionstudios.biomeswevegone.client.renderer.BWGBoatRenderer; import net.potionstudios.biomeswevegone.world.entity.BWGEntities; import net.potionstudios.biomeswevegone.world.entity.boats.BWGBoatEntity; @@ -28,6 +34,7 @@ import java.awt.*; import java.util.function.BiConsumer; +import java.util.function.Function; import java.util.function.Supplier; /** @@ -88,6 +95,22 @@ public static void registerLayerDefinitions(BiConsumer>> consumer) { + consumer.accept(BWGParticles.FIREFLY.get(), FireFlyParticle.Provider::new); + consumer.accept(BWGParticles.BOREALIS_GLINT.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.WITCH_HAZEL_LEAVES.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.WHITE_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.YELLOW_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.RED_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.SILVER_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); + consumer.accept(BWGParticles.IRONWOOD_LEAVES.get(), FallingLeafParticle.Provider::new); + } + + private static final ImprovedNoise NOISE = new ImprovedNoise(new XoroshiroRandomSource(1)); public static int getBorealisIceColor(BlockPos pos) { diff --git a/Fabric/src/main/java/net/potionstudios/biomeswevegone/fabric/client/BiomesWeveGoneClientFabric.java b/Fabric/src/main/java/net/potionstudios/biomeswevegone/fabric/client/BiomesWeveGoneClientFabric.java index 1a2bc7f7d..018472ab7 100644 --- a/Fabric/src/main/java/net/potionstudios/biomeswevegone/fabric/client/BiomesWeveGoneClientFabric.java +++ b/Fabric/src/main/java/net/potionstudios/biomeswevegone/fabric/client/BiomesWeveGoneClientFabric.java @@ -18,9 +18,6 @@ import net.minecraft.world.level.GrassColor; import net.minecraft.world.level.block.*; import net.potionstudios.biomeswevegone.client.BiomesWeveGoneClient; -import net.potionstudios.biomeswevegone.client.particle.BWGParticles; -import net.potionstudios.biomeswevegone.client.particle.particles.FallingLeafParticle; -import net.potionstudios.biomeswevegone.client.particle.particles.FireFlyParticle; import net.potionstudios.biomeswevegone.world.level.block.BWGBlocks; import net.potionstudios.biomeswevegone.world.level.block.custom.BWGSpreadableBlock; import net.potionstudios.biomeswevegone.world.level.block.plants.cactus.BWGCactusBlock; @@ -44,7 +41,7 @@ public void onInitializeClient() { registerRenderTypes(); BiomesWeveGoneClient.registerEntityRenderers(EntityRendererRegistry::register); BiomesWeveGoneClient.registerBlockEntityRenderers(BlockEntityRenderers::register); - registerParticles(); + BiomesWeveGoneClient.registerParticles((type, spriteProviderFactory) -> ParticleFactoryRegistry.getInstance().register(type, spriteProviderFactory::apply)); BiomesWeveGoneClient.registerLayerDefinitions((a, b) -> EntityModelLayerRegistry.registerModelLayer(a, b::get)); registerColorChangingBlocks(); } @@ -70,17 +67,6 @@ else if (block instanceof StainedGlassPaneBlock || block instanceof HalfTranspar BlockRenderLayerMap.INSTANCE.putBlock(block, RenderType.translucent()); } - private void registerParticles() { - ParticleFactoryRegistry.getInstance().register(BWGParticles.FIREFLY.get(), FireFlyParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.BOREALIS_GLINT.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.WITCH_HAZEL_LEAVES.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.WHITE_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.YELLOW_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.RED_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.SILVER_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); - ParticleFactoryRegistry.getInstance().register(BWGParticles.IRONWOOD_LEAVES.get(), FallingLeafParticle.Provider::new); - } - private void registerColorChangingBlocks() { ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> view != null && pos != null ? BiomeColors.getAverageGrassColor(view, pos) : GrassColor.getDefaultColor(), BWGBlocks.FLOWER_PATCH.get(), BWGBlocks.TINY_LILY_PADS.get(), BWGBlocks.FLOWERING_TINY_LILY_PADS.get(), BWGBlocks.OVERGROWN_DACITE.get(), BWGBlocks.OVERGROWN_STONE.get(), BWGBlocks.LUSH_GRASS_BLOCK.get(), BWGBlocks.WHITE_SAKURA_PETALS.get(), BWGBlocks.YELLOW_SAKURA_PETALS.get()); ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> view != null && pos != null ? BiomeColors.getAverageFoliageColor(view, pos) : FoliageColor.get(0.5D, 1.0D), BWGBlocks.CLOVER_PATCH.get(), BWGBlocks.LEAF_PILE.get(), BWGBlocks.POISON_IVY.get(), BWGWood.MAHOGANY.leaves(), diff --git a/Forge/src/main/java/net/potionstudios/biomeswevegone/forge/client/BiomesWeveGoneClientForge.java b/Forge/src/main/java/net/potionstudios/biomeswevegone/forge/client/BiomesWeveGoneClientForge.java index 96b79290a..73f4cebb5 100644 --- a/Forge/src/main/java/net/potionstudios/biomeswevegone/forge/client/BiomesWeveGoneClientForge.java +++ b/Forge/src/main/java/net/potionstudios/biomeswevegone/forge/client/BiomesWeveGoneClientForge.java @@ -15,9 +15,6 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.potionstudios.biomeswevegone.client.BiomesWeveGoneClient; -import net.potionstudios.biomeswevegone.client.particle.BWGParticles; -import net.potionstudios.biomeswevegone.client.particle.particles.FallingLeafParticle; -import net.potionstudios.biomeswevegone.client.particle.particles.FireFlyParticle; import net.potionstudios.biomeswevegone.world.level.block.BWGBlocks; import net.potionstudios.biomeswevegone.world.level.block.wood.BWGWood; @@ -41,7 +38,7 @@ public static void init(IEventBus eventBus) { eventBus.addListener(BiomesWeveGoneClientForge::forgeClientSetup); eventBus.addListener((Consumer) event -> BiomesWeveGoneClient.registerEntityRenderers(event::registerEntityRenderer)); eventBus.addListener((Consumer) event -> BiomesWeveGoneClient.registerBlockEntityRenderers(event::registerBlockEntityRenderer)); - eventBus.addListener(BiomesWeveGoneClientForge::registerParticles); + eventBus.addListener((RegisterParticleProvidersEvent event) -> BiomesWeveGoneClient.registerParticles((type, spriteProviderFactory) -> event.registerSpriteSet(type, spriteProviderFactory::apply))); eventBus.addListener((Consumer) event -> BiomesWeveGoneClient.registerLayerDefinitions(event::registerLayerDefinition)); eventBus.addListener(BiomesWeveGoneClientForge::registerColorChangingBlocks); eventBus.addListener(BiomesWeveGoneClientForge::registerItemColorHandlers); @@ -56,22 +53,6 @@ private static void forgeClientSetup(final FMLClientSetupEvent event) { BiomesWeveGoneClient.onInitialize(Minecraft.getInstance()); } - /** - * Registers the custom particles for the mod. - * @param event The event to register the particles to. - * @see RegisterParticleProvidersEvent - */ - private static void registerParticles(final RegisterParticleProvidersEvent event) { - event.registerSpriteSet(BWGParticles.FIREFLY.get(), FireFlyParticle.Provider::new); - event.registerSpriteSet(BWGParticles.BOREALIS_GLINT.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.WITCH_HAZEL_LEAVES.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.WHITE_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.YELLOW_SAKURA_LEAVES.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.RED_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.SILVER_MAPLE_LEAVES.get(), FallingLeafParticle.Provider::new); - event.registerSpriteSet(BWGParticles.IRONWOOD_LEAVES.get(), FallingLeafParticle.Provider::new); - } - /** * Registers the blocks that change color based on the biome. * @param event The event to register the blocks to.