diff --git a/src/main/java/dev/yurisuika/blossom/Blossom.java b/src/main/java/dev/yurisuika/blossom/Blossom.java index 1d344abd..f3134933 100644 --- a/src/main/java/dev/yurisuika/blossom/Blossom.java +++ b/src/main/java/dev/yurisuika/blossom/Blossom.java @@ -27,21 +27,20 @@ import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.RegisterColorHandlersEvent; -import net.minecraftforge.client.event.RegisterParticleProvidersEvent; +import net.minecraftforge.client.event.ColorHandlerEvent; +import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.event.entity.EntityJoinLevelEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; 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; @@ -285,7 +284,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)); + ITEMS.register(name, () -> new BlockItem(block.get(), settings.group(ItemGroup.DECORATIONS))); return block; } @@ -294,11 +293,11 @@ public static class CommonForgeEvents { @SubscribeEvent public static void registerCommandsEvents(RegisterCommandsEvent event) { - BlossomCommand.register(event.getDispatcher(), event.getBuildContext(), event.getCommandSelection()); + BlossomCommand.register(event.getDispatcher(), event.getEnvironment()); } @SubscribeEvent - public static void entityJoinLevelEvents(EntityJoinLevelEvent event) { + public static void entityJoinWorldEvents(EntityJoinWorldEvent event) { Entity entity = event.getEntity(); if (entity instanceof BeeEntity) { ((BeeEntity)entity).getGoalSelector().add(4, new BlossomGoal((BeeEntity)entity)); @@ -321,7 +320,7 @@ public static void commonSetup(FMLCommonSetupEvent event) { } @SubscribeEvent - public static void registerParticleProvidersEvents(RegisterParticleProvidersEvent event) { + public static void particleFactoryRegisterEvents(ParticleFactoryRegisterEvent event) { MinecraftClient.getInstance().particleManager.registerFactory(BLOSSOM.get(), BlossomParticle.Factory::new); } @@ -357,27 +356,17 @@ public static void clientSetup(FMLClientSetupEvent event) { } @SubscribeEvent - public static void registerBlockColorHandlersEvents(RegisterColorHandlersEvent.Block event) { + public static void blockColorHandlerEvents(ColorHandlerEvent.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 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()); + 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()); 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 c1978491..3a55286f 100644 --- a/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java +++ b/src/main/java/dev/yurisuika/blossom/block/FloweringLeavesBlock.java @@ -1,18 +1,14 @@ package dev.yurisuika.blossom.block; -import dev.yurisuika.blossom.mixin.world.biome.BiomeAccessor; import net.minecraft.block.Block; import net.minecraft.block.BlockState; 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; @@ -21,6 +17,7 @@ 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; @@ -28,17 +25,16 @@ 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.*; @@ -49,7 +45,6 @@ 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); @@ -57,7 +52,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(WATERLOGGED, false).with(AGE, 0).with(RIPENESS, 0)); + setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(AGE, 0).with(RIPENESS, 0)); } public VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { @@ -104,21 +99,15 @@ 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).value().getTemperature(); - float downfall = ((BiomeAccessor)(Object)world.getBiome(pos).value()).getWeather().downfall(); + float temperature = world.getBiome(pos).getTemperature(); + float downfall = world.getBiome(pos).getDownfall(); temperature += 2; float f = (downfall * temperature) / 4; f = ((4 - 1) * f) + 1; - Biome.Precipitation precipitation = world.getBiome(pos).value().getPrecipitation(); + Biome.Precipitation precipitation = world.getBiome(pos).getPrecipitation(); if (world.isRaining() && precipitation == Biome.Precipitation.RAIN) { f = 5.0F; } @@ -126,7 +115,6 @@ 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); } } @@ -142,7 +130,6 @@ 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) { @@ -163,7 +150,6 @@ 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); } @@ -176,12 +162,9 @@ 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.scheduleBlockTick(pos, this, 1); + world.getBlockTickScheduler().schedule(pos, this, 1); } return state; } @@ -213,10 +196,6 @@ 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) { @@ -232,14 +211,14 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando } public void appendProperties(Builder builder) { - builder.add(DISTANCE, PERSISTENT, WATERLOGGED, AGE, RIPENESS); + builder.add(DISTANCE, PERSISTENT, AGE, RIPENESS); } public BlockState getPlacementState(ItemPlacementContext ctx) { - 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()); + return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); } - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return !isMature(state); } @@ -266,7 +245,6 @@ 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 bbac1509..a2c83b93 100644 --- a/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java +++ b/src/main/java/dev/yurisuika/blossom/block/FruitingLeavesBlock.java @@ -1,6 +1,5 @@ package dev.yurisuika.blossom.block; -import dev.yurisuika.blossom.mixin.world.biome.BiomeAccessor; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Fertilizable; @@ -8,13 +7,10 @@ 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; @@ -23,6 +19,7 @@ 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; @@ -30,17 +27,16 @@ 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.*; @@ -52,7 +48,6 @@ 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); @@ -60,7 +55,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(WATERLOGGED, false).with(AGE, 0).with(RIPENESS, 0)); + setDefaultState(stateManager.getDefaultState().with(DISTANCE, 1).with(PERSISTENT, false).with(AGE, 0).with(RIPENESS, 0)); } public VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { @@ -107,21 +102,15 @@ 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).value().getTemperature(); - float downfall = ((BiomeAccessor)(Object)world.getBiome(pos).value()).getWeather().downfall(); + float temperature = world.getBiome(pos).getTemperature(); + float downfall = world.getBiome(pos).getDownfall(); temperature += 2; float f = (downfall * temperature) / 4; f = ((4 - 1) * f) + 1; - Biome.Precipitation precipitation = world.getBiome(pos).value().getPrecipitation(); + Biome.Precipitation precipitation = world.getBiome(pos).getPrecipitation(); if (world.isRaining() && precipitation == Biome.Precipitation.RAIN) { f = 5.0F; } @@ -129,7 +118,6 @@ 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); } } @@ -146,7 +134,6 @@ 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) { @@ -167,7 +154,6 @@ 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); } @@ -180,12 +166,9 @@ 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.scheduleBlockTick(pos, this, 1); + world.getBlockTickScheduler().schedule(pos, this, 1); } return state; } @@ -217,23 +200,19 @@ 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, WATERLOGGED, AGE, RIPENESS); + builder.add(DISTANCE, PERSISTENT, AGE, RIPENESS); } public BlockState getPlacementState(ItemPlacementContext ctx) { - 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()); + return updateDistanceFromLogs(getDefaultState().with(PERSISTENT, true).with(AGE, 0).with(RIPENESS, 0), ctx.getWorld(), ctx.getBlockPos()); } - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { + public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { return !isMature(state); } @@ -272,7 +251,6 @@ 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 c7a68c53..d1a0e86d 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.velocityMultiplier = 1.0F; + this.field_28786 = 1.0F; } public ParticleTextureSheet getType() { @@ -63,9 +63,9 @@ public void tick() { if (dead) { return; } - velocityX *= velocityMultiplier; - velocityY *= velocityMultiplier; - velocityZ *= velocityMultiplier; + velocityX *= field_28786; + velocityY *= field_28786; + velocityZ *= field_28786; } } \ 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 e63fa708..f0014594 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 @@ -4,19 +4,14 @@ import dev.yurisuika.blossom.mixin.entity.MobEntityAccessor; import dev.yurisuika.blossom.mixin.entity.passive.BeeEntityAccessor; import dev.yurisuika.blossom.mixin.entity.passive.BeeEntityInvoker; -import dev.yurisuika.blossom.mixin.world.biome.BiomeAccessor; import net.minecraft.block.BlockState; 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; @@ -33,13 +28,7 @@ public class BlossomGoal extends Goal { public final BeeEntity entity; - public final Predicate targetPredicate = (state) -> { - if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { - return false; - } else { - return state.isOf(Blocks.OAK_LEAVES); - } - }; + public final Predicate targetPredicate = (state) -> state.isOf(Blocks.OAK_LEAVES); public int blossomingTicks; public int lastBlossomingTick; public boolean running; @@ -53,34 +42,20 @@ public BlossomGoal(BeeEntity beeEntity) { } public boolean checkFilters() { - RegistryEntry dimension = entity.getWorld().getDimensionEntry(); - RegistryEntry biome = entity.getWorld().getBiome(entity.getBlockPos()); - float temperature = biome.value().getTemperature(); - float downfall = ((BiomeAccessor)(Object)biome.value()).getWeather().downfall(); + DimensionType dimension = entity.getEntityWorld().getDimension(); + Biome biome = entity.getEntityWorld().getBiome(entity.getBlockPos()); + float temperature = biome.getTemperature(); + float downfall = biome.getDownfall(); AtomicBoolean whitelist = new AtomicBoolean(false); if (config.toggle.whitelist) { Arrays.stream(config.filter.dimension.whitelist).forEach(entry -> { - 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())) { + if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(dimension).toString())) { whitelist.set(true); } }); Arrays.stream(config.filter.biome.whitelist).forEach(entry -> { - 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())) { + if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.BIOME_KEY).getId(biome).toString())) { whitelist.set(true); } }); @@ -89,26 +64,12 @@ public boolean checkFilters() { AtomicBoolean blacklist = new AtomicBoolean(true); if (config.toggle.blacklist) { Arrays.stream(config.filter.dimension.blacklist).forEach(entry -> { - 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())) { + if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(dimension).toString())) { blacklist.set(false); } }); Arrays.stream(config.filter.biome.blacklist).forEach(entry -> { - 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())) { + if (Objects.equals(entry, entity.getEntityWorld().getRegistryManager().get(Registry.BIOME_KEY).getId(biome).toString())) { blacklist.set(false); } }); @@ -138,7 +99,7 @@ public boolean canBeeStart() { if (((EntityAccessor)entity).getRandom().nextFloat() > config.value.blossoming.chance) { return false; } - if (entity.getWorld().isRaining()) { + if (entity.getEntityWorld().isRaining()) { return false; } Optional optional = findTarget(); @@ -171,7 +132,7 @@ public boolean canBeeContinue() { if (((BeeEntityInvoker)entity).invokeGetCropsGrownSincePollination() >= 10) { return false; } - if (entity.getWorld().isRaining()) { + if (entity.getEntityWorld().isRaining()) { return false; } if (completed()) { @@ -207,13 +168,12 @@ public void stop() { if (completed()) { BlockPos blockPos = entity.getFlowerPos(); if (blockPos != null) { - BlockState blockState = entity.getWorld().getBlockState(blockPos); + BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); if (blockState.getBlock() == Blocks.OAK_LEAVES) { - entity.getWorld().syncWorldEvent(2005, blockPos, 0); - entity.getWorld().setBlockState(blockPos, FLOWERING_OAK_LEAVES.get().getDefaultState() + entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); + entity.getEntityWorld().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(); } @@ -278,7 +238,7 @@ public void tick() { } public boolean isTarget(BlockPos pos) { - return entity.getWorld().canSetBlock(pos) && entity.getWorld().getBlockState(pos).isOf(Blocks.OAK_LEAVES); + return entity.getEntityWorld().canSetBlock(pos) && entity.getEntityWorld().getBlockState(pos).isOf(Blocks.OAK_LEAVES); } public void moveToNextTarget() { @@ -301,7 +261,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.getWorld().getBlockState(mutable))) { + if (blockPos.isWithinDistance(mutable, searchDistance) && predicate.test(entity.getEntityWorld().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 a4bb2051..9355a322 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,14 +19,10 @@ public class FruitGoal extends BlossomGoal { public final Predicate targetPredicate = (state) -> { - if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { - return false; + if (state.isOf(FLOWERING_OAK_LEAVES.get())) { + return state.get(Properties.AGE_3) >= 3; } else { - if (state.isOf(FLOWERING_OAK_LEAVES.get())) { - return state.get(Properties.AGE_3) >= 3; - } else { - return false; - } + return false; } }; @@ -41,7 +37,7 @@ public boolean canBeeStart() { if (((EntityAccessor)entity).getRandom().nextFloat() > config.value.fruiting.chance) { return false; } - if (entity.getWorld().isRaining()) { + if (entity.getEntityWorld().isRaining()) { return false; } Optional optional = findTarget(); @@ -65,14 +61,13 @@ public void stop() { if (completed()) { BlockPos blockPos = entity.getFlowerPos(); if (blockPos != null) { - BlockState blockState = entity.getWorld().getBlockState(blockPos); + BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); if (blockState.getBlock() == FLOWERING_OAK_LEAVES.get()) { if (blockState.get(Properties.AGE_3) >= 3) { - entity.getWorld().syncWorldEvent(2005, blockPos, 0); - entity.getWorld().setBlockState(blockPos, FRUITING_OAK_LEAVES.get().getDefaultState() + entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); + entity.getEntityWorld().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(); } @@ -84,7 +79,7 @@ public void stop() { } public boolean isTarget(BlockPos pos) { - return entity.getWorld().canSetBlock(pos) && entity.getWorld().getBlockState(pos).getBlock() instanceof FloweringLeavesBlock; + return entity.getEntityWorld().canSetBlock(pos) && entity.getEntityWorld().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 186cd49a..a6ee9cdf 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(); + entity = ((EntityShapeContext)context).getEntity().orElse(null); 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 a1cadae5..3e7b9c2b 100644 --- a/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java +++ b/src/main/java/dev/yurisuika/blossom/mixin/entity/EntityAccessor.java @@ -1,10 +1,11 @@ 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 deleted file mode 100644 index 54847555..00000000 --- a/src/main/java/dev/yurisuika/blossom/mixin/entity/ai/goal/GoalInvoker.java +++ /dev/null @@ -1,13 +0,0 @@ -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 87ad5835..79b44cc3 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,11 +1,10 @@ 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; @@ -38,16 +37,16 @@ private void injectInit(BeeEntity beeEntity, CallbackInfo ci) { @Inject(method = "tick", at = @At(value = "HEAD")) private void injectTick(CallbackInfo ci) { - if (entity.getRandom().nextInt(((GoalInvoker)this).invokeGetTickCount(30)) != 0) { + if (entity.getRandom().nextInt(30) != 0) { for (int i = 1; i <= 2; ++i) { BlockPos blockPos = entity.getBlockPos().down(i); - BlockState blockState = entity.getWorld().getBlockState(blockPos); + BlockState blockState = entity.getEntityWorld().getBlockState(blockPos); if (blockState.isIn(BlockTags.BEE_GROWABLES)) { if (blockState.getBlock() instanceof FruitingLeavesBlock fruitingLeavesBlock) { if (!fruitingLeavesBlock.isMature(blockState)) { IntProperty age = fruitingLeavesBlock.getAgeProperty(); - entity.getWorld().syncWorldEvent(2005, blockPos, 0); - entity.getWorld().setBlockState(blockPos, blockState.with(age, blockState.get(age) + 1)); + entity.getEntityWorld().syncWorldEvent(2005, blockPos, 0); + entity.getEntityWorld().setBlockState(blockPos, blockState.with(age, blockState.get(age) + 1)); ((BeeEntityInvoker)entity).invokeAddCropCounter(); } } @@ -71,7 +70,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.getWorld().getBlockState(entity.getFlowerPos()).isOf(Blocks.OAK_LEAVES) && entity.hasNectar())); + cir.setReturnValue(cir.getReturnValue() || (entity.getEntityWorld().getBlockState(entity.getFlowerPos()).isOf(Blocks.OAK_LEAVES) && entity.hasNectar())); } } diff --git a/src/main/java/dev/yurisuika/blossom/mixin/world/biome/BiomeAccessor.java b/src/main/java/dev/yurisuika/blossom/mixin/world/biome/BiomeAccessor.java deleted file mode 100644 index 19584615..00000000 --- a/src/main/java/dev/yurisuika/blossom/mixin/world/biome/BiomeAccessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package dev.yurisuika.blossom.mixin.world.biome; - -import net.minecraft.world.biome.Biome; -import org.spongepowered.asm.mixin.Intrinsic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(Biome.class) -public interface BiomeAccessor { - - @Intrinsic - @Accessor("weather") - Biome.Weather getWeather(); - -} \ No newline at end of file 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 76f8bb21..7944138c 100644 --- a/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java +++ b/src/main/java/dev/yurisuika/blossom/server/command/BlossomCommand.java @@ -2,16 +2,15 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.*; -import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.command.argument.RegistryEntryPredicateArgumentType; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.command.argument.DimensionArgumentType; +import net.minecraft.command.argument.IdentifierArgumentType; +import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.text.Texts; +import net.minecraft.text.*; 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.*; @@ -21,7 +20,7 @@ public class BlossomCommand { - public static void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess, RegistrationEnvironment environment) { + public static void register(CommandDispatcher dispatcher, RegistrationEnvironment environment) { dispatcher.register(literal("blossom") .then(literal("config") .requires(source -> source.hasPermissionLevel(4)) @@ -29,7 +28,7 @@ public static void register(CommandDispatcher dispatcher, C .executes(context -> { loadConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.config.reload"), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.config.reload"), true); return 1; }) ) @@ -52,7 +51,7 @@ public static void register(CommandDispatcher dispatcher, C ); saveConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.config.reset"), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.config.reset"), true); return 1; }) ) @@ -61,10 +60,10 @@ public static void register(CommandDispatcher dispatcher, C .requires(source -> source.hasPermissionLevel(4)) .then(literal("blossoming") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.blossoming.query", chance, distance), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.blossoming.query", chance, distance), true); return 1; }) .then(CommandManager.argument("chance", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -74,10 +73,10 @@ public static void register(CommandDispatcher dispatcher, C config.value.blossoming.distance = DoubleArgumentType.getDouble(context, "distance"); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.blossoming.set", chance, distance), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.blossoming.set", chance, distance), true); return 1; }) ) @@ -85,10 +84,10 @@ public static void register(CommandDispatcher dispatcher, C ) .then(literal("fruiting") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.fruiting.query", chance, distance), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.fruiting.query", chance, distance), false); return 1; }) .then(CommandManager.argument("chance", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -98,10 +97,10 @@ public static void register(CommandDispatcher dispatcher, C config.value.fruiting.distance = DoubleArgumentType.getDouble(context, "distance"); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.fruiting.set", chance, distance), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.fruiting.set", chance, distance), false); return 1; }) ) @@ -109,11 +108,11 @@ public static void register(CommandDispatcher dispatcher, C ) .then(literal("harvesting") .executes(context -> { - 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 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(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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.harvesting.query", bonus, chance), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.harvesting.query", bonus, chance), true); return 1; }) .then(CommandManager.argument("bonus", IntegerArgumentType.integer(0)) @@ -123,10 +122,10 @@ public static void register(CommandDispatcher dispatcher, C config.value.harvesting.chance = FloatArgumentType.getFloat(context, "chance"); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.value.harvesting.set", bonus, chance), true); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.value.harvesting.set", bonus, chance), true); return 1; }) ) @@ -137,10 +136,10 @@ public static void register(CommandDispatcher dispatcher, C .requires(source -> source.hasPermissionLevel(4)) .then(literal("temperature") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.query", min, max), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.query", min, max), false); return 1; }) .then(argument("min", FloatArgumentType.floatArg(-2.0F, 2.0F)) @@ -150,10 +149,10 @@ public static void register(CommandDispatcher dispatcher, C config.filter.temperature.max = Math.max(FloatArgumentType.getFloat(context, "max"), FloatArgumentType.getFloat(context, "min")); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.set", min, max), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.set", min, max), false); return 1; }) ) @@ -161,10 +160,10 @@ public static void register(CommandDispatcher dispatcher, C ) .then(literal("downfall") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.query", min, max), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.query", min, max), false); return 1; }) .then(argument("min", FloatArgumentType.floatArg(0.0F, 1.0F)) @@ -174,10 +173,10 @@ public static void register(CommandDispatcher dispatcher, C config.filter.downfall.max = Math.max(FloatArgumentType.getFloat(context, "max"), FloatArgumentType.getFloat(context, "min")); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.temperature.set", min, max), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.temperature.set", min, max), false); return 1; }) ) @@ -186,35 +185,35 @@ public static void register(CommandDispatcher dispatcher, C .then(literal("dimension") .then(literal("whitelist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.whitelist.query", list), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.query", list), false); return 1; }) .then(literal("add") - .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) + .then(argument("dimension", DimensionArgumentType.dimension()) .executes(context -> { - String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); + String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); if (Arrays.stream(config.filter.dimension.whitelist).anyMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.whitelist.add.failed", dimension)); + context.getSource().sendError(new TranslatableText("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(Text.translatable("commands.blossom.filter.dimension.whitelist.add", dimension), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.add", dimension), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) + .then(argument("dimension", DimensionArgumentType.dimension()) .executes(context -> { - String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); + String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); if (Arrays.stream(config.filter.dimension.whitelist).noneMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.whitelist.remove.failed", dimension)); + context.getSource().sendError(new TranslatableText("commands.blossom.filter.dimension.whitelist.remove.failed", dimension)); return 0; } else { for (String entry : config.filter.dimension.whitelist) { @@ -225,7 +224,7 @@ public static void register(CommandDispatcher dispatcher, C } saveConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.whitelist.remove", dimension), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.whitelist.remove", dimension), false); return 1; } }) @@ -234,35 +233,35 @@ public static void register(CommandDispatcher dispatcher, C ) .then(literal("blacklist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.blacklist.query", list), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.query", list), false); return 1; }) .then(literal("add") - .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) + .then(argument("dimension", DimensionArgumentType.dimension()) .executes(context -> { - String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); + String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); if (Arrays.stream(config.filter.dimension.blacklist).anyMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.add.failed", dimension)); + context.getSource().sendError(new TranslatableText("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(Text.translatable("commands.blossom.filter.dimension.blacklist.add", dimension), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.add", dimension), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("dimension", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.DIMENSION_TYPE)) + .then(argument("dimension", DimensionArgumentType.dimension()) .executes(context -> { - String dimension = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "dimension", RegistryKeys.DIMENSION_TYPE).asString(); + String dimension = context.getSource().getRegistryManager().get(Registry.DIMENSION_TYPE_KEY).getId(DimensionArgumentType.getDimensionArgument(context, "dimension").getDimension()).toString(); if (Arrays.stream(config.filter.dimension.blacklist).noneMatch(dimension::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.dimension.blacklist.remove.failed", dimension)); + context.getSource().sendError(new TranslatableText("commands.blossom.filter.dimension.blacklist.remove.failed", dimension)); return 0; } else { for (String entry : config.filter.dimension.blacklist) { @@ -273,7 +272,7 @@ public static void register(CommandDispatcher dispatcher, C } saveConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.dimension.blacklist.remove", dimension), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.dimension.blacklist.remove", dimension), false); return 1; } }) @@ -284,35 +283,37 @@ public static void register(CommandDispatcher dispatcher, C .then(literal("biome") .then(literal("whitelist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.whitelist.query", list), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.query", list), false); return 1; }) .then(literal("add") - .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) + .then(argument("biome", IdentifierArgumentType.identifier()) + .suggests(SuggestionProviders.ALL_BIOMES) .executes(context -> { - String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); + String biome = context.getArgument("biome", Identifier.class).toString(); if (Arrays.stream(config.filter.biome.whitelist).anyMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.whitelist.add.failed", biome)); + context.getSource().sendError(new TranslatableText("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(Text.translatable("commands.blossom.filter.biome.whitelist.add", biome), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.add", biome), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) + .then(argument("biome", IdentifierArgumentType.identifier()) + .suggests(SuggestionProviders.ALL_BIOMES) .executes(context -> { - String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); + String biome = context.getArgument("biome", Identifier.class).toString(); if (Arrays.stream(config.filter.biome.whitelist).noneMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.whitelist.remove.failed", biome)); + context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.whitelist.remove.failed", biome)); return 0; } else { for (String entry : config.filter.biome.whitelist) { @@ -323,7 +324,7 @@ public static void register(CommandDispatcher dispatcher, C } saveConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.whitelist.remove", biome), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.whitelist.remove", biome), false); return 1; } }) @@ -332,35 +333,37 @@ public static void register(CommandDispatcher dispatcher, C ) .then(literal("blacklist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.blacklist.query", list), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.query", list), false); return 1; }) .then(literal("add") - .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) + .then(argument("biome", IdentifierArgumentType.identifier()) + .suggests(SuggestionProviders.ALL_BIOMES) .executes(context -> { - String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); + String biome = context.getArgument("biome", Identifier.class).toString(); if (Arrays.stream(config.filter.biome.blacklist).anyMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.add.failed", biome)); + context.getSource().sendError(new TranslatableText("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(Text.translatable("commands.blossom.filter.biome.blacklist.add", biome), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.add", biome), false); return 1; } }) ) ) .then(literal("remove") - .then(argument("biome", RegistryEntryPredicateArgumentType.registryEntryPredicate(registryAccess, RegistryKeys.BIOME)) + .then(argument("biome", IdentifierArgumentType.identifier()) + .suggests(SuggestionProviders.ALL_BIOMES) .executes(context -> { - String biome = RegistryEntryPredicateArgumentType.getRegistryEntryPredicate(context, "biome", RegistryKeys.BIOME).asString(); + String biome = context.getArgument("biome", Identifier.class).toString(); if (Arrays.stream(config.filter.biome.blacklist).noneMatch(biome::equalsIgnoreCase)) { - context.getSource().sendError(Text.translatable("commands.blossom.filter.biome.blacklist.remove.failed", biome)); + context.getSource().sendError(new TranslatableText("commands.blossom.filter.biome.blacklist.remove.failed", biome)); return 0; } else { for (String entry : config.filter.biome.blacklist) { @@ -371,7 +374,7 @@ public static void register(CommandDispatcher dispatcher, C } saveConfig(); - context.getSource().sendFeedback(Text.translatable("commands.blossom.filter.biome.blacklist.remove", biome), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.filter.biome.blacklist.remove", biome), false); return 1; } }) @@ -384,9 +387,9 @@ public static void register(CommandDispatcher dispatcher, C .requires(source -> source.hasPermissionLevel(4)) .then(literal("whitelist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.whitelist.query", toggle), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.whitelist.query", toggle), false); return 1; }) .then(argument("value", BoolArgumentType.bool()) @@ -394,18 +397,18 @@ public static void register(CommandDispatcher dispatcher, C config.toggle.whitelist = BoolArgumentType.getBool(context, "value"); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.whitelist.set", toggle), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.whitelist.set", toggle), false); return 1; }) ) ) .then(literal("blacklist") .executes(context -> { - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.blacklist.query", toggle), false); + context.getSource().sendFeedback(new TranslatableText("commands.blossom.toggle.blacklist.query", toggle), false); return 1; }) .then(argument("value", BoolArgumentType.bool()) @@ -413,9 +416,9 @@ public static void register(CommandDispatcher dispatcher, C config.toggle.blacklist = BoolArgumentType.getBool(context, "value"); saveConfig(); - 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")))); + 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")))); - context.getSource().sendFeedback(Text.translatable("commands.blossom.toggle.blacklist.set", toggle), false); + context.getSource().sendFeedback(new TranslatableText("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 c6922b8b..c8e8021a 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "44,)" +loaderVersion = "37,)" 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.19.3,1.19.4)" +versionRange = "[1.17,1.18)" ordering = "NONE" side = "BOTH" [[dependencies.blossom]] modId = "forge" mandatory = true -versionRange = "[44,)" +versionRange = "[37,)" 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 4e892813..b5a5b5b1 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_17", + "compatibilityLevel": "JAVA_16", "mixins": [ "block.AbstractBlockMixin", "block.BlocksInvoker", @@ -12,13 +12,11 @@ "block.LeavesBlockMixin", "entity.EntityAccessor", "entity.MobEntityAccessor", - "entity.ai.goal.GoalInvoker", "entity.passive.BeeEntityAccessor", "entity.passive.BeeEntityInvoker", "entity.passive.BeeEntityMixin", "entity.passive.BeeEntityMixin$GrowCropsGoalMixin", - "entity.passive.BeeEntityMixin$MoveToFlowerGoalMixin", - "world.biome.BiomeAccessor" + "entity.passive.BeeEntityMixin$MoveToFlowerGoalMixin" ], "client": [ ],