Skip to content

Commit

Permalink
1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yurisuika committed Oct 16, 2024
1 parent 9da970c commit 7b54abe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
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 = forge

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

forge_version = 1.20.4-49.1.12
forge_version = 1.20.6-50.1.20
25 changes: 12 additions & 13 deletions src/main/java/dev/yurisuika/blossom/Blossom.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.Bee;
import net.minecraft.world.item.*;
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;
Expand Down Expand Up @@ -137,21 +138,19 @@ public static void clientSetup(FMLClientSetupEvent event) {
ItemBlockRenderTypes.setRenderLayer(Blossom.FRUITING_OAK_LEAVES.get(), RenderType.cutout());

ItemProperties.register(FLOWERING_OAK_LEAVES.get().asItem(), new ResourceLocation("age"), (stack, world, entity, seed) -> {
CompoundTag tag = stack.getTagElement("BlockStateTag");
try {
if (Objects.nonNull(tag) && Objects.nonNull(tag.get(FloweringLeavesBlock.AGE.getName()))) {
return Integer.parseInt(tag.get(FloweringLeavesBlock.AGE.getName()).getAsString()) / 4.0F;
}
} catch (NumberFormatException ignored) {}
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;
});
ItemProperties.register(FRUITING_OAK_LEAVES.get().asItem(), new ResourceLocation("age"), (stack, world, entity, seed) -> {
CompoundTag tag = stack.getTagElement("BlockStateTag");
try {
if (Objects.nonNull(tag) && Objects.nonNull(tag.get(FloweringLeavesBlock.AGE.getName()))) {
return Integer.parseInt(tag.get(FloweringLeavesBlock.AGE.getName()).getAsString()) / 8.0F;
}
} catch (NumberFormatException ignored) {}
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;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
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 @@ -247,12 +248,12 @@ 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) {
public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
Item item = itemStack.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));
itemStack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand));
if (!level.isClientSide()) {
player.awardStat(Stats.ITEM_USED.get(item));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
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 @@ -253,14 +254,14 @@ 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) {
public InteractionResult useItemOn(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
ItemStack itemStack = player.getItemInHand(hand);
if (isMaxAge(state)) {
Item item = itemStack.getItem();
if (item instanceof ShearsItem) {
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.CROP_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
dropFruit(level, pos, shearedItem, (itemStack.isEnchanted() && EnchantmentHelper.getEnchantments(itemStack).containsKey(Enchantments.BLOCK_FORTUNE)) ? EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, itemStack) : 0);
itemStack.hurtAndBreak(1, player, entity -> entity.broadcastBreakEvent(hand));
dropFruit(level, pos, shearedItem, (itemStack.isEnchanted() && EnchantmentHelper.getEnchantmentsForCrafting(itemStack).entrySet().contains(Enchantments.FORTUNE)) ? EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FORTUNE, itemStack) : 0);
itemStack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(hand));
if (!level.isClientSide()) {
player.awardStat(Stats.ITEM_USED.get(item));
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "48,)"
loaderVersion = "50,)"
license = "GNU Lesser General Public License v3.0"

[[mods]]
Expand All @@ -18,13 +18,13 @@ Apples blossom upon leaves by the pollen from bees!
[[dependencies.blossom]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20.2,1.20.4]"
versionRange = "[1.20.5,1.20.6]"
ordering = "NONE"
side = "BOTH"

[[dependencies.blossom]]
modId = "forge"
mandatory = true
versionRange = "[48,)"
versionRange = "[50,)"
ordering = "NONE"
side = "BOTH"

0 comments on commit 7b54abe

Please sign in to comment.