This commit is contained in:
modmuss
2023-08-31 12:50:38 +01:00
committed by GitHub
parent 017b9d93e2
commit fce67b32cf
36 changed files with 366 additions and 504 deletions

View File

@@ -1,49 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.api.object.builder.v1.advancement;
import net.minecraft.advancement.criterion.Criterion;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.mixin.object.builder.CriteriaAccessor;
/**
* Allows registering advancement criteria for triggers.
*
* <p>A registered criterion (trigger) can be retrieved through
* {@link net.minecraft.advancement.criterion.Criteria#getById(Identifier)}.</p>
*
* @see net.minecraft.advancement.criterion.Criteria
* @deprecated Replaced by access widener for {@link net.minecraft.advancement.criterion.Criteria#register(Criterion)}
* in Fabric Transitive Access Wideners (v1).
*/
@Deprecated
public final class CriterionRegistry {
/**
* Registers a criterion for a trigger for advancements.
*
* @param <T> the criterion's type
* @param criterion the criterion registered
* @return the criterion registered, for chaining
* @throws IllegalArgumentException if a criterion with the same {@link
* Criterion#getId() id} exists
*/
public static <T extends Criterion<?>> T register(T criterion) {
CriteriaAccessor.callRegister(criterion);
return criterion;
}
}

View File

@@ -1,31 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.object.builder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.advancement.criterion.Criterion;
@Mixin(Criteria.class)
public interface CriteriaAccessor {
@Invoker
static <T extends Criterion<?>> T callRegister(T object) {
throw new AssertionError("Mixin dummy");
}
}

View File

@@ -5,7 +5,6 @@
"mixins": [
"AbstractBlockAccessor",
"AbstractBlockSettingsAccessor",
"CriteriaAccessor",
"DefaultAttributeRegistryAccessor",
"DefaultAttributeRegistryMixin",
"DetectorRailBlockMixin",

View File

@@ -1,46 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.test.object.builder;
import com.google.gson.JsonObject;
import net.minecraft.advancement.criterion.ImpossibleCriterion;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.object.builder.v1.advancement.CriterionRegistry;
public final class CriterionRegistryTest {
public static void init() {
CriterionRegistry.register(new CustomCriterion());
}
static class CustomCriterion extends ImpossibleCriterion {
static final Identifier ID = ObjectBuilderTestConstants.id("custom");
@Override
public Identifier getId() {
return ID;
}
@Override
public Conditions conditionsFromJson(JsonObject jsonObject, AdvancementEntityPredicateDeserializer advancementEntityPredicateDeserializer) {
ObjectBuilderTestConstants.LOGGER.info("Loading custom criterion in advancement!");
return super.conditionsFromJson(jsonObject, advancementEntityPredicateDeserializer);
}
}
}

View File

@@ -1,28 +0,0 @@
{
"display": {
"icon": {
"item": "minecraft:command_block_minecart"
},
"title": {
"text": "Criterion registry test advancement"
},
"description": {
"text": "Criterion registry test advancement description"
},
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": false,
"background": "minecraft:textures/gui/advancements/backgrounds/stone.png"
},
"criteria": {
"custom": {
"trigger": "fabric-object-builder-api-v1-testmod:custom"
}
},
"requirements": [
[
"custom"
]
]
}

View File

@@ -29,7 +29,6 @@
"entrypoints": {
"main": [
"net.fabricmc.fabric.test.object.builder.BlockEntityTypeBuilderTest",
"net.fabricmc.fabric.test.object.builder.CriterionRegistryTest::init",
"net.fabricmc.fabric.test.object.builder.FabricBlockSettingsTest",
"net.fabricmc.fabric.test.object.builder.VillagerTypeTest1",
"net.fabricmc.fabric.test.object.builder.VillagerTypeTest2",