diff --git a/src/main/java/dev/yurisuika/blossom/Blossom.java b/src/main/java/dev/yurisuika/blossom/Blossom.java index f3134933..1d344abd 100644 --- a/src/main/java/dev/yurisuika/blossom/Blossom.java +++ b/src/main/java/dev/yurisuika/blossom/Blossom.java @@ -27,20 +27,21 @@ import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ColorHandlerEvent; -import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; +import net.minecraftforge.client.event.RegisterColorHandlersEvent; +import net.minecraftforge.client.event.RegisterParticleProvidersEvent; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.fmllegacy.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import java.io.File; import java.io.FileWriter; @@ -284,7 +285,7 @@ public static void checkBounds() { public static RegistryObject register(String name, Supplier supplier, Item.Settings settings) { RegistryObject block = BLOCKS.register(name, supplier); - ITEMS.register(name, () -> new BlockItem(block.get(), settings.group(ItemGroup.DECORATIONS))); + ITEMS.register(name, () -> new BlockItem(block.get(), settings)); return block; } @@ -293,11 +294,11 @@ public static class CommonForgeEvents { @SubscribeEvent public static void registerCommandsEvents(RegisterCommandsEvent event) { - BlossomCommand.register(event.getDispatcher(), event.getEnvironment()); + BlossomCommand.register(event.getDispatcher(), event.getBuildContext(), event.getCommandSelection()); } @SubscribeEvent - public static void entityJoinWorldEvents(EntityJoinWorldEvent event) { + public static void entityJoinLevelEvents(EntityJoinLevelEvent event) { Entity entity = event.getEntity(); if (entity instanceof BeeEntity) { ((BeeEntity)entity).getGoalSelector().add(4, new BlossomGoal((BeeEntity)entity)); @@ -320,7 +321,7 @@ public static void commonSetup(FMLCommonSetupEvent event) { } @SubscribeEvent - public static void particleFactoryRegisterEvents(ParticleFactoryRegisterEvent event) { + public static void registerParticleProvidersEvents(RegisterParticleProvidersEvent event) { MinecraftClient.getInstance().particleManager.registerFactory(BLOSSOM.get(), BlossomParticle.Factory::new); } @@ -356,17 +357,27 @@ public static void clientSetup(FMLClientSetupEvent event) { } @SubscribeEvent - public static void blockColorHandlerEvents(ColorHandlerEvent.Block event) { + public static void registerBlockColorHandlersEvents(RegisterColorHandlersEvent.Block event) { event.getBlockColors().registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getColor(0.5, 1.0), Blossom.FLOWERING_OAK_LEAVES.get()); event.getBlockColors().registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getColor(0.5, 1.0), Blossom.FRUITING_OAK_LEAVES.get()); } @SubscribeEvent - public static void itemColorHandlerEvents(ColorHandlerEvent.Item event) { - event.getItemColors().register((stack, tintIndex) -> tintIndex > 0 ? -1 : MinecraftClient.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), Blossom.FLOWERING_OAK_LEAVES.get()); + public static void registerItemColorHandlersEvents(RegisterColorHandlersEvent.Item event) { + event.getItemColors().register((stack, tintIndex) -> tintIndex > 0 ? -1 : MinecraftClient.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), FLOWERING_OAK_LEAVES.get()); event.getItemColors().register((stack, tintIndex) -> tintIndex > 0 ? -1 : MinecraftClient.getInstance().getBlockColors().getColor(((BlockItem) stack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), FRUITING_OAK_LEAVES.get()); } + @SubscribeEvent + public static void registerCreativeModeTabEvents(CreativeModeTabEvent.BuildContents event) { + if(event.getTab() == ItemGroups.NATURAL) { + event.accept(FLOWERING_OAK_LEAVES); + event.getEntries().putAfter(Items.FLOWERING_AZALEA_LEAVES.getDefaultStack(), FLOWERING_OAK_LEAVES.get().asItem().getDefaultStack(), ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + event.accept(FRUITING_OAK_LEAVES); + event.getEntries().putAfter(FLOWERING_OAK_LEAVES.get().asItem().getDefaultStack(), FRUITING_OAK_LEAVES.get().asItem().getDefaultStack(), ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + } + } public Blossom() { diff --git a/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java b/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java index 3a55286f..a816dadb 100644 --- a/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java +++ b/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java @@ -5,10 +5,13 @@ import net.minecraft.block.Fertilizable; import net.minecraft.block.LeavesBlock; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; import net.minecraft.item.Item; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; import net.minecraft.item.ShearsItem; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -17,7 +20,6 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -25,16 +27,17 @@ import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; import net.minecraft.world.biome.Biome; import net.minecraft.world.event.GameEvent; import java.util.OptionalInt; -import java.util.Random; import static dev.yurisuika.blossom.Blossom.*; @@ -45,6 +48,7 @@ public class FloweringLeavesBlock extends LeavesBlock implements Fertilizable { public static final IntProperty DISTANCE = Properties.DISTANCE_1_7; public static final BooleanProperty PERSISTENT = Properties.PERSISTENT; + public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final IntProperty AGE = Properties.AGE_3; public static final IntProperty RIPENESS = IntProperty.of("ripeness", 0, 7); @@ -52,7 +56,7 @@ public FloweringLeavesBlock(Block shearedBlock, Block pollinatedBlock, Settings super(settings); this.shearedBlock = shearedBlock; this.pollinatedBlock = pollinatedBlock; - setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(AGE, 0).with(RIPENESS, 0)); + setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(WATERLOGGED, false).with(AGE, 0).with(RIPENESS, 0)); } public VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { @@ -99,15 +103,21 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random if (!(Boolean)state.get(PERSISTENT) && state.get(DISTANCE) == 7) { dropStacks(state, world, pos); world.removeBlock(pos, false); + } else if (state.get(WATERLOGGED)) { + world.setBlockState(pos, shearedBlock.getDefaultState() + .with(DISTANCE, state.get(DISTANCE)) + .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) + ); } else if (!isMature(state) && world.getBaseLightLevel(pos, 0) >= 9) { int i = getAge(state); if (i < getMaxAge()) { - float temperature = world.getBiome(pos).getTemperature(); - float downfall = world.getBiome(pos).getDownfall(); + float temperature = world.getBiome(pos).value().getTemperature(); + float downfall = world.getBiome(pos).value().getDownfall(); temperature += 2; float f = (downfall * temperature) / 4; f = ((4 - 1) * f) + 1; - Biome.Precipitation precipitation = world.getBiome(pos).getPrecipitation(); + Biome.Precipitation precipitation = world.getBiome(pos).value().getPrecipitation(); if (world.isRaining() && precipitation == Biome.Precipitation.RAIN) { f = 5.0F; } @@ -115,6 +125,7 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random world.setBlockState(pos, getDefaultState().with(AGE, i + 1) .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) .with(RIPENESS, state.get(RIPENESS)), 2); } } @@ -130,6 +141,7 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random world.setBlockState(pos, shearedBlock.getDefaultState() .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) ); } if (!isMature(state) && state.get(RIPENESS) > 0) { @@ -150,6 +162,7 @@ public void applyGrowth(World world, BlockPos pos, BlockState state) { world.setBlockState(pos, getDefaultState().with(AGE, i) .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) .with(RIPENESS, state.get(RIPENESS)), 2); } @@ -162,9 +175,12 @@ public int getOpacity(BlockState state, BlockView world, BlockPos pos) { } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } int i = getDistanceFromLog(neighborState) + 1; if (i != 1 || state.get(DISTANCE) != i) { - world.getBlockTickScheduler().schedule(pos, this, 1); + world.scheduleBlockTick(pos, this, 1); } return state; } @@ -196,6 +212,10 @@ public static OptionalInt getOptionalDistanceFromLog(BlockState state) { return OptionalInt.empty(); } + public FluidState getFluidState(BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { super.randomDisplayTick(state, world, pos, random); if (random.nextInt(10) != 0) { @@ -211,14 +231,14 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando } public void appendProperties(Builder builder) { - builder.add(DISTANCE, PERSISTENT, AGE, RIPENESS); + builder.add(DISTANCE, PERSISTENT, WATERLOGGED, AGE, RIPENESS); } public BlockState getPlacementState(ItemPlacementContext ctx) { - return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); + return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); } - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { return !isMature(state); } @@ -245,6 +265,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt world.setBlockState(pos, shearedBlock.getDefaultState() .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) ); return ActionResult.SUCCESS; } else { diff --git a/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java b/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java index a2c83b93..8bcae8d9 100644 --- a/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java +++ b/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java @@ -7,10 +7,13 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; import net.minecraft.item.Item; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; import net.minecraft.item.ShearsItem; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -19,7 +22,6 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.Properties; -import net.minecraft.tag.BlockTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -27,16 +29,17 @@ import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; +import net.minecraft.world.WorldView; import net.minecraft.world.biome.Biome; import net.minecraft.world.event.GameEvent; import java.util.OptionalInt; -import java.util.Random; import java.util.concurrent.ThreadLocalRandom; import static dev.yurisuika.blossom.Blossom.*; @@ -48,6 +51,7 @@ public class FruitingLeavesBlock extends LeavesBlock implements Fertilizable { public static final IntProperty DISTANCE = Properties.DISTANCE_1_7; public static final BooleanProperty PERSISTENT = Properties.PERSISTENT; + public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final IntProperty AGE = Properties.AGE_7; public static final IntProperty RIPENESS = IntProperty.of("ripeness", 0, 7); @@ -55,7 +59,7 @@ public FruitingLeavesBlock(Block shearedBlock, Item shearedItem, Settings settin super(settings); this.shearedBlock = shearedBlock; this.shearedItem = shearedItem; - setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(AGE, 0).with(RIPENESS, 0)); + setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(WATERLOGGED, false).with(AGE, 0).with(RIPENESS, 0)); } public VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { @@ -102,15 +106,21 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random if (!(Boolean)state.get(PERSISTENT) && state.get(DISTANCE) == 7) { dropStacks(state, world, pos); world.removeBlock(pos, false); + } else if (state.get(WATERLOGGED)) { + world.setBlockState(pos, shearedBlock.getDefaultState() + .with(DISTANCE, state.get(DISTANCE)) + .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) + ); } else if (!isMature(state) && world.getBaseLightLevel(pos, 0) >= 9) { int i = getAge(state); if (i < getMaxAge()) { - float temperature = world.getBiome(pos).getTemperature(); - float downfall = world.getBiome(pos).getDownfall(); + float temperature = world.getBiome(pos).value().getTemperature(); + float downfall = world.getBiome(pos).value().getDownfall(); temperature += 2; float f = (downfall * temperature) / 4; f = ((4 - 1) * f) + 1; - Biome.Precipitation precipitation = world.getBiome(pos).getPrecipitation(); + Biome.Precipitation precipitation = world.getBiome(pos).value().getPrecipitation(); if (world.isRaining() && precipitation == Biome.Precipitation.RAIN) { f = 5.0F; } @@ -118,6 +128,7 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random world.setBlockState(pos, getDefaultState().with(AGE, i + 1) .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) .with(RIPENESS, state.get(RIPENESS)), 2); } } @@ -134,6 +145,7 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random world.setBlockState(pos, shearedBlock.getDefaultState() .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) ); } if (!isMature(state) && state.get(RIPENESS) > 0) { @@ -154,6 +166,7 @@ public void applyGrowth(World world, BlockPos pos, BlockState state) { world.setBlockState(pos, getDefaultState().with(AGE, i) .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) .with(RIPENESS, state.get(RIPENESS)), 2); } @@ -166,9 +179,12 @@ public int getOpacity(BlockState state, BlockView world, BlockPos pos) { } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { + if (state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } int i = getDistanceFromLog(neighborState) + 1; if (i != 1 || state.get(DISTANCE) != i) { - world.getBlockTickScheduler().schedule(pos, this, 1); + world.scheduleBlockTick(pos, this, 1); } return state; } @@ -200,19 +216,23 @@ public static OptionalInt getOptionalDistanceFromLog(BlockState state) { return OptionalInt.empty(); } + public FluidState getFluidState(BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { super.randomDisplayTick(state, world, pos, random); } public void appendProperties(Builder builder) { - builder.add(DISTANCE, PERSISTENT, AGE, RIPENESS); + builder.add(DISTANCE, PERSISTENT, WATERLOGGED, AGE, RIPENESS); } public BlockState getPlacementState(ItemPlacementContext ctx) { - return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); + return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); } - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { return !isMature(state); } @@ -251,6 +271,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt world.setBlockState(pos, shearedBlock.getDefaultState() .with(DISTANCE, state.get(DISTANCE)) .with(PERSISTENT, state.get(PERSISTENT)) + .with(WATERLOGGED, state.get(WATERLOGGED)) ); } return ActionResult.SUCCESS; diff --git a/src/main/java/dev/yurisuika/blossom/client/particle/BlossomParticle.java b/src/main/java/dev/yurisuika/blossom/client/particle/BlossomParticle.java index d1a0e86d..c7a68c53 100644 --- a/src/main/java/dev/yurisuika/blossom/client/particle/BlossomParticle.java +++ b/src/main/java/dev/yurisuika/blossom/client/particle/BlossomParticle.java @@ -21,7 +21,7 @@ public BlossomParticle(ClientWorld world, double x, double y, double z, SpritePr this.gravityStrength = 7.5E-4F; this.scale = f = random.nextBoolean() ? 0.05F : 0.075F; this.setBoundingBoxSpacing(f, f); - this.field_28786 = 1.0F; + this.velocityMultiplier = 1.0F; } public ParticleTextureSheet getType() { @@ -63,9 +63,9 @@ public void tick() { if (dead) { return; } - velocityX *= field_28786; - velocityY *= field_28786; - velocityZ *= field_28786; + velocityX *= velocityMultiplier; + velocityY *= velocityMultiplier; + velocityZ *= velocityMultiplier; } } \ No newline at end of file diff --git a/src/main/java/dev/yurisuika/blossom/entity/ai/goal/BlossomGoal.java b/src/main/java/dev/yurisuika/blossom/entity/ai/goal/BlossomGoal.java index f0014594..6ad8e9b6 100644 --- a/src/main/java/dev/yurisuika/blossom/entity/ai/goal/BlossomGoal.java +++ b/src/main/java/dev/yurisuika/blossom/entity/ai/goal/BlossomGoal.java @@ -8,10 +8,14 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.passive.BeeEntity; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.sound.SoundEvents; +import net.minecraft.state.property.Properties; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.dimension.DimensionType; @@ -28,7 +32,13 @@ public class BlossomGoal extends Goal { public final BeeEntity entity; - public final Predicate targetPredicate = (state) -> state.isOf(Blocks.OAK_LEAVES); + public final Predicate targetPredicate = (state) -> { + if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { + return false; + } else { + return state.isOf(Blocks.OAK_LEAVES); + } + }; public int blossomingTicks; public int lastBlossomingTick; public boolean running; @@ -42,20 +52,34 @@ public BlossomGoal(BeeEntity beeEntity) { } public boolean checkFilters() { - DimensionType dimension = entity.getEntityWorld().getDimension(); - Biome biome = entity.getEntityWorld().getBiome(entity.getBlockPos()); - float temperature = biome.getTemperature(); - float downfall = biome.getDownfall(); + RegistryEntry dimension = entity.getWorld().getDimensionEntry(); + RegistryEntry biome = entity.getWorld().getBiome(entity.getBlockPos()); + float temperature = biome.value().getTemperature(); + float downfall = biome.value().getDownfall(); AtomicBoolean whitelist = new AtomicBoolean(false); if (config.toggle.whitelist) { Arrays.stream(config.filter.dimension.whitelist).forEach(entry -> { - if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(dimension).toString())) { + if (entry.startsWith("#")) { + TagKey tag = TagKey.of(RegistryKeys.DIMENSION_TYPE, new Identifier(entry.substring(1))); + if (tag != null) { + if (dimension.isIn(tag)) { + whitelist.set(true); + } + } + } else if (Objects.equals(entry, dimension.getKey().get().getValue().toString())) { whitelist.set(true); } }); Arrays.stream(config.filter.biome.whitelist).forEach(entry -> { - if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.BIOME_KEY).getId(biome).toString())) { + if (entry.startsWith("#")) { + TagKey tag = TagKey.of(RegistryKeys.BIOME, new Identifier(entry.substring(1))); + if (tag != null) { + if (biome.isIn(tag)) { + whitelist.set(true); + } + } + } else if (Objects.equals(entry, biome.getKey().get().getValue().toString())) { whitelist.set(true); } }); @@ -64,12 +88,26 @@ public boolean checkFilters() { AtomicBoolean blacklist = new AtomicBoolean(true); if (config.toggle.blacklist) { Arrays.stream(config.filter.dimension.blacklist).forEach(entry -> { - if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(dimension).toString())) { + if (entry.startsWith("#")) { + TagKey tag = TagKey.of(RegistryKeys.DIMENSION_TYPE, new Identifier(entry.substring(1))); + if (tag != null) { + if (dimension.isIn(tag)) { + blacklist.set(false); + } + } + } else if (Objects.equals(entry, dimension.getKey().get().getValue().toString())) { blacklist.set(false); } }); Arrays.stream(config.filter.biome.blacklist).forEach(entry -> { - if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.BIOME_KEY).getId(biome).toString())) { + if (entry.startsWith("#")) { + TagKey tag = TagKey.of(RegistryKeys.BIOME, new Identifier(entry.substring(1))); + if (tag != null) { + if (biome.isIn(tag)) { + blacklist.set(false); + } + } + } else if (Objects.equals(entry, biome.getKey().get().getValue().toString())) { blacklist.set(false); } }); @@ -99,7 +137,7 @@ public boolean canBeeStart() { if (((EntityAccessor)entity).getRandom().nextFloat() > config.value.blossoming.chance) { return false; } - if (entity.getEntityWorld().isRaining()) { + if (entity.getWorld().isRaining()) { return false; } Optional optional = findTarget(); @@ -132,7 +170,7 @@ public boolean canBeeContinue() { if (((BeeEntityInvoker)entity).invokeGetCropsGrownSincePollination() >= 10) { return false; } - if (entity.getEntityWorld().isRaining()) { + if (entity.getWorld().isRaining()) { return false; } if (completed()) { @@ -168,12 +206,13 @@ public void stop() { if (completed()) { BlockPos blockPos = entity.getFlowerPos(); if (blockPos != null) { - BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); + BlockState blockState = entity.getWorld().getBlockState(blockPos); if (blockState.getBlock() == Blocks.OAK_LEAVES) { - entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); - entity.getEntityWorld().setBlockState(blockPos, FLOWERING_OAK_LEAVES.get().getDefaultState() + entity.getWorld().syncWorldEvent(2005, blockPos, 0); + entity.getWorld().setBlockState(blockPos, FLOWERING_OAK_LEAVES.get().getDefaultState() .with(DISTANCE, blockState.get(DISTANCE)) .with(PERSISTENT, blockState.get(PERSISTENT)) + .with(WATERLOGGED, blockState.get(WATERLOGGED)) ); ((BeeEntityInvoker)entity).invokeAddCropCounter(); } @@ -238,7 +277,7 @@ public void tick() { } public boolean isTarget(BlockPos pos) { - return entity.getEntityWorld().canSetBlock(pos) && entity.getEntityWorld().getBlockState(pos).isOf(Blocks.OAK_LEAVES); + return entity.getWorld().canSetBlock(pos) && entity.getWorld().getBlockState(pos).isOf(Blocks.OAK_LEAVES); } public void moveToNextTarget() { @@ -261,7 +300,7 @@ public Optional findTarget(Predicate predicate, double sea for(int k = 0; k <= j; k = k > 0 ? -k : 1 - k) { for(int l = k < j && k > -j ? j : 0; l <= j; l = l > 0 ? -l : 1 - l) { mutable.set(blockPos, k, i - 1, l); - if (blockPos.isWithinDistance(mutable, searchDistance) && predicate.test(entity.getEntityWorld().getBlockState(mutable))) { + if (blockPos.isWithinDistance(mutable, searchDistance) && predicate.test(entity.getWorld().getBlockState(mutable))) { return Optional.of(mutable); } } diff --git a/src/main/java/dev/yurisuika/blossom/entity/ai/goal/FruitGoal.java b/src/main/java/dev/yurisuika/blossom/entity/ai/goal/FruitGoal.java index 9355a322..a4bb2051 100644 --- a/src/main/java/dev/yurisuika/blossom/entity/ai/goal/FruitGoal.java +++ b/src/main/java/dev/yurisuika/blossom/entity/ai/goal/FruitGoal.java @@ -19,10 +19,14 @@ public class FruitGoal extends BlossomGoal { public final Predicate targetPredicate = (state) -> { - if (state.isOf(FLOWERING_OAK_LEAVES.get())) { - return state.get(Properties.AGE_3) >= 3; - } else { + if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { return false; + } else { + if (state.isOf(FLOWERING_OAK_LEAVES.get())) { + return state.get(Properties.AGE_3) >= 3; + } else { + return false; + } } }; @@ -37,7 +41,7 @@ public boolean canBeeStart() { if (((EntityAccessor)entity).getRandom().nextFloat() > config.value.fruiting.chance) { return false; } - if (entity.getEntityWorld().isRaining()) { + if (entity.getWorld().isRaining()) { return false; } Optional optional = findTarget(); @@ -61,13 +65,14 @@ public void stop() { if (completed()) { BlockPos blockPos = entity.getFlowerPos(); if (blockPos != null) { - BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); + BlockState blockState = entity.getWorld().getBlockState(blockPos); if (blockState.getBlock() == FLOWERING_OAK_LEAVES.get()) { if (blockState.get(Properties.AGE_3) >= 3) { - entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); - entity.getEntityWorld().setBlockState(blockPos, FRUITING_OAK_LEAVES.get().getDefaultState() + entity.getWorld().syncWorldEvent(2005, blockPos, 0); + entity.getWorld().setBlockState(blockPos, FRUITING_OAK_LEAVES.get().getDefaultState() .with(DISTANCE, blockState.get(DISTANCE)) .with(PERSISTENT, blockState.get(PERSISTENT)) + .with(WATERLOGGED, blockState.get(WATERLOGGED)) ); ((BeeEntityInvoker)entity).invokeAddCropCounter(); } @@ -79,7 +84,7 @@ public void stop() { } public boolean isTarget(BlockPos pos) { - return entity.getEntityWorld().canSetBlock(pos) && entity.getEntityWorld().getBlockState(pos).getBlock() instanceof FloweringLeavesBlock; + return entity.getWorld().canSetBlock(pos) && entity.getWorld().getBlockState(pos).getBlock() instanceof FloweringLeavesBlock; } public Optional findTarget() { diff --git a/src/main/java/dev/yurisuika/blossom/mixin/block/AbstractBlockMixin.java b/src/main/java/dev/yurisuika/blossom/mixin/block/AbstractBlockMixin.java index a6ee9cdf..186cd49a 100644 --- a/src/main/java/dev/yurisuika/blossom/mixin/block/AbstractBlockMixin.java +++ b/src/main/java/dev/yurisuika/blossom/mixin/block/AbstractBlockMixin.java @@ -19,7 +19,7 @@ public abstract class AbstractBlockMixin { private void injectGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) { Entity entity = null; if (context instanceof EntityShapeContext) { - entity = ((EntityShapeContext)context).getEntity().orElse(null); + entity = ((EntityShapeContext)context).getEntity(); if (entity instanceof BeeEntity) { if (state.getBlock() instanceof LeavesBlock) { cir.setReturnValue(VoxelShapes.empty()); diff --git a/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java b/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java index 3e7b9c2b..a1cadae5 100644 --- a/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java +++ b/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java @@ -1,11 +1,10 @@ package dev.yurisuika.blossom.mixin.entity; import net.minecraft.entity.Entity; +import net.minecraft.util.math.random.Random; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Random; - @Mixin(Entity.class) public interface EntityAccessor { diff --git a/src/main/java/dev/yurisuika/blossom/mixin/entity/ai/goal/GoalInvoker.java b/src/main/java/dev/yurisuika/blossom/mixin/entity/ai/goal/GoalInvoker.java new file mode 100644 index 00000000..54847555 --- /dev/null +++ b/src/main/java/dev/yurisuika/blossom/mixin/entity/ai/goal/GoalInvoker.java @@ -0,0 +1,13 @@ +package dev.yurisuika.blossom.mixin.entity.ai.goal; + +import net.minecraft.entity.ai.goal.Goal; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(Goal.class) +public interface GoalInvoker { + + @Invoker("getTickCount") + int invokeGetTickCount(int ticks); + +} \ No newline at end of file diff --git a/src/main/java/dev/yurisuika/blossom/mixin/entity/passive/BeeEntityMixin.java b/src/main/java/dev/yurisuika/blossom/mixin/entity/passive/BeeEntityMixin.java index 79b44cc3..87ad5835 100644 --- a/src/main/java/dev/yurisuika/blossom/mixin/entity/passive/BeeEntityMixin.java +++ b/src/main/java/dev/yurisuika/blossom/mixin/entity/passive/BeeEntityMixin.java @@ -1,10 +1,11 @@ package dev.yurisuika.blossom.mixin.entity.passive; import dev.yurisuika.blossom.block.FruitingLeavesBlock; +import dev.yurisuika.blossom.mixin.entity.ai.goal.GoalInvoker; import net.minecraft.block.*; import net.minecraft.entity.passive.BeeEntity; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.state.property.IntProperty; -import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldView; import org.spongepowered.asm.mixin.Mixin; @@ -37,16 +38,16 @@ private void injectInit(BeeEntity beeEntity, CallbackInfo ci) { @Inject(method = "tick", at = @At(value = "HEAD")) private void injectTick(CallbackInfo ci) { - if (entity.getRandom().nextInt(30) != 0) { + if (entity.getRandom().nextInt(((GoalInvoker)this).invokeGetTickCount(30)) != 0) { for (int i = 1; i <= 2; ++i) { BlockPos blockPos = entity.getBlockPos().down(i); - BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); + BlockState blockState = entity.getWorld().getBlockState(blockPos); if (blockState.isIn(BlockTags.BEE_GROWABLES)) { if (blockState.getBlock() instanceof FruitingLeavesBlock fruitingLeavesBlock) { if (!fruitingLeavesBlock.isMature(blockState)) { IntProperty age = fruitingLeavesBlock.getAgeProperty(); - entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); - entity.getEntityWorld().setBlockState(blockPos, blockState.with(age, blockState.get(age) + 1)); + entity.getWorld().syncWorldEvent(2005, blockPos, 0); + entity.getWorld().setBlockState(blockPos, blockState.with(age, blockState.get(age) + 1)); ((BeeEntityInvoker)entity).invokeAddCropCounter(); } } @@ -70,7 +71,7 @@ private void injectInit(BeeEntity beeEntity, CallbackInfo ci) { @Inject(method = "shouldMoveToFlower", at = @At("RETURN"), cancellable = true) private void injectTick(CallbackInfoReturnable cir) { - cir.setReturnValue(cir.getReturnValue() || (entity.getEntityWorld().getBlockState(entity.getFlowerPos()).isOf(Blocks.OAK_LEAVES) && entity.hasNectar())); + cir.setReturnValue(cir.getReturnValue() || (entity.getWorld().getBlockState(entity.getFlowerPos()).isOf(Blocks.OAK_LEAVES) && entity.hasNectar())); } } diff --git a/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java b/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java index 7944138c..76f8bb21 100644 --- a/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java +++ b/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java @@ -2,15 +2,16 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.*; -import net.minecraft.command.argument.DimensionArgumentType; -import net.minecraft.command.argument.IdentifierArgumentType; -import net.minecraft.command.suggestion.SuggestionProviders; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.argument.RegistryEntryPredicateArgumentType; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.*; +import net.minecraft.text.HoverEvent; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import net.minecraft.text.Texts; import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import org.apache.commons.lang3.ArrayUtils; import java.util.*; @@ -20,7 +21,7 @@ public class BlossomCommand { - public static void register(CommandDispatcher dispatcher, RegistrationEnvironment environment) { + public static void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess, RegistrationEnvironment environment) { dispatcher.register(literal("blossom") .then(literal("config") .requires(source -> source.hasPermissionLevel(4)) @@ -28,7 +29,7 @@ public static void register(CommandDispatcher dispatcher, R .executes(context -> { loadConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.config.reload"), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.config.reload"), true); return 1; }) ) @@ -51,7 +52,7 @@ public static void register(CommandDispatcher dispatcher, R ); saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.config.reset"), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.config.reset"), true); return 1; }) ) @@ -60,10 +61,10 @@ public static void register(CommandDispatcher dispatcher, R .requires(source -> source.hasPermissionLevel(4)) .then(literal("blossoming") .executes(context -> { - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.blossoming.chance", config.value.blossoming.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.chance.tooltip")))); - MutableText distance = Texts.bracketed(new TranslatableText("commands.blossom.value.blossoming.distance", config.value.blossoming.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.distance.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.blossoming.chance", config.value.blossoming.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.chance.tooltip")))); + MutableText distance = Texts.bracketed(Text.translatable("commands.blossom.value.blossoming.distance", config.value.blossoming.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.distance.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.blossoming.query", chance, distance), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.blossoming.query", chance, distance), true); return 1; }) .then(CommandManager.argument("chance", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -73,10 +74,10 @@ public static void register(CommandDispatcher dispatcher, R config.value.blossoming.distance = DoubleArgumentType.getDouble(context, "distance"); saveConfig(); - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.blossoming.chance", config.value.blossoming.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.chance.tooltip")))); - MutableText distance = Texts.bracketed(new TranslatableText("commands.blossom.value.blossoming.distance", config.value.blossoming.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.distance.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.blossoming.chance", config.value.blossoming.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.chance.tooltip")))); + MutableText distance = Texts.bracketed(Text.translatable("commands.blossom.value.blossoming.distance", config.value.blossoming.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.distance.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.blossoming.set", chance, distance), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.blossoming.set", chance, distance), true); return 1; }) ) @@ -84,10 +85,10 @@ public static void register(CommandDispatcher dispatcher, R ) .then(literal("fruiting") .executes(context -> { - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.fruiting.chance", config.value.fruiting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.fruiting.chance.tooltip")))); - MutableText distance = Texts.bracketed(new TranslatableText("commands.blossom.value.fruiting.distance", config.value.fruiting.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.fruiting.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.fruiting.chance", config.value.fruiting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.fruiting.chance.tooltip")))); + MutableText distance = Texts.bracketed(Text.translatable("commands.blossom.value.fruiting.distance", config.value.fruiting.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.fruiting.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.fruiting.query", chance, distance), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.fruiting.query", chance, distance), false); return 1; }) .then(CommandManager.argument("chance", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -97,10 +98,10 @@ public static void register(CommandDispatcher dispatcher, R config.value.fruiting.distance = DoubleArgumentType.getDouble(context, "distance"); saveConfig(); - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.fruiting.chance", config.value.fruiting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.fruiting.chance.tooltip")))); - MutableText distance = Texts.bracketed(new TranslatableText("commands.blossom.value.fruiting.distance", config.value.fruiting.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.blossoming.fruiting.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.fruiting.chance", config.value.fruiting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.fruiting.chance.tooltip")))); + MutableText distance = Texts.bracketed(Text.translatable("commands.blossom.value.fruiting.distance", config.value.fruiting.distance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.blossoming.fruiting.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.fruiting.set", chance, distance), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.fruiting.set", chance, distance), false); return 1; }) ) @@ -108,11 +109,11 @@ public static void register(CommandDispatcher dispatcher, R ) .then(literal("harvesting") .executes(context -> { - MutableText bonus = Texts.bracketed(new TranslatableText("commands.blossom.value.harvesting.bonus", config.value.harvesting.bonus)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.harvesting.bonus.tooltip")))); + MutableText bonus = Texts.bracketed(Text.translatable("commands.blossom.value.harvesting.bonus", config.value.harvesting.bonus)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.harvesting.bonus.tooltip")))); - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.harvesting.chance", config.value.harvesting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.harvesting.chance.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.harvesting.chance", config.value.harvesting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.harvesting.chance.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.harvesting.query", bonus, chance), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.harvesting.query", bonus, chance), true); return 1; }) .then(CommandManager.argument("bonus", IntegerArgumentType.integer(0)) @@ -122,10 +123,10 @@ public static void register(CommandDispatcher dispatcher, R config.value.harvesting.chance = FloatArgumentType.getFloat(context, "chance"); saveConfig(); - MutableText bonus = Texts.bracketed(new TranslatableText("commands.blossom.value.harvesting.bonus", config.value.harvesting.bonus)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.harvesting.bonus.tooltip")))); - MutableText chance = Texts.bracketed(new TranslatableText("commands.blossom.value.harvesting.chance", config.value.harvesting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.value.harvesting.chance.tooltip")))); + MutableText bonus = Texts.bracketed(Text.translatable("commands.blossom.value.harvesting.bonus", config.value.harvesting.bonus)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.harvesting.bonus.tooltip")))); + MutableText chance = Texts.bracketed(Text.translatable("commands.blossom.value.harvesting.chance", config.value.harvesting.chance)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.value.harvesting.chance.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.harvesting.set", bonus, chance), true); + context.getSource().sendFeedback(Text.translatable("commands.blossom.value.harvesting.set", bonus, chance), true); return 1; }) ) @@ -136,10 +137,10 @@ public static void register(CommandDispatcher dispatcher, R .requires(source -> source.hasPermissionLevel(4)) .then(literal("temperature") .executes(context -> { - MutableText min = Texts.bracketed(new TranslatableText("commands.blossom.filter.temperature.min", config.filter.temperature.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.temperature.min.tooltip")))); - MutableText max = Texts.bracketed(new TranslatableText("commands.blossom.filter.temperature.max", config.filter.temperature.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.temperature.max.tooltip")))); + MutableText min = Texts.bracketed(Text.translatable("commands.blossom.filter.temperature.min", config.filter.temperature.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.temperature.min.tooltip")))); + MutableText max = Texts.bracketed(Text.translatable("commands.blossom.filter.temperature.max", config.filter.temperature.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.temperature.max.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.query", min, max), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.query", min, max), false); return 1; }) .then(argument("min", FloatArgumentType.floatArg(-2.0F, 2.0F)) @@ -149,10 +150,10 @@ public static void register(CommandDispatcher dispatcher, R config.filter.temperature.max = Math.max(FloatArgumentType.getFloat(context, "max"), FloatArgumentType.getFloat(context, "min")); saveConfig(); - MutableText min = Texts.bracketed(new TranslatableText("commands.blossom.filter.temperature.min", config.filter.temperature.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.temperature.min.tooltip")))); - MutableText max = Texts.bracketed(new TranslatableText("commands.blossom.filter.temperature.max", config.filter.temperature.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.temperature.max.tooltip")))); + MutableText min = Texts.bracketed(Text.translatable("commands.blossom.filter.temperature.min", config.filter.temperature.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.temperature.min.tooltip")))); + MutableText max = Texts.bracketed(Text.translatable("commands.blossom.filter.temperature.max", config.filter.temperature.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.temperature.max.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.set", min, max), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.set", min, max), false); return 1; }) ) @@ -160,10 +161,10 @@ public static void register(CommandDispatcher dispatcher, R ) .then(literal("downfall") .executes(context -> { - MutableText min = Texts.bracketed(new TranslatableText("commands.blossom.filter.downfall.min", config.filter.downfall.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.downfall.min.tooltip")))); - MutableText max = Texts.bracketed(new TranslatableText("commands.blossom.filter.downfall.max", config.filter.downfall.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.downfall.max.tooltip")))); + MutableText min = Texts.bracketed(Text.translatable("commands.blossom.filter.downfall.min", config.filter.downfall.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.downfall.min.tooltip")))); + MutableText max = Texts.bracketed(Text.translatable("commands.blossom.filter.downfall.max", config.filter.downfall.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.downfall.max.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.query", min, max), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.query", min, max), false); return 1; }) .then(argument("min", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -173,10 +174,10 @@ public static void register(CommandDispatcher dispatcher, R config.filter.downfall.max = Math.max(FloatArgumentType.getFloat(context, "max"), FloatArgumentType.getFloat(context, "min")); saveConfig(); - MutableText min = Texts.bracketed(new TranslatableText("commands.blossom.filter.downfall.min", config.filter.downfall.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.downfall.min.tooltip")))); - MutableText max = Texts.bracketed(new TranslatableText("commands.blossom.filter.downfall.max", config.filter.downfall.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.downfall.max.tooltip")))); + MutableText min = Texts.bracketed(Text.translatable("commands.blossom.filter.downfall.min", config.filter.downfall.min)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.downfall.min.tooltip")))); + MutableText max = Texts.bracketed(Text.translatable("commands.blossom.filter.downfall.max", config.filter.downfall.max)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.downfall.max.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.set", min, max), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.set", min, max), false); return 1; }) ) @@ -185,35 +186,35 @@ public static void register(CommandDispatcher dispatcher, R .then(literal("dimension") .then(literal("whitelist") .executes(context -> { - MutableText list = new TranslatableText("commands.blossom.filter.dimension.whitelist.list", Arrays.toString(config.filter.dimension.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.dimension.whitelist.list.tooltip")))); + MutableText list = Text.translatable("commands.blossom.filter.dimension.whitelist.list", Arrays.toString(config.filter.dimension.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.dimension.whitelist.list.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.query", list), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.whitelist.query", list), false); return 1; }) .then(literal("add") - .then(argument("dimension", DimensionArgumentType.dimension()) + .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) .executes(context -> { - String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); + String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); if (Arrays.stream(config.filter.dimension.whitelist).anyMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.dimension.whitelist.add.failed", dimension)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.whitelist.add.failed", dimension)); return 0; } else { config.filter.dimension.whitelist = ArrayUtils.add(config.filter.dimension.whitelist, dimension); Arrays.sort(config.filter.dimension.whitelist); saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.add", dimension), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.whitelist.add", dimension), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("dimension", DimensionArgumentType.dimension()) + .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) .executes(context -> { - String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); + String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); if (Arrays.stream(config.filter.dimension.whitelist).noneMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.dimension.whitelist.remove.failed", dimension)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.whitelist.remove.failed", dimension)); return 0; } else { for (String entry : config.filter.dimension.whitelist) { @@ -224,7 +225,7 @@ public static void register(CommandDispatcher dispatcher, R } saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.remove", dimension), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.whitelist.remove", dimension), false); return 1; } }) @@ -233,35 +234,35 @@ public static void register(CommandDispatcher dispatcher, R ) .then(literal("blacklist") .executes(context -> { - MutableText list = new TranslatableText("commands.blossom.filter.dimension.blacklist.list", Arrays.toString(config.filter.dimension.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.dimension.blacklist.list.tooltip")))); + MutableText list = Text.translatable("commands.blossom.filter.dimension.blacklist.list", Arrays.toString(config.filter.dimension.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.dimension.blacklist.list.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.query", list), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.blacklist.query", list), false); return 1; }) .then(literal("add") - .then(argument("dimension", DimensionArgumentType.dimension()) + .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) .executes(context -> { - String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); + String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); if (Arrays.stream(config.filter.dimension.blacklist).anyMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.blacklist.add.failed", dimension)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.add.failed", dimension)); return 0; } else { config.filter.dimension.blacklist = ArrayUtils.add(config.filter.dimension.blacklist, dimension); Arrays.sort(config.filter.dimension.blacklist); saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.add", dimension), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.blacklist.add", dimension), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("dimension", DimensionArgumentType.dimension()) + .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) .executes(context -> { - String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); + String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); if (Arrays.stream(config.filter.dimension.blacklist).noneMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.dimension.blacklist.remove.failed", dimension)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.blacklist.remove.failed", dimension)); return 0; } else { for (String entry : config.filter.dimension.blacklist) { @@ -272,7 +273,7 @@ public static void register(CommandDispatcher dispatcher, R } saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.remove", dimension), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.blacklist.remove", dimension), false); return 1; } }) @@ -283,37 +284,35 @@ public static void register(CommandDispatcher dispatcher, R .then(literal("biome") .then(literal("whitelist") .executes(context -> { - MutableText list = new TranslatableText("commands.blossom.filter.biome.whitelist.list", Arrays.toString(config.filter.biome.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.biome.whitelist.list.tooltip")))); + MutableText list = Text.translatable("commands.blossom.filter.biome.whitelist.list", Arrays.toString(config.filter.biome.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.biome.whitelist.list.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.query", list), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.whitelist.query", list), false); return 1; }) .then(literal("add") - .then(argument("biome", IdentifierArgumentType.identifier()) - .suggests(SuggestionProviders.ALL_BIOMES) + .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) .executes(context -> { - String biome = context.getArgument("biome", Identifier.class).toString(); + String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); if (Arrays.stream(config.filter.biome.whitelist).anyMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.whitelist.add.failed", biome)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.whitelist.add.failed", biome)); return 0; } else { config.filter.biome.whitelist = ArrayUtils.add(config.filter.biome.whitelist, biome); Arrays.sort(config.filter.biome.whitelist); saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.add", biome), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.whitelist.add", biome), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("biome", IdentifierArgumentType.identifier()) - .suggests(SuggestionProviders.ALL_BIOMES) + .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) .executes(context -> { - String biome = context.getArgument("biome", Identifier.class).toString(); + String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); if (Arrays.stream(config.filter.biome.whitelist).noneMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.whitelist.remove.failed", biome)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.whitelist.remove.failed", biome)); return 0; } else { for (String entry : config.filter.biome.whitelist) { @@ -324,7 +323,7 @@ public static void register(CommandDispatcher dispatcher, R } saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.remove", biome), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.whitelist.remove", biome), false); return 1; } }) @@ -333,37 +332,35 @@ public static void register(CommandDispatcher dispatcher, R ) .then(literal("blacklist") .executes(context -> { - MutableText list = new TranslatableText("commands.blossom.filter.biome.blacklist.list", Arrays.toString(config.filter.biome.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.filter.biome.blacklist.list.tooltip")))); + MutableText list = Text.translatable("commands.blossom.filter.biome.blacklist.list", Arrays.toString(config.filter.biome.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.filter.biome.blacklist.list.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.query", list), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.blacklist.query", list), false); return 1; }) .then(literal("add") - .then(argument("biome", IdentifierArgumentType.identifier()) - .suggests(SuggestionProviders.ALL_BIOMES) + .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) .executes(context -> { - String biome = context.getArgument("biome", Identifier.class).toString(); + String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); if (Arrays.stream(config.filter.biome.blacklist).anyMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.blacklist.add.failed", biome)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.add.failed", biome)); return 0; } else { config.filter.biome.blacklist = ArrayUtils.add(config.filter.biome.blacklist, biome); Arrays.sort(config.filter.biome.blacklist); saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.add", biome), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.blacklist.add", biome), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("biome", IdentifierArgumentType.identifier()) - .suggests(SuggestionProviders.ALL_BIOMES) + .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) .executes(context -> { - String biome = context.getArgument("biome", Identifier.class).toString(); + String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); if (Arrays.stream(config.filter.biome.blacklist).noneMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.blacklist.remove.failed", biome)); + context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.remove.failed", biome)); return 0; } else { for (String entry : config.filter.biome.blacklist) { @@ -374,7 +371,7 @@ public static void register(CommandDispatcher dispatcher, R } saveConfig(); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.remove", biome), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.blacklist.remove", biome), false); return 1; } }) @@ -387,9 +384,9 @@ public static void register(CommandDispatcher dispatcher, R .requires(source -> source.hasPermissionLevel(4)) .then(literal("whitelist") .executes(context -> { - MutableText toggle = Texts.bracketed(new TranslatableText("commands.blossom.toggle.whitelist.toggle", config.toggle.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.toggle.whitelist.toggle.tooltip")))); + MutableText toggle = Texts.bracketed(Text.translatable("commands.blossom.toggle.whitelist.toggle", config.toggle.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.toggle.whitelist.toggle.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.whitelist.query", toggle), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.whitelist.query", toggle), false); return 1; }) .then(argument("value", BoolArgumentType.bool()) @@ -397,18 +394,18 @@ public static void register(CommandDispatcher dispatcher, R config.toggle.whitelist = BoolArgumentType.getBool(context, "value"); saveConfig(); - MutableText toggle = Texts.bracketed(new TranslatableText("commands.blossom.toggle.whitelist.toggle", config.toggle.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.toggle.whitelist.toggle.tooltip")))); + MutableText toggle = Texts.bracketed(Text.translatable("commands.blossom.toggle.whitelist.toggle", config.toggle.whitelist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.toggle.whitelist.toggle.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.whitelist.set", toggle), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.whitelist.set", toggle), false); return 1; }) ) ) .then(literal("blacklist") .executes(context -> { - MutableText toggle = Texts.bracketed(new TranslatableText("commands.blossom.toggle.blacklist.toggle", config.toggle.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.toggle.blacklist.toggle.tooltip")))); + MutableText toggle = Texts.bracketed(Text.translatable("commands.blossom.toggle.blacklist.toggle", config.toggle.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.toggle.blacklist.toggle.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.blacklist.query", toggle), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.blacklist.query", toggle), false); return 1; }) .then(argument("value", BoolArgumentType.bool()) @@ -416,9 +413,9 @@ public static void register(CommandDispatcher dispatcher, R config.toggle.blacklist = BoolArgumentType.getBool(context, "value"); saveConfig(); - MutableText toggle = Texts.bracketed(new TranslatableText("commands.blossom.toggle.blacklist.toggle", config.toggle.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands.blossom.toggle.blacklist.toggle.tooltip")))); + MutableText toggle = Texts.bracketed(Text.translatable("commands.blossom.toggle.blacklist.toggle", config.toggle.blacklist)).styled(style -> style.withColor(Formatting.GREEN).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("commands.blossom.toggle.blacklist.toggle.tooltip")))); - context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.blacklist.set", toggle), false); + context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.blacklist.set", toggle), false); return 1; }) ) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index c8e8021a..c6922b8b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "37,)" +loaderVersion = "44,)" license = "GNU Lesser General Public License v3.0" [[mods]] @@ -18,13 +18,13 @@ Apples blossom upon leaves by the pollen from bees! [[dependencies.blossom]] modId = "minecraft" mandatory = true -versionRange = "[1.17,1.18)" +versionRange = "[1.19.3,1.19.4)" ordering = "NONE" side = "BOTH" [[dependencies.blossom]] modId = "forge" mandatory = true -versionRange = "[37,)" +versionRange = "[44,)" ordering = "NONE" side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/blossom.mixins.json b/src/main/resources/blossom.mixins.json index b5a5b5b1..9e88024b 100644 --- a/src/main/resources/blossom.mixins.json +++ b/src/main/resources/blossom.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "dev.yurisuika.blossom.mixin", "refmap": "blossom.refmap.json", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "mixins": [ "block.AbstractBlockMixin", "block.BlocksInvoker", @@ -12,6 +12,7 @@ "block.LeavesBlockMixin", "entity.EntityAccessor", "entity.MobEntityAccessor", + "entity.ai.goal.GoalInvoker", "entity.passive.BeeEntityAccessor", "entity.passive.BeeEntityInvoker", "entity.passive.BeeEntityMixin",