diff --git a/build.gradle b/build.gradle index 52145e5..7be11b6 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ archivesBaseName = "wthitharvestability-mc" + "${minecraft_version}" java.toolchain.languageVersion = JavaLanguageVersion.of(17) repositories { - maven { url "https://maven.bai.lol" } + maven { url "https://maven2.bai.lol" } maven { url "https://dvs1.progwml6.com/files/maven" } } diff --git a/gradle.properties b/gradle.properties index ba29ae1..5a9bfd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -mod_version=2.1.0 -minecraft_version=1.19.2 -forge_version= 43.1.3 +mod_version=2.2.0 +minecraft_version=1.20.1 +forge_version= 47.1.0 mappings_version=20200723-1.16.1 -wthit_version=5.11.3 -badpackets_version=0.2.0 +wthit_version=8.4.0 +badpackets_version=0.4.2 mantle_version=1.18.2-1.9.28 tconstruct_version=1.18.2-3.5.1.35 diff --git a/java/squeek/wthitharvestability/WailaHandler.java b/java/squeek/wthitharvestability/WailaHandler.java index 4a66ef1..c2ae42e 100644 --- a/java/squeek/wthitharvestability/WailaHandler.java +++ b/java/squeek/wthitharvestability/WailaHandler.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; + import mcp.mobius.waila.api.IBlockAccessor; import mcp.mobius.waila.api.IBlockComponentProvider; import mcp.mobius.waila.api.IEventListener; @@ -10,7 +11,6 @@ import mcp.mobius.waila.api.ITooltip; import mcp.mobius.waila.api.IWailaPlugin; import mcp.mobius.waila.api.TooltipPosition; -import mcp.mobius.waila.api.WailaPlugin; import net.minecraft.ChatFormatting; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; @@ -34,7 +34,6 @@ import squeek.wthitharvestability.helpers.ToolHelper; import squeek.wthitharvestability.helpers.ToolType; -@WailaPlugin(id = WailaHarvestability.MOD_ID + ":plugin") public class WailaHandler implements IBlockComponentProvider, IEventListener, IWailaPlugin { @Override @@ -89,7 +88,7 @@ public void getHarvestability(List stringList, Player player, BlockSt return; } - if (BlockHelper.isAdventureModeAndBlockIsUnbreakable(player, pos) || BlockHelper.isBlockUnbreakable(player.level, pos, state)) { + if (BlockHelper.isAdventureModeAndBlockIsUnbreakable(player, pos) || BlockHelper.isBlockUnbreakable(player.level(), pos, state)) { Component unbreakableString = Component.literal(ColorHelper.getBooleanColor(false)).append(config.getString(HARVESTABLE_FALSE_STRING)).append(" ").append(!minimalLayout ? Component.translatable("waila.h12y.harvestable").withStyle(ChatFormatting.RESET) : Component.literal("")); stringList.add(unbreakableString); return; @@ -102,7 +101,7 @@ public void getHarvestability(List stringList, Player player, BlockSt break; } } - ToolType effectiveTool = BlockHelper.getEffectiveToolOf(player.level, pos, state); + ToolType effectiveTool = BlockHelper.getEffectiveToolOf(player.level(), pos, state); if (effectiveTool == null) harvestTier = null; @@ -173,7 +172,7 @@ public String getShearabilityString(Player player, BlockState state, BlockPos po if (showShearability && canBeSheared) { ItemStack heldStack = player.getMainHandItem(); boolean isHoldingShears = !heldStack.isEmpty() && heldStack.getItem() instanceof ShearsItem; - boolean isShearable = isHoldingShears && (isDoublePlant || ((IForgeShearable) state.getBlock()).isShearable(heldStack, player.level, pos)); + boolean isShearable = isHoldingShears && (isDoublePlant || ((IForgeShearable) state.getBlock()).isShearable(heldStack, player.level(), pos)); return ColorHelper.getBooleanColor(isShearable, !isShearable && isHoldingShears) + config.getString(SHEARABILITY_STRING); } return ""; diff --git a/java/squeek/wthitharvestability/helpers/BlockHelper.java b/java/squeek/wthitharvestability/helpers/BlockHelper.java index 82771f3..9bb1028 100644 --- a/java/squeek/wthitharvestability/helpers/BlockHelper.java +++ b/java/squeek/wthitharvestability/helpers/BlockHelper.java @@ -1,11 +1,12 @@ package squeek.wthitharvestability.helpers; import java.util.Map; + import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.tags.TagKey; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -53,9 +54,9 @@ public static boolean isAdventureModeAndBlockIsUnbreakable(Player player, BlockP return false; ItemStack heldItem = player.getMainHandItem(); - Level world = player.level; + Level world = player.level(); - return gameType == GameType.SPECTATOR || heldItem.isEmpty() || !heldItem.hasAdventureModeBreakTagForBlock(world.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY), new BlockInWorld(world, pos, false)); + return gameType == GameType.SPECTATOR || heldItem.isEmpty() || !heldItem.hasAdventureModeBreakTagForBlock(world.registryAccess().registryOrThrow(Registries.BLOCK), new BlockInWorld(world, pos, false)); } /** diff --git a/java/squeek/wthitharvestability/helpers/ToolType.java b/java/squeek/wthitharvestability/helpers/ToolType.java index fc8ab50..5354975 100644 --- a/java/squeek/wthitharvestability/helpers/ToolType.java +++ b/java/squeek/wthitharvestability/helpers/ToolType.java @@ -2,7 +2,8 @@ import java.util.HashMap; import java.util.Map; -import net.minecraft.core.Registry; + +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; @@ -26,7 +27,7 @@ public record ToolType( register(new ToolType(BlockTags.MINEABLE_WITH_SHOVEL, new ItemStack(Items.WOODEN_SHOVEL), ToolActions.SHOVEL_DIG, "shovel")); register(new ToolType(BlockTags.MINEABLE_WITH_AXE, new ItemStack(Items.WOODEN_AXE), ToolActions.AXE_DIG, "axe")); register(new ToolType(BlockTags.MINEABLE_WITH_HOE, new ItemStack(Items.WOODEN_HOE), ToolActions.HOE_DIG, "hoe")); - register(new ToolType(TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation("forge:mineable/sword")), new ItemStack(Items.WOODEN_SWORD), ToolActions.SWORD_DIG, "sword")); + register(new ToolType(TagKey.create(Registries.BLOCK, new ResourceLocation("forge:mineable/sword")), new ItemStack(Items.WOODEN_SWORD), ToolActions.SWORD_DIG, "sword")); } public static void register(ToolType toolType) { diff --git a/resources/META-INF/mods.toml b/resources/META-INF/mods.toml index 05691e1..49521c7 100644 --- a/resources/META-INF/mods.toml +++ b/resources/META-INF/mods.toml @@ -17,7 +17,7 @@ license="The Unlicense" [[dependencies.wthitharvestability]] modId="wthit" mandatory=true - versionRange="[5.11,)" + versionRange="[8.4.0,)" ordering="AFTER" side="BOTH" diff --git a/resources/waila_plugins.json b/resources/waila_plugins.json new file mode 100644 index 0000000..1f43a14 --- /dev/null +++ b/resources/waila_plugins.json @@ -0,0 +1,5 @@ +{ + "wthitharvestability:plugin": { + "initializer": "squeek.wthitharvestability.WailaHandler" + } +} \ No newline at end of file