mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Drop 1.18/1.18.1 Support, it now compiles
This commit is contained in:
@@ -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<Supplier<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving) {
|
||||
public Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving) {
|
||||
return settings.getCarvers(carving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Supplier<PlacedFeature>> getFeatures(GenerationStep.Decoration decoration) {
|
||||
public Iterable<Holder<PlacedFeature>> getFeatures(GenerationStep.Decoration decoration) {
|
||||
return settings.features().get(decoration.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<Supplier<PlacedFeature>>> getFeatures() {
|
||||
public List<HolderSet<PlacedFeature>> getFeatures() {
|
||||
return settings.features();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Supplier<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving);
|
||||
Iterable<Holder<ConfiguredWorldCarver<?>>> getCarvers(GenerationStep.Carving carving);
|
||||
|
||||
List<Supplier<PlacedFeature>> getFeatures(GenerationStep.Decoration decoration);
|
||||
Iterable<Holder<PlacedFeature>> getFeatures(GenerationStep.Decoration decoration);
|
||||
|
||||
List<List<Supplier<PlacedFeature>>> getFeatures();
|
||||
List<HolderSet<PlacedFeature>> getFeatures();
|
||||
|
||||
interface Mutable extends GenerationProperties {
|
||||
@ApiStatus.Experimental
|
||||
|
||||
@@ -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 <T> Tag.Named<T> optional(ResourceLocation id, Supplier<TagCollection<T>> collection) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static Tag.Named<Item> optionalItem(ResourceLocation id) {
|
||||
return optional(id, ItemTags::getAllTags);
|
||||
}
|
||||
|
||||
public static Tag.Named<Block> optionalBlock(ResourceLocation id) {
|
||||
return optional(id, BlockTags::getAllTags);
|
||||
}
|
||||
|
||||
public static Tag.Named<Fluid> optionalFluid(ResourceLocation id) {
|
||||
return optional(id, FluidTagsAccessor.getHelper()::getAllTags);
|
||||
}
|
||||
|
||||
public static Tag.Named<EntityType<?>> optionalEntityType(ResourceLocation id) {
|
||||
return optional(id, EntityTypeTags::getAllTags);
|
||||
}
|
||||
}
|
||||
@@ -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<Fluid> getHelper() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
"client": [
|
||||
],
|
||||
"mixins": [
|
||||
"FluidTagsAccessor",
|
||||
"MixinLightningBolt"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
@@ -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 <T> Tag.Named<T> optional(ResourceLocation id, Supplier<TagCollection<T>> collection) {
|
||||
return TagFactory.of(collection).create(id);
|
||||
}
|
||||
}
|
||||
@@ -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<Boolean> ci) {
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
@ModifyVariable(
|
||||
method = "setScreen",
|
||||
at = @At(value = "FIELD",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<Boolean> ci) {
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.invoker().click(player, InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
"client.MixinIntegratedServer",
|
||||
"client.MixinKeyboardHandler",
|
||||
"client.MixinMinecraft",
|
||||
"client.MixinMinecraft118",
|
||||
"client.MixinMinecraft1182",
|
||||
"client.MixinMouseHandler",
|
||||
"client.MixinMultiPlayerGameMode",
|
||||
"client.MixinScreen",
|
||||
|
||||
@@ -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 <T> Tag.Named<T> optional(ResourceLocation id, Supplier<TagCollection<T>> collection) {
|
||||
return new Tag.Named<T>() {
|
||||
private volatile Tag<T> backend;
|
||||
private volatile WeakReference<TagCollection<T>> backendCollection;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(T object) {
|
||||
return getBackend().contains(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getValues() {
|
||||
return getBackend().getValues();
|
||||
}
|
||||
|
||||
private Tag<T> getBackend() {
|
||||
TagCollection<T> 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();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
Reference in New Issue
Block a user