diff --git a/gradle.properties b/gradle.properties index 72c228cfe..d155f831b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ org.gradle.jvmargs=-Xmx3G # Mod properties -mod_version=1.100.1 +mod_version=1.100.2 # Minecraft properties -mc_version=1.18.1 -fabric_api_version=0.44.0+1.18 -fabric_loader_version=0.12.12 +mc_version=1.18.2 +fabric_api_version=0.47.8+1.18.2 +fabric_loader_version=0.13.3 cloth_api_version=2.0.54 cloth_config_version=6.0.42 diff --git a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java index c17710cca..ec5f3714e 100644 --- a/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java +++ b/src/main/java/dan200/computercraft/ComputerCraftAPIImpl.java @@ -22,7 +22,6 @@ import dan200.computercraft.core.apis.ApiFactories; import dan200.computercraft.core.asm.GenericMethod; import dan200.computercraft.core.filesystem.FileMount; import dan200.computercraft.core.filesystem.ResourceMount; -import dan200.computercraft.fabric.mixin.MinecraftServerAccess; import dan200.computercraft.shared.*; import dan200.computercraft.shared.peripheral.modem.wired.TileCable; import dan200.computercraft.shared.peripheral.modem.wired.TileWiredModemFull; @@ -34,7 +33,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ReloadableResourceManager; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -57,7 +56,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI public static InputStream getResourceFile( String domain, String subPath ) { - ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) GameInstanceUtils.getServer()).callGetResourceManager(); + ResourceManager manager = GameInstanceUtils.getServer().getResourceManager(); try { return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream(); @@ -100,7 +99,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI @Override public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath ) { - ReloadableResourceManager manager = (ReloadableResourceManager) ((MinecraftServerAccess) GameInstanceUtils.getServer()).callGetResourceManager(); + ResourceManager manager = GameInstanceUtils.getServer().getResourceManager(); ResourceMount mount = ResourceMount.get( domain, subPath, manager ); return mount.exists( "" ) ? mount : null; } diff --git a/src/main/java/dan200/computercraft/api/ComputerCraftTags.java b/src/main/java/dan200/computercraft/api/ComputerCraftTags.java index fc68ecc44..ab3064c8f 100644 --- a/src/main/java/dan200/computercraft/api/ComputerCraftTags.java +++ b/src/main/java/dan200/computercraft/api/ComputerCraftTags.java @@ -6,9 +6,9 @@ package dan200.computercraft.api; import dan200.computercraft.ComputerCraft; -import net.fabricmc.fabric.api.tag.TagFactory; +import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; @@ -19,47 +19,47 @@ public class ComputerCraftTags { public static class Items { - public static final Tag.Named COMPUTER = make( "computer" ); - public static final Tag.Named TURTLE = make( "turtle" ); - public static final Tag.Named WIRED_MODEM = make( "wired_modem" ); - public static final Tag.Named MONITOR = make( "monitor" ); + public static final TagKey COMPUTER = make( "computer" ); + public static final TagKey TURTLE = make( "turtle" ); + public static final TagKey WIRED_MODEM = make( "wired_modem" ); + public static final TagKey MONITOR = make( "monitor" ); - private static Tag.Named make( String name ) + private static TagKey make( String name ) { - return TagFactory.ITEM.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) ); + return TagKey.create( Registry.ITEM_REGISTRY, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); } } public static class Blocks { - public static final Tag.Named COMPUTER = make( "computer" ); - public static final Tag.Named TURTLE = make( "turtle" ); - public static final Tag.Named WIRED_MODEM = make( "wired_modem" ); - public static final Tag.Named MONITOR = make( "monitor" ); + public static final TagKey COMPUTER = make( "computer" ); + public static final TagKey TURTLE = make( "turtle" ); + public static final TagKey WIRED_MODEM = make( "wired_modem" ); + public static final TagKey MONITOR = make( "monitor" ); /** * Blocks which can be broken by any turtle tool. */ - public static final Tag.Named TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" ); + public static final TagKey TURTLE_ALWAYS_BREAKABLE = make( "turtle_always_breakable" ); /** * Blocks which can be broken by the default shovel tool. */ - public static final Tag.Named TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" ); + public static final TagKey TURTLE_SHOVEL_BREAKABLE = make( "turtle_shovel_harvestable" ); /** * Blocks which can be broken with the default sword tool. */ - public static final Tag.Named TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" ); + public static final TagKey TURTLE_SWORD_BREAKABLE = make( "turtle_sword_harvestable" ); /** * Blocks which can be broken with the default hoe tool. */ - public static final Tag.Named TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" ); + public static final TagKey TURTLE_HOE_BREAKABLE = make( "turtle_hoe_harvestable" ); - private static Tag.Named make( String name ) + private static TagKey make( String name ) { - return TagFactory.BLOCK.create( new ResourceLocation( ComputerCraft.MOD_ID, name ) ); + return TagKey.create( Registry.BLOCK_REGISTRY, new ResourceLocation( ComputerCraft.MOD_ID, name ) ); } } } diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MinecraftServerAccess.java b/src/main/java/dan200/computercraft/fabric/mixin/MinecraftServerAccess.java deleted file mode 100644 index 1b250337e..000000000 --- a/src/main/java/dan200/computercraft/fabric/mixin/MinecraftServerAccess.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package dan200.computercraft.fabric.mixin; - -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.packs.resources.ResourceManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin( MinecraftServer.class ) -public interface MinecraftServerAccess -{ - @Invoker - ResourceManager callGetResourceManager(); -} diff --git a/src/main/java/dan200/computercraft/shared/Registry.java b/src/main/java/dan200/computercraft/shared/Registry.java index 32f8f056c..c3d7ccabb 100644 --- a/src/main/java/dan200/computercraft/shared/Registry.java +++ b/src/main/java/dan200/computercraft/shared/Registry.java @@ -68,6 +68,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.MaterialColor; import java.util.function.BiFunction; @@ -157,7 +158,7 @@ public final class Registry private static BlockBehaviour.Properties modemProperties() { - return FabricBlockSettings.copyOf( Blocks.STONE ).breakByHand( true ).strength( 1.5f ); + return BlockBehaviour.Properties.of( Material.STONE, MaterialColor.STONE ).strength( 1.5f ); } } diff --git a/src/main/java/dan200/computercraft/shared/command/CommandUtils.java b/src/main/java/dan200/computercraft/shared/command/CommandUtils.java index 98f459061..f7f5a90a6 100644 --- a/src/main/java/dan200/computercraft/shared/command/CommandUtils.java +++ b/src/main/java/dan200/computercraft/shared/command/CommandUtils.java @@ -45,7 +45,7 @@ public final class CommandUtils } else { - return ((SharedSuggestionProvider) source).customSuggestion( (CommandContext) context, builder ); + return ((SharedSuggestionProvider) source).customSuggestion( context ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java index f21bb7c51..2c280fce6 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/DataHelpers.java @@ -7,8 +7,6 @@ package dan200.computercraft.shared.peripheral.generic.data; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ItemTags; import net.minecraft.world.item.Item; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.block.Block; @@ -18,6 +16,7 @@ import javax.annotation.Nullable; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; public final class DataHelpers { @@ -35,14 +34,14 @@ public final class DataHelpers @Nonnull static Map getTags( @Nonnull Block block ) { - Collection tags = BlockTags.getAllTags().getMatchingTags( block ); + Collection tags = block.builtInRegistryHolder().tags().map( tag -> tag.location() ).collect( Collectors.toList() ); return getTags( tags ); } @Nonnull static Map getTags( @Nonnull Item item ) { - Collection tags = ItemTags.getAllTags().getMatchingTags( item ); + Collection tags = item.builtInRegistryHolder().tags().map( tag -> tag.location() ).collect( Collectors.toList() ); return getTags( tags ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index 7b5de06d5..01b9e3064 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -27,7 +27,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.Tag; +import net.minecraft.tags.TagKey; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; @@ -62,9 +62,9 @@ public class TurtleTool extends AbstractTurtleUpgrade final ItemStack item; final float damageMulitiplier; @Nullable - final Tag breakable; + final TagKey breakable; - public TurtleTool( ResourceLocation id, Item item, float damageMulitiplier, @Nullable Tag breakable ) + public TurtleTool( ResourceLocation id, Item item, float damageMulitiplier, @Nullable TagKey breakable ) { super( id, TurtleUpgradeType.TOOL, new ItemStack( item ) ); this.item = new ItemStack( item ); @@ -122,7 +122,7 @@ public class TurtleTool extends AbstractTurtleUpgrade return UNBREAKABLE; } - return breakable == null || breakable.contains( state.getBlock() ) || isTriviallyBreakable( world, pos, state ) + return breakable == null || state.is( breakable ) || isTriviallyBreakable( world, pos, state ) ? TurtleCommandResult.success() : INEFFECTIVE; } diff --git a/src/main/resources/computercraft.mixins.json b/src/main/resources/computercraft.mixins.json index f92f23b39..f8cc4eda1 100644 --- a/src/main/resources/computercraft.mixins.json +++ b/src/main/resources/computercraft.mixins.json @@ -1,12 +1,10 @@ { "required": true, "package": "dan200.computercraft.fabric.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "mixins": [ "ConnectionAccess", "LevelResourceAccess", - "MinecraftServerAccess", - "MixinBlock", "MixinChunkMap", "MixinEntity", @@ -18,7 +16,6 @@ "client": [ "ChatComponentAccess", "ItemInHandRendererAccess", - "MixinGameRenderer", "MixinItemFrameRenderer", "MixinItemInHandRenderer", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index de8a23f3a..fa8bb6798 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ "Toad-Dev" ], "depends": { - "minecraft": "1.18.x", + "minecraft": ">=1.18.2-rc.1 <1.19", "fabricloader": ">=0.12.9", "fabric": "*" },