From 6dff58485f437422cdab270cc023b2c1bfd61d3c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 10 Feb 2022 10:03:56 +0800 Subject: [PATCH] Drop 1.18/1.18.1 Support, it now compiles --- .../hooks/level/biome/BiomeHooks.java | 8 +- .../level/biome/GenerationProperties.java | 9 ++- .../dev/architectury/hooks/tags/TagHooks.java | 57 ------------- .../architectury/mixin/FluidTagsAccessor.java | 34 -------- .../resources/architectury-common.mixins.json | 1 - .../hooks/tags/fabric/TagHooksImpl.java | 33 -------- .../mixin/fabric/client/MixinMinecraft.java | 5 ++ .../fabric/client/MixinMinecraft118.java | 45 ----------- .../fabric/client/MixinMinecraft1182.java | 45 ----------- .../fabric/ArchitecturyMixinPlugin.java | 19 ----- .../main/resources/architectury.mixins.json | 2 - .../hooks/tags/forge/TagHooksImpl.java | 79 ------------------- gradle.properties | 4 +- .../dev/architectury/test/tags/TestTags.java | 9 +-- 14 files changed, 21 insertions(+), 329 deletions(-) delete mode 100644 common/src/main/java/dev/architectury/hooks/tags/TagHooks.java delete mode 100644 common/src/main/java/dev/architectury/mixin/FluidTagsAccessor.java delete mode 100644 fabric/src/main/java/dev/architectury/hooks/tags/fabric/TagHooksImpl.java delete mode 100644 fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft118.java delete mode 100644 fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft1182.java delete mode 100644 forge/src/main/java/dev/architectury/hooks/tags/forge/TagHooksImpl.java diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java index 2c792f58..ce244b82 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java @@ -19,6 +19,8 @@ package dev.architectury.hooks.level.biome; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; import net.minecraft.sounds.Music; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.EntityType; @@ -358,17 +360,17 @@ public final class BiomeHooks { } @Override - public List>> getCarvers(GenerationStep.Carving carving) { + public Iterable>> getCarvers(GenerationStep.Carving carving) { return settings.getCarvers(carving); } @Override - public List> getFeatures(GenerationStep.Decoration decoration) { + public Iterable> getFeatures(GenerationStep.Decoration decoration) { return settings.features().get(decoration.ordinal()); } @Override - public List>> getFeatures() { + public List> getFeatures() { return settings.features(); } } diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java index 98eb7155..92fb0138 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java @@ -19,20 +19,21 @@ package dev.architectury.hooks.level.biome; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import org.jetbrains.annotations.ApiStatus; import java.util.List; -import java.util.function.Supplier; public interface GenerationProperties { - List>> getCarvers(GenerationStep.Carving carving); + Iterable>> getCarvers(GenerationStep.Carving carving); - List> getFeatures(GenerationStep.Decoration decoration); + Iterable> getFeatures(GenerationStep.Decoration decoration); - List>> getFeatures(); + List> getFeatures(); interface Mutable extends GenerationProperties { @ApiStatus.Experimental diff --git a/common/src/main/java/dev/architectury/hooks/tags/TagHooks.java b/common/src/main/java/dev/architectury/hooks/tags/TagHooks.java deleted file mode 100644 index cfab7552..00000000 --- a/common/src/main/java/dev/architectury/hooks/tags/TagHooks.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.hooks.tags; - -import dev.architectury.injectables.annotations.ExpectPlatform; -import dev.architectury.mixin.FluidTagsAccessor; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.*; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.material.Fluid; - -import java.util.function.Supplier; - -public final class TagHooks { - private TagHooks() { - } - - @ExpectPlatform - public static Tag.Named optional(ResourceLocation id, Supplier> collection) { - throw new AssertionError(); - } - - public static Tag.Named optionalItem(ResourceLocation id) { - return optional(id, ItemTags::getAllTags); - } - - public static Tag.Named optionalBlock(ResourceLocation id) { - return optional(id, BlockTags::getAllTags); - } - - public static Tag.Named optionalFluid(ResourceLocation id) { - return optional(id, FluidTagsAccessor.getHelper()::getAllTags); - } - - public static Tag.Named> optionalEntityType(ResourceLocation id) { - return optional(id, EntityTypeTags::getAllTags); - } -} diff --git a/common/src/main/java/dev/architectury/mixin/FluidTagsAccessor.java b/common/src/main/java/dev/architectury/mixin/FluidTagsAccessor.java deleted file mode 100644 index c89f8ff2..00000000 --- a/common/src/main/java/dev/architectury/mixin/FluidTagsAccessor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.mixin; - -import net.minecraft.tags.FluidTags; -import net.minecraft.tags.StaticTagHelper; -import net.minecraft.world.level.material.Fluid; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(FluidTags.class) -public interface FluidTagsAccessor { - @Accessor("HELPER") - static StaticTagHelper getHelper() { - throw new AssertionError(); - } -} diff --git a/common/src/main/resources/architectury-common.mixins.json b/common/src/main/resources/architectury-common.mixins.json index 618fbf85..989561ab 100644 --- a/common/src/main/resources/architectury-common.mixins.json +++ b/common/src/main/resources/architectury-common.mixins.json @@ -6,7 +6,6 @@ "client": [ ], "mixins": [ - "FluidTagsAccessor", "MixinLightningBolt" ], "injectors": { diff --git a/fabric/src/main/java/dev/architectury/hooks/tags/fabric/TagHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/tags/fabric/TagHooksImpl.java deleted file mode 100644 index f190d388..00000000 --- a/fabric/src/main/java/dev/architectury/hooks/tags/fabric/TagHooksImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.hooks.tags.fabric; - -import net.fabricmc.fabric.api.tag.TagFactory; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagCollection; - -import java.util.function.Supplier; - -public class TagHooksImpl { - public static Tag.Named optional(ResourceLocation id, Supplier> collection) { - return TagFactory.of(collection).create(id); - } -} diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java index fac44d07..8c99560a 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java @@ -71,6 +71,11 @@ public abstract class MixinMinecraft { } } + @Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0)) + private void leftClickAir(CallbackInfoReturnable ci) { + InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND); + } + @ModifyVariable( method = "setScreen", at = @At(value = "FIELD", diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft118.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft118.java deleted file mode 100644 index aacb556b..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft118.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.mixin.fabric.client; - -import dev.architectury.event.events.common.InteractionEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.InteractionHand; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Unique -@Mixin(Minecraft.class) -public abstract class MixinMinecraft118 { - @Shadow - @Nullable - public LocalPlayer player; - - @Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0)) - private void leftClickAir(CallbackInfo ci) { - InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND); - } -} diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft1182.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft1182.java deleted file mode 100644 index 34a390c7..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft1182.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.mixin.fabric.client; - -import dev.architectury.event.events.common.InteractionEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.InteractionHand; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Unique -@Mixin(Minecraft.class) -public class MixinMinecraft1182 { - @Shadow - @Nullable - public LocalPlayer player; - - @Inject(method = "startAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;resetAttackStrengthTicker()V", ordinal = 0)) - private void leftClickAir(CallbackInfoReturnable ci) { - InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND); - } -} diff --git a/fabric/src/main/java/dev/architectury/plugin/fabric/ArchitecturyMixinPlugin.java b/fabric/src/main/java/dev/architectury/plugin/fabric/ArchitecturyMixinPlugin.java index 7d0702f9..a4bdf3d7 100644 --- a/fabric/src/main/java/dev/architectury/plugin/fabric/ArchitecturyMixinPlugin.java +++ b/fabric/src/main/java/dev/architectury/plugin/fabric/ArchitecturyMixinPlugin.java @@ -53,21 +53,6 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin { return true; } - private boolean isMinecraft1182() { - ModContainer minecraft = FabricLoader.getInstance().getModContainer("minecraft") - .orElseThrow(() -> new IllegalStateException("Where is minecraft?")); - Version version = minecraft.getMetadata().getVersion(); - if (version instanceof SemanticVersion) { - try { - return version.compareTo(SemanticVersion.parse("1.18.2-")) >= 0; - } catch (VersionParsingException e) { - throw new IllegalStateException("Failed to parse version", e); - } - } - System.err.println("Minecraft is not a SemanticVersion, cannot determine if it is >= 1.18.2"); - return true; - } - @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if ("dev.architectury.mixin.fabric.client.MixinEffectInstance".equals(mixinClassName)) { @@ -76,10 +61,6 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin { return !isLoader013(); } else if ("dev.architectury.mixin.fabric.client.MixinGameRenderer013".equals(mixinClassName)) { return isLoader013(); - } else if ("dev.architectury.mixin.fabric.client.MixinMinecraft118".equals(mixinClassName)) { - return !isMinecraft1182(); - } else if ("dev.architectury.mixin.fabric.client.MixinMinecraft1182".equals(mixinClassName)) { - return isMinecraft1182(); } return true; } diff --git a/fabric/src/main/resources/architectury.mixins.json b/fabric/src/main/resources/architectury.mixins.json index 8acbe4c4..fcad6648 100644 --- a/fabric/src/main/resources/architectury.mixins.json +++ b/fabric/src/main/resources/architectury.mixins.json @@ -14,8 +14,6 @@ "client.MixinIntegratedServer", "client.MixinKeyboardHandler", "client.MixinMinecraft", - "client.MixinMinecraft118", - "client.MixinMinecraft1182", "client.MixinMouseHandler", "client.MixinMultiPlayerGameMode", "client.MixinScreen", diff --git a/forge/src/main/java/dev/architectury/hooks/tags/forge/TagHooksImpl.java b/forge/src/main/java/dev/architectury/hooks/tags/forge/TagHooksImpl.java deleted file mode 100644 index 1f5aa2e7..00000000 --- a/forge/src/main/java/dev/architectury/hooks/tags/forge/TagHooksImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.hooks.tags.forge; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagCollection; - -import java.lang.ref.WeakReference; -import java.util.List; -import java.util.Objects; -import java.util.function.Supplier; - -public class TagHooksImpl { - public static Tag.Named optional(ResourceLocation id, Supplier> collection) { - return new Tag.Named() { - private volatile Tag backend; - private volatile WeakReference> backendCollection; - - @Override - public ResourceLocation getName() { - return id; - } - - @Override - public boolean contains(T object) { - return getBackend().contains(object); - } - - @Override - public List getValues() { - return getBackend().getValues(); - } - - private Tag getBackend() { - TagCollection currentCollection = collection.get(); - - if (backend == null || backendCollection == null || backendCollection.get() != currentCollection) { // If not initialized or was tag changed. - backendCollection = new WeakReference<>(currentCollection); - return backend = currentCollection.getTagOrEmpty(id); - } else { - return backend; - } - } - - @Override - public String toString() { - return "OptionalNamedTag[" + getName().toString() + ']'; - } - - @Override - public boolean equals(Object o) { - return o == this || o instanceof Named && Objects.equals(getName(), ((Named) o).getName()); - } - - @Override - public int hashCode() { - return getName().hashCode(); - } - }; - } -} diff --git a/gradle.properties b/gradle.properties index de387fcc..eb35e949 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.daemon=false forgeEnabled=false -minecraft_version=22w05a -supported_version=1.18.2 (22w05a) +minecraft_version=22w06a +supported_version=1.18.2 (22w06a) cf_type=release diff --git a/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java b/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java index f9e13ef2..ec592d4d 100644 --- a/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java +++ b/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java @@ -21,20 +21,19 @@ package dev.architectury.test.tags; import dev.architectury.event.EventResult; import dev.architectury.event.events.common.BlockEvent; -import dev.architectury.hooks.tags.TagHooks; import dev.architectury.test.TestMod; +import net.minecraft.core.Registry; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; -import net.minecraft.tags.Tag; -import net.minecraft.world.level.block.Block; +import net.minecraft.tags.TagKey; public class TestTags { public static void initialize() { // This will not be present, but it should return an empty tag - var heartParticles = TagHooks.optionalBlock(new ResourceLocation(TestMod.MOD_ID, "heart_particles")); + var heartParticles = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(TestMod.MOD_ID, "heart_particles")); // This will act like a normal tag, we have emerald block here - var heartParticles2 = TagHooks.optionalBlock(new ResourceLocation(TestMod.MOD_ID, "heart_particles2")); + var heartParticles2 = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(TestMod.MOD_ID, "heart_particles2")); BlockEvent.BREAK.register((world, pos, state, player, xp) -> { if (player != null && !world.isClientSide() && (state.is(heartParticles) || state.is(heartParticles2))) {