Skip to content

Commit

Permalink
Changes far too numerous to enumerate.
Browse files Browse the repository at this point in the history
  • Loading branch information
yurisuika committed Dec 11, 2024
1 parent 267ec4a commit d0e0589
Show file tree
Hide file tree
Showing 59 changed files with 1,107 additions and 928 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id "fabric-loom" version "1.7-SNAPSHOT"
id "fabric-loom" version "1.9-SNAPSHOT"
id "maven-publish"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -34,7 +34,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

loom {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
org.gradle.jvmargs = -Xmx1G
loom.platform = fabric

minecraft_version = 1.21.2-pre4
parchment_version = 2024.07.28
minecraft_version = 1.21.3
parchment_version = 2024.11.10

mod_id = blossom
mod_author = yurisuika
mod_version = 2.0.0
maven_group = dev.yurisuika.blossom
archives_base_name = blossom

fabric_version = 0.106.0+1.21.2
loader_version = 0.16.7
fabric_version = 0.107.3+1.21.3
loader_version = 0.16.9
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
153 changes: 44 additions & 109 deletions src/main/java/dev/yurisuika/blossom/Blossom.java
Original file line number Diff line number Diff line change
@@ -1,187 +1,122 @@
package dev.yurisuika.blossom;

import dev.yurisuika.blossom.client.particle.BlossomParticle;
import dev.yurisuika.blossom.mixin.world.level.block.BlocksInvoker;
import dev.yurisuika.blossom.client.particle.FallingPetalsParticle;
import dev.yurisuika.blossom.core.particles.BlossomParticleTypes;
import dev.yurisuika.blossom.server.commands.BlossomCommand;
import dev.yurisuika.blossom.util.Validate;
import dev.yurisuika.blossom.util.config.Config;
import dev.yurisuika.blossom.world.entity.ai.goal.BlossomGoal;
import dev.yurisuika.blossom.world.entity.ai.goal.FruitGoal;
import dev.yurisuika.blossom.world.entity.animal.BeeInterface;
import dev.yurisuika.blossom.world.level.block.BlossomBlocks;
import dev.yurisuika.blossom.world.level.block.FloweringLeavesBlock;
import dev.yurisuika.blossom.world.level.block.FruitingLeavesBlock;
import dev.yurisuika.blossom.world.level.item.BlossomItems;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.animal.Bee;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.BlockItemStateProperties;
import net.minecraft.world.level.FoliageColor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.PushReaction;

import java.util.Objects;

public class Blossom implements ModInitializer {

public static final Block FRUITING_OAK_LEAVES = new FruitingLeavesBlock(Blocks.OAK_LEAVES, Items.APPLE, BlockBehaviour.Properties.of()
.mapColor(MapColor.PLANT)
.strength(0.2F)
.randomTicks()
.sound(SoundType.GRASS)
.noOcclusion()
.isValidSpawn(BlocksInvoker::invokeOcelotOrParrot)
.isSuffocating(BlocksInvoker::invokeNever)
.isViewBlocking(BlocksInvoker::invokeNever)
.ignitedByLava()
.pushReaction(PushReaction.DESTROY)
.isRedstoneConductor(BlocksInvoker::invokeNever));
public static final Block FLOWERING_OAK_LEAVES = new FloweringLeavesBlock(Blocks.OAK_LEAVES, Blossom.FRUITING_OAK_LEAVES, BlockBehaviour.Properties.of()
.mapColor(MapColor.PLANT)
.strength(0.2F)
.randomTicks()
.sound(SoundType.GRASS)
.noOcclusion()
.isValidSpawn(BlocksInvoker::invokeOcelotOrParrot)
.isSuffocating(BlocksInvoker::invokeNever)
.isViewBlocking(BlocksInvoker::invokeNever)
.ignitedByLava()
.pushReaction(PushReaction.DESTROY)
.isRedstoneConductor(BlocksInvoker::invokeNever));

public static final SimpleParticleType BLOSSOM = FabricParticleTypes.simple(false);

public static void registerBlocks() {
Registry.register(BuiltInRegistries.BLOCK, ResourceLocation.fromNamespaceAndPath("blossom", "flowering_oak_leaves"), FLOWERING_OAK_LEAVES);
Registry.register(BuiltInRegistries.BLOCK, ResourceLocation.fromNamespaceAndPath("blossom", "fruiting_oak_leaves"), FRUITING_OAK_LEAVES);
}

public static void registerItems() {
Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath("blossom", "flowering_oak_leaves"), new BlockItem(FLOWERING_OAK_LEAVES, new Item.Properties()));
Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath("blossom", "fruiting_oak_leaves"), new BlockItem(FRUITING_OAK_LEAVES, new Item.Properties()));
}

public static void registerParticles() {
Registry.register(BuiltInRegistries.PARTICLE_TYPE, ResourceLocation.fromNamespaceAndPath("blossom", "blossom"), BLOSSOM);
}

public static void registerCompostables() {
CompostingChanceRegistry.INSTANCE.add(FLOWERING_OAK_LEAVES, 0.3F);
CompostingChanceRegistry.INSTANCE.add(FRUITING_OAK_LEAVES, 0.3F);
CompostingChanceRegistry.INSTANCE.add(BlossomBlocks.FRUITING_OAK_LEAVES, 0.3F);
CompostingChanceRegistry.INSTANCE.add(BlossomBlocks.FLOWERING_OAK_LEAVES, 0.3F);
}

public static void registerFlammables() {
FlammableBlockRegistry.getDefaultInstance().add(FLOWERING_OAK_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(FRUITING_OAK_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(BlossomBlocks.FRUITING_OAK_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(BlossomBlocks.FLOWERING_OAK_LEAVES, 30, 60);
}

public static void registerItemGroupEvents() {
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.NATURAL_BLOCKS).register(content -> {
content.addAfter(Items.FLOWERING_AZALEA_LEAVES, FLOWERING_OAK_LEAVES.asItem(), FRUITING_OAK_LEAVES.asItem());
});
public static void registerCreativeModeTabs() {
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.NATURAL_BLOCKS).register(content -> content.addAfter(Items.FLOWERING_AZALEA_LEAVES, BlossomBlocks.FLOWERING_OAK_LEAVES.asItem(), BlossomBlocks.FRUITING_OAK_LEAVES.asItem()));
}

public static void registerCommands() {
CommandRegistrationCallback.EVENT.register(BlossomCommand::register);
}

public static void registerServerEntityEvents() {
public static void registerGoals() {
ServerEntityEvents.ENTITY_LOAD.register((entity, level) -> {
if (entity instanceof Bee) {
((Bee) entity).getGoalSelector().addGoal(4, new BlossomGoal((Bee) entity));
((Bee) entity).getGoalSelector().addGoal(4, new FruitGoal((Bee) entity));
((BeeInterface) entity).registerGoals((Bee) entity);
}
});
}

public static void registerCommands() {
CommandRegistrationCallback.EVENT.register(BlossomCommand::register);
}

@Override
public void onInitialize() {
Config.loadConfig();
Validate.checkBounds();

registerBlocks();
registerItems();
registerParticles();
BlossomBlocks.register();
BlossomItems.register();
BlossomParticleTypes.register();
registerFlammables();
registerCompostables();
registerItemGroupEvents();
registerServerEntityEvents();
registerCreativeModeTabs();
registerCommands();
registerGoals();
}

public static class Client implements ClientModInitializer {

@Environment(EnvType.CLIENT)
public static void registerParticleFactories() {
ParticleFactoryRegistry.getInstance().register(BLOSSOM, BlossomParticle.Factory::new);
public static void registerParticles() {
ParticleFactoryRegistry.getInstance().register(BlossomParticleTypes.FLOWERING_OAK_LEAVES, FallingPetalsParticle.FloweringOakProvider::new);
}

@Environment(EnvType.CLIENT)
public static void registerRenderLayers() {
BlockRenderLayerMap.INSTANCE.putBlock(FLOWERING_OAK_LEAVES, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(FRUITING_OAK_LEAVES, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(BlossomBlocks.FRUITING_OAK_LEAVES, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(BlossomBlocks.FLOWERING_OAK_LEAVES, RenderType.cutout());
}

@Environment(EnvType.CLIENT)
public static void registerColorProviders() {
ColorProviderRegistry.BLOCK.register((state, level, pos, tintIndex) -> level != null && pos != null ? BiomeColors.getAverageFoliageColor(level, pos) : FoliageColor.get(0.5F, 1.0F), FLOWERING_OAK_LEAVES);
ColorProviderRegistry.BLOCK.register((state, level, pos, tintIndex) -> level != null && pos != null ? BiomeColors.getAverageFoliageColor(level, pos) : FoliageColor.get(0.5F, 1.0F), FRUITING_OAK_LEAVES);
public static void registerBlockColors() {
ColorProviderRegistry.BLOCK.register((state, level, pos, tintIndex) -> level != null && pos != null ? BiomeColors.getAverageFoliageColor(level, pos) : FoliageColor.get(0.5F, 1.0F), BlossomBlocks.FRUITING_OAK_LEAVES);
ColorProviderRegistry.BLOCK.register((state, level, pos, tintIndex) -> level != null && pos != null ? BiomeColors.getAverageFoliageColor(level, pos) : FoliageColor.get(0.5F, 1.0F), BlossomBlocks.FLOWERING_OAK_LEAVES);
}

ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : Minecraft.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().defaultBlockState(), null, null, tintIndex), FLOWERING_OAK_LEAVES);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : Minecraft.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().defaultBlockState(), null, null, tintIndex), FRUITING_OAK_LEAVES);
public static void registerItemColors() {
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : Minecraft.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().defaultBlockState(), null, null, tintIndex), BlossomBlocks.FRUITING_OAK_LEAVES);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : Minecraft.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().defaultBlockState(), null, null, tintIndex), BlossomBlocks.FLOWERING_OAK_LEAVES);
}

@Environment(EnvType.CLIENT)
public static void registerModelPredicateProviders() {
ItemProperties.register(FLOWERING_OAK_LEAVES.asItem(), ResourceLocation.parse("age"), (stack, world, entity, seed) -> {
BlockItemStateProperties blockItemStateProperties = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY);
Integer integer = blockItemStateProperties.get(FloweringLeavesBlock.AGE);
if (Objects.nonNull(integer)) {
return integer.intValue() / 4.0F;
}
return 0.0F;
public static void registerItemProperties() {
ItemProperties.register(BlossomItems.FRUITING_OAK_LEAVES, ResourceLocation.tryParse("age"), (stack, world, entity, seed) -> {
Integer integer = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY).get(FruitingLeavesBlock.AGE);
return Objects.nonNull(integer) ? integer / 8.0F : 0.0F;
});
ItemProperties.register(FRUITING_OAK_LEAVES.asItem(), ResourceLocation.parse("age"), (stack, world, entity, seed) -> {
BlockItemStateProperties blockItemStateProperties = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY);
Integer integer = blockItemStateProperties.get(FruitingLeavesBlock.AGE);
if (Objects.nonNull(integer)) {
return integer.intValue() / 8.0F;
}
return 0.0F;
ItemProperties.register(BlossomItems.FLOWERING_OAK_LEAVES, ResourceLocation.tryParse("age"), (stack, world, entity, seed) -> {
Integer integer = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY).get(FloweringLeavesBlock.AGE);
return Objects.nonNull(integer) ? integer / 4.0F : 0.0F;
});
}

@Override
public void onInitializeClient() {
registerParticleFactories();
registerParticles();
registerRenderLayers();
registerColorProviders();
registerModelPredicateProviders();
registerBlockColors();
registerItemColors();
registerItemProperties();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package dev.yurisuika.blossom.client.particle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;

@Environment(EnvType.CLIENT)
public class BlossomParticle extends TextureSheetParticle {
public class FallingPetalsParticle extends TextureSheetParticle {

public float rotSpeed;
public final float particleRandom;
public final float spinAcceleration;

public BlossomParticle(ClientLevel level, double x, double y, double z, SpriteSet spriteSet) {
public FallingPetalsParticle(ClientLevel level, double x, double y, double z, SpriteSet spriteSet) {
super(level, x, y, z);
this.setSprite(spriteSet.get(random.nextInt(12), 12));
this.rotSpeed = (float)Math.toRadians(random.nextBoolean() ? -30.0F : 30.0F);
this.rotSpeed = (float) Math.toRadians(random.nextBoolean() ? -30.0F : 30.0F);
this.particleRandom = random.nextFloat();
this.spinAcceleration = (float)Math.toRadians(random.nextBoolean() ? -5.0F : 5.0F);
this.spinAcceleration = (float) Math.toRadians(random.nextBoolean() ? -5.0F : 5.0F);
this.lifetime = 300;
this.gravity = 7.5E-4F;
float f = this.random.nextBoolean() ? 0.05F : 0.075F;
Expand All @@ -31,11 +28,10 @@ public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}

@Environment(EnvType.CLIENT)
public record Factory(SpriteSet spriteSet) implements ParticleProvider<SimpleParticleType> {
public record FloweringOakProvider(SpriteSet spriteSet) implements ParticleProvider<SimpleParticleType> {

public Particle createParticle(SimpleParticleType parameters, ClientLevel level, double x, double y, double z, double r, double g, double b) {
return new BlossomParticle(level, x, y, z, spriteSet);
return new FallingPetalsParticle(level, x, y, z, spriteSet);
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/yurisuika/blossom/config/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class Options {

public Value value = new Value(
new Blossoming(0.2F, 10.0D),
new Fruiting(0.2F, 10.0D),
new Harvesting(3, 0.5714286F)
new Blossoming(0.2F),
new Fruiting(0.2F),
new Harvesting(0.5714286F, 3)
);
public Filter filter = new Filter(
new Temperature(-2.0F, 2.0F),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dev.yurisuika.blossom.core.particles;

import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;

public class BlossomParticleTypes {

public static final SimpleParticleType FLOWERING_OAK_LEAVES = FabricParticleTypes.simple(false);

public static void register() {
Registry.register(BuiltInRegistries.PARTICLE_TYPE, ResourceLocation.fromNamespaceAndPath("blossom", "flowering_oak_leaves"), FLOWERING_OAK_LEAVES);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.yurisuika.blossom.mixin.world.entity;

import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(Entity.class)
public abstract class EntityMixin {

@Shadow
public abstract Level level();

@Final
@Shadow
protected RandomSource random;

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(Goal.class)
public interface GoalInvoker {
public interface
GoalInvoker {

@Invoker("adjustedTickDelay")
int invokeAdjustedTickDelay(int ticks);
Expand Down
Loading

0 comments on commit d0e0589

Please sign in to comment.