Skip to content

Commit

Permalink
NeoForge 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yurisuika committed Dec 11, 2024
1 parent b9a8405 commit c27439b
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 106 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
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 All @@ -27,14 +27,14 @@ dependencies {
processResources {
inputs.property "version", project.mod_version

filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.mod_version
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}

loom {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
org.gradle.jvmargs = -Xmx3G
loom.platform = neoforge

minecraft_version = 1.20.4
parchment_version = 2024.04.14
minecraft_version = 1.20.6
parchment_version = 2024.06.16

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

neo_version = 20.4.234
neo_version = 20.6.52-beta
18 changes: 10 additions & 8 deletions src/main/java/dev/yurisuika/blossom/Blossom.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.animal.Bee;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
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.Blocks;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
Expand All @@ -43,7 +45,7 @@
@Mod("blossom")
public class Blossom {

@Mod.EventBusSubscriber(modid = "blossom")
@EventBusSubscriber(modid = "blossom")
public static class CommonForgeEvents {

@SubscribeEvent
Expand All @@ -60,7 +62,7 @@ public static void registerGoals(EntityJoinLevelEvent event) {

}

@Mod.EventBusSubscriber(modid = "blossom", bus = Mod.EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = "blossom", bus = EventBusSubscriber.Bus.MOD)
public static class CommonModBusEvents {

@SubscribeEvent
Expand All @@ -77,7 +79,7 @@ public static void registerFlammables(FMLCommonSetupEvent event) {

}

@Mod.EventBusSubscriber(modid = "blossom", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(modid = "blossom", bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModBusEvents {

@SubscribeEvent
Expand All @@ -94,12 +96,12 @@ public static void registerRenderLayers(FMLClientSetupEvent event) {
@SubscribeEvent
public static void registerItemProperties(FMLClientSetupEvent event) {
ItemProperties.register(BlossomItems.FRUITING_OAK_LEAVES.get(), ResourceLocation.tryParse("age"), (stack, world, entity, seed) -> {
CompoundTag tag = stack.getTagElement("BlockStateTag");
return Objects.nonNull(tag) ? Integer.parseInt(tag.get(FruitingLeavesBlock.AGE.getName()).getAsString()) / 8.0F : 0.0F;
Integer integer = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY).get(FruitingLeavesBlock.AGE);
return Objects.nonNull(integer) ? integer / 8.0F : 0.0F;
});
ItemProperties.register(BlossomItems.FLOWERING_OAK_LEAVES.get(), ResourceLocation.tryParse("age"), (stack, world, entity, seed) -> {
CompoundTag tag = stack.getTagElement("BlockStateTag");
return Objects.nonNull(tag) ? Integer.parseInt(tag.get(FloweringLeavesBlock.AGE.getName()).getAsString()) / 4.0F : 0.0F;
Integer integer = stack.getOrDefault(DataComponents.BLOCK_STATE, BlockItemStateProperties.EMPTY).get(FloweringLeavesBlock.AGE);
return Objects.nonNull(integer) ? integer / 4.0F : 0.0F;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ private void injectAddAdditionalSaveData(CompoundTag compound, CallbackInfo ci)

@Inject(method = "readAdditionalSaveData", at = @At("HEAD"))
private void injectReadAdditionalSaveData(CompoundTag compound, CallbackInfo ci) {
if (compound.contains("leaves_pos")) {
setSavedLeavesPos(NbtUtils.readBlockPos(compound.getCompound("leaves_pos")));
}
setSavedLeavesPos(NbtUtils.readBlockPos(compound, "leaves_pos").orElse(null));
}

@Inject(method = "getTravellingTicks", at = @At("RETURN"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package dev.yurisuika.blossom.world.level.block;

import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.yurisuika.blossom.core.particles.BlossomParticleTypes;
import dev.yurisuika.blossom.mixin.world.level.biome.BiomeAccessor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand All @@ -14,7 +17,8 @@
import net.minecraft.util.ParticleUtils;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -46,12 +50,17 @@ public class FloweringLeavesBlock extends LeavesBlock implements BonemealableBlo

public final Block shearedBlock;
public final Block pollinatedBlock;
public static final MapCodec<FloweringLeavesBlock> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("shearedBlock").forGetter(arg -> arg.shearedBlock), BuiltInRegistries.BLOCK.byNameCodec().fieldOf("pollinatedBlock").forGetter(arg -> arg.pollinatedBlock), propertiesCodec()).apply(instance, FloweringLeavesBlock::new));
public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE;
public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final IntegerProperty AGE = BlockStateProperties.AGE_3;
public static final IntegerProperty RIPENESS = IntegerProperty.create("ripeness", 0, 7);

public MapCodec<? extends FloweringLeavesBlock> codec() {
return CODEC;
}

public FloweringLeavesBlock(Block shearedBlock, Block pollinatedBlock, Properties properties) {
super(properties);
this.shearedBlock = shearedBlock;
Expand Down Expand Up @@ -251,12 +260,11 @@ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos
applyGrowth(level, pos, state);
}

public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
Item item = itemStack.getItem();
public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
Item item = stack.getItem();
if (item instanceof ShearsItem) {
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.CROP_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
itemStack.hurtAndBreak(1, player, entity -> entity.broadcastBreakEvent(hand));
stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand));
if (!level.isClientSide()) {
player.awardStat(Stats.ITEM_USED.get(item));
}
Expand All @@ -266,9 +274,9 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
.setValue(PERSISTENT, state.getValue(PERSISTENT))
.setValue(WATERLOGGED, state.getValue(WATERLOGGED))
);
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package dev.yurisuika.blossom.world.level.block;

import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.yurisuika.blossom.mixin.world.level.biome.BiomeAccessor;
import dev.yurisuika.blossom.util.config.Option;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand All @@ -13,7 +16,8 @@
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -48,12 +52,17 @@ public class FruitingLeavesBlock extends LeavesBlock implements BonemealableBloc

public final Block shearedBlock;
public final Item shearedItem;
public static final MapCodec<FruitingLeavesBlock> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("shearedBlock").forGetter(arg -> arg.shearedBlock), BuiltInRegistries.ITEM.byNameCodec().fieldOf("shearedItem").forGetter(arg -> arg.shearedItem), propertiesCodec()).apply(instance, FruitingLeavesBlock::new));
public static final IntegerProperty DISTANCE = BlockStateProperties.DISTANCE;
public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final IntegerProperty AGE = BlockStateProperties.AGE_7;
public static final IntegerProperty RIPENESS = IntegerProperty.create("ripeness", 0, 7);

public MapCodec<? extends FruitingLeavesBlock> codec() {
return CODEC;
}

public FruitingLeavesBlock(Block shearedBlock, Item shearedItem, Properties properties) {
super(properties);
this.shearedBlock = shearedBlock;
Expand Down Expand Up @@ -253,15 +262,11 @@ public static void dropFruit(Level level, BlockPos pos, Item item, int bonus) {
popResource(level, pos, new ItemStack(item, count));
}

public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
Item item = itemStack.getItem();
public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
Item item = stack.getItem();
if (item instanceof ShearsItem) {
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.CROP_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
if (isMaxAge(state)) {
dropFruit(level, pos, getShearedItem(), (itemStack.isEnchanted() && EnchantmentHelper.getEnchantments(itemStack).containsKey(Enchantments.BLOCK_FORTUNE)) ? EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, itemStack) : 0);
}
itemStack.hurtAndBreak(1, player, entity -> entity.broadcastBreakEvent(hand));
stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand));
if (!level.isClientSide()) {
player.awardStat(Stats.ITEM_USED.get(item));
}
Expand All @@ -271,9 +276,9 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
.setValue(PERSISTENT, state.getValue(PERSISTENT))
.setValue(WATERLOGGED, state.getValue(WATERLOGGED))
);
return InteractionResult.SUCCESS;
return ItemInteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ config = "blossom.mixins.json"

[[dependencies.blossom]]
modId = "minecraft"
mandatory = true
type = "required"
versionRange = "[1.20.2,1.20.4]"
versionRange = "[1.20.5,1.20.6]"
ordering = "NONE"
side = "BOTH"

[[dependencies.blossom]]
modId = "neoforge"
mandatory = true
type = "required"
versionRange = "[20.2,)"
versionRange = "[20.5,)"
ordering = "NONE"
side = "BOTH"
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
"predicates": {
"minecraft:enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
}
]
]
}
}
}
],
Expand All @@ -41,9 +43,7 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
"items": "minecraft:shears"
}
}
],
Expand Down Expand Up @@ -84,22 +84,22 @@
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
"items": "minecraft:shears"
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
"predicates": {
"minecraft:enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
}
]
]
}
}
}
]
Expand Down
Loading

0 comments on commit c27439b

Please sign in to comment.