mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-13 16:53:35 -04:00
Even more fixes
This commit is contained in:
parent
ff06767f0f
commit
ca04f2463c
18 changed files with 85 additions and 114 deletions
|
@ -208,11 +208,11 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
|
|||
.input(Ingredient.ofItems(Items.DIAMOND_PICKAXE))
|
||||
.input(Ingredient.ofItems(Items.DIAMOND_PICKAXE))
|
||||
.input(DefaultCustomIngredients.components(
|
||||
Ingredient.ofItems(Items.DIAMOND_PICKAXE),
|
||||
ComponentChanges.builder()
|
||||
.add(DataComponentTypes.DAMAGE, 0)
|
||||
.build()
|
||||
)
|
||||
Ingredient.ofItems(Items.DIAMOND_PICKAXE),
|
||||
ComponentChanges.builder()
|
||||
.add(DataComponentTypes.DAMAGE, 0)
|
||||
.build()
|
||||
)
|
||||
)
|
||||
.input(Ingredient.ofItems(Items.DIAMOND_PICKAXE))
|
||||
.input(Ingredient.ofItems(Items.DIAMOND_PICKAXE))
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:diamond_ore"
|
||||
},
|
||||
{
|
||||
"item": "fabric-item-api-v1-testmod:weird_pickaxe"
|
||||
}
|
||||
"minecraft:diamond_ore",
|
||||
"fabric-item-api-v1-testmod:weird_pickaxe"
|
||||
],
|
||||
"result": {
|
||||
"id": "minecraft:diamond",
|
||||
|
|
|
@ -48,8 +48,7 @@ public final class ClientTickTests implements ClientModInitializer {
|
|||
|
||||
ClientTickEvents.END_WORLD_TICK.register(world -> {
|
||||
if (!tagsLoadedCalled) {
|
||||
// TODO 24w33a port
|
||||
//throw new IllegalStateException("TAGS_LOADED was not invoked during configuration!");
|
||||
throw new IllegalStateException("TAGS_LOADED was not invoked during configuration!");
|
||||
}
|
||||
|
||||
final int worldTicks = this.tickTracker.computeIfAbsent(world.getRegistryKey(), k -> 0);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.jetbrains.annotations.ApiStatus;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
|
||||
import net.fabricmc.fabric.impl.recipe.ingredient.CustomIngredientImpl;
|
||||
|
||||
|
@ -71,7 +72,7 @@ public interface CustomIngredient {
|
|||
*
|
||||
* <p>Note: no caching needs to be done by the implementation, this is already handled by the ingredient itself.
|
||||
*/
|
||||
List<ItemStack> getMatchingStacks();
|
||||
List<RegistryEntry<Item>> getMatchingStacks();
|
||||
|
||||
/**
|
||||
* Returns whether this ingredient always requires {@linkplain #test direct stack testing}.
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.entry.RegistryEntryList;
|
||||
|
@ -74,7 +75,8 @@ public class CustomIngredientImpl extends Ingredient {
|
|||
private final CustomIngredient customIngredient;
|
||||
|
||||
public CustomIngredientImpl(CustomIngredient customIngredient) {
|
||||
super(RegistryEntryList.empty());
|
||||
// We must pass a registry entry list that contains something that isn't air. It doesn't actually get used.
|
||||
super(RegistryEntryList.of(Items.STONE.getRegistryEntry()));
|
||||
|
||||
this.customIngredient = customIngredient;
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ public class CustomIngredientImpl extends Ingredient {
|
|||
@Override
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
if (this.matchingStacks == null) {
|
||||
this.matchingStacks = customIngredient.toVanilla().getMatchingStacks();
|
||||
this.matchingStacks = customIngredient.getMatchingStacks();
|
||||
}
|
||||
|
||||
return this.matchingStacks;
|
||||
|
@ -102,13 +104,4 @@ public class CustomIngredientImpl extends Ingredient {
|
|||
public boolean test(@Nullable ItemStack stack) {
|
||||
return stack != null && customIngredient.test(stack);
|
||||
}
|
||||
|
||||
// TODO 24w33a
|
||||
/*@Override
|
||||
public boolean isEmpty() {
|
||||
// We don't want to resolve the matching stacks,
|
||||
// as this might cause the ingredient to use outdated tags when it's done too early.
|
||||
// So we just return false when the matching stacks haven't been resolved yet (i.e. when the field is null).
|
||||
return matchingStacks != null && matchingStacks.length == 0;
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
package net.fabricmc.fabric.impl.recipe.ingredient.builtin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredientSerializer;
|
||||
|
@ -53,16 +53,11 @@ public class AllIngredient extends CombinedIngredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatchingStacks() {
|
||||
// There's always at least one sub ingredient, so accessing ingredients[0] is safe.
|
||||
List<ItemStack> previewStacks = ingredients.get(0).getMatchingStacks().stream().map(a -> new ItemStack(a)).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
for (int i = 1; i < ingredients.size(); ++i) {
|
||||
Ingredient ing = ingredients.get(i);
|
||||
previewStacks.removeIf(stack -> !ing.test(stack));
|
||||
}
|
||||
|
||||
return previewStacks;
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
return ingredients.stream()
|
||||
.flatMap(ingredient -> ingredient.getMatchingStacks().stream())
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,12 +53,11 @@ public class AnyIngredient extends CombinedIngredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatchingStacks() {
|
||||
return ingredients.stream().<ItemStack>mapMulti((ingredient, consumer) -> {
|
||||
for (RegistryEntry<Item> entry : ingredient.getMatchingStacks()) {
|
||||
consumer.accept(new ItemStack(entry));
|
||||
}
|
||||
}).toList();
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
return ingredients.stream()
|
||||
.flatMap(ingredient -> ingredient.getMatchingStacks().stream())
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,10 +27,12 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import net.minecraft.component.ComponentChanges;
|
||||
import net.minecraft.component.ComponentType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredient;
|
||||
|
@ -81,14 +83,14 @@ public class ComponentsIngredient implements CustomIngredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatchingStacks() {
|
||||
return base.getMatchingStacks().stream().map(entry -> {
|
||||
var stack = new ItemStack(entry);
|
||||
|
||||
stack.applyChanges(components);
|
||||
|
||||
return stack;
|
||||
}).filter(stack -> base.test(stack)).toList();
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
return base.getMatchingStacks().stream()
|
||||
.filter(registryEntry -> {
|
||||
ItemStack itemStack = registryEntry.value().getDefaultStack();
|
||||
itemStack.applyChanges(components);
|
||||
return base.test(itemStack);
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|||
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.NbtComponent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.StringNbtReader;
|
||||
|
@ -30,6 +31,7 @@ import net.minecraft.network.RegistryByteBuf;
|
|||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredient;
|
||||
|
@ -57,17 +59,14 @@ public class CustomDataIngredient implements CustomIngredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatchingStacks() {
|
||||
return List.of();
|
||||
// TODO 24w33a port
|
||||
/*List<ItemStack> stacks = new ArrayList<>(List.of(base.getMatchingStacks()));
|
||||
stacks.replaceAll(stack -> {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, existingNbt -> NbtComponent.of(existingNbt.copyNbt().copyFrom(this.nbt)));
|
||||
return copy;
|
||||
});
|
||||
stacks.removeIf(stack -> !base.test(stack));
|
||||
return stacks;*/
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
return base.getMatchingStacks().stream()
|
||||
.filter(registryEntry -> {
|
||||
ItemStack itemStack = registryEntry.value().getDefaultStack();
|
||||
itemStack.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, existingNbt -> NbtComponent.of(existingNbt.copyNbt().copyFrom(nbt)));
|
||||
return base.test(itemStack);
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,10 +21,12 @@ import java.util.List;
|
|||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredient;
|
||||
|
@ -47,12 +49,11 @@ public class DifferenceIngredient implements CustomIngredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatchingStacks() {
|
||||
return List.of();
|
||||
// TODO 24w33a port
|
||||
//List<ItemStack> stacks = new ArrayList<>(List.of(base.getMatchingStacks()));
|
||||
//stacks.removeIf(subtracted);
|
||||
//return stacks;
|
||||
public List<RegistryEntry<Item>> getMatchingStacks() {
|
||||
final List<RegistryEntry<Item>> subtractedMatchingStacks = subtracted.getMatchingStacks();
|
||||
return base.getMatchingStacks().stream()
|
||||
.filter(registryEntry -> !subtractedMatchingStacks.contains(registryEntry))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,40 +1,22 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe",
|
||||
{
|
||||
"fabric:type": "fabric:components",
|
||||
"base": {
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
"base": "minecraft:diamond_pickaxe",
|
||||
"components": {
|
||||
"minecraft:damage": 0
|
||||
},
|
||||
"strict": false
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:diamond_pickaxe"
|
||||
}
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe",
|
||||
"minecraft:diamond_pickaxe"
|
||||
],
|
||||
"result": {
|
||||
"id": "minecraft:diamond_block"
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
|||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -72,13 +71,13 @@ public interface ArmorRenderer {
|
|||
/**
|
||||
* Renders an armor part.
|
||||
*
|
||||
* @param matrices the matrix stack
|
||||
* @param vertexConsumers the vertex consumer provider
|
||||
* @param stack the item stack of the armor item
|
||||
* @param entity the entity wearing the armor item
|
||||
* @param slot the equipment slot in which the armor stack is worn
|
||||
* @param light packed lightmap coordinates
|
||||
* @param contextModel the model provided by {@link FeatureRenderer#getContextModel()}
|
||||
* @param matrices the matrix stack
|
||||
* @param vertexConsumers the vertex consumer provider
|
||||
* @param stack the item stack of the armor item
|
||||
* @param bipedEntityRenderState the render state of the entity
|
||||
* @param slot the equipment slot in which the armor stack is worn
|
||||
* @param light packed lightmap coordinates
|
||||
* @param contextModel the model provided by {@link FeatureRenderer#getContextModel()}
|
||||
*/
|
||||
void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ItemStack stack, LivingEntity entity, EquipmentSlot slot, int light, BipedEntityModel<BipedEntityRenderState> contextModel);
|
||||
void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ItemStack stack, BipedEntityRenderState bipedEntityRenderState, EquipmentSlot slot, int light, BipedEntityModel<BipedEntityRenderState> contextModel);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package net.fabricmc.fabric.mixin.client.rendering;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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;
|
||||
|
@ -36,17 +37,24 @@ import net.fabricmc.fabric.impl.client.rendering.ArmorRendererRegistryImpl;
|
|||
|
||||
@Mixin(ArmorFeatureRenderer.class)
|
||||
public abstract class ArmorFeatureRendererMixin<S extends BipedEntityRenderState, M extends BipedEntityModel<S>, A extends BipedEntityModel<S>> extends FeatureRenderer<S, M> {
|
||||
@Unique
|
||||
private BipedEntityRenderState bipedRenderState;
|
||||
|
||||
public ArmorFeatureRendererMixin(FeatureRendererContext<S, M> featureRendererContext) {
|
||||
super(featureRendererContext);
|
||||
}
|
||||
|
||||
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V", at = @At("HEAD"))
|
||||
private void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, S bipedEntityRenderState, float f, float g, CallbackInfo ci) {
|
||||
this.bipedRenderState = bipedEntityRenderState;
|
||||
}
|
||||
|
||||
@Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true)
|
||||
private void renderArmor(MatrixStack matrices, VertexConsumerProvider vertexConsumers, ItemStack stack, EquipmentSlot armorSlot, int light, A model, CallbackInfo ci) {
|
||||
ArmorRenderer renderer = ArmorRendererRegistryImpl.get(stack.getItem());
|
||||
|
||||
if (renderer != null) {
|
||||
// TODO fix me 1.21.2
|
||||
// renderer.render(matrices, vertexConsumers, stack, entity, armorSlot, light, getContextModel());
|
||||
renderer.render(matrices, vertexConsumers, stack, bipedRenderState, armorSlot, light, (BipedEntityModel<BipedEntityRenderState>) getContextModel());
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,6 @@ public abstract class WorldRendererMixin {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO 24w33a double check
|
||||
@Inject(at = @At(value = "HEAD"), method = "renderSky", cancellable = true)
|
||||
private void renderSky(FrameGraphBuilder frameGraphBuilder, Camera camera, float tickDelta, Fog fog, CallbackInfo info) {
|
||||
if (this.client.world != null) {
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ArmorRenderingTests implements ClientModInitializer {
|
|||
// Renders a biped model with dirt texture, replacing diamond helmet and diamond chest plate rendering
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ArmorRenderer.register((matrices, vertexConsumers, stack, entity, slot, light, model) -> {
|
||||
ArmorRenderer.register((matrices, vertexConsumers, stack, renderState, slot, light, model) -> {
|
||||
if (armorModel == null) {
|
||||
armorModel = new BipedEntityModel<>(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(EntityModelLayers.PLAYER_OUTER_ARMOR));
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class FeatureRendererGenericTests implements ClientModInitializer {
|
|||
|
||||
// Obviously not recommended, just used for testing generics
|
||||
// TODO 1.21.2
|
||||
// registrationHelper.register(new ElytraFeatureRenderer<>(entityRenderer, context.getModelLoader()));
|
||||
// registrationHelper.register(new ElytraFeatureRenderer<>(entityRenderer, context.getModelLoader()));
|
||||
|
||||
if (entityRenderer instanceof BipedEntityRenderer) {
|
||||
// It works, method ref is encouraged
|
||||
|
@ -83,7 +83,7 @@ public class FeatureRendererGenericTests implements ClientModInitializer {
|
|||
|
||||
// Obviously not recommended, just used for testing generics.
|
||||
// TODO 1.21.2
|
||||
// registrationHelper.register(new ElytraFeatureRenderer<>(entityRenderer, context.getModelLoader()));
|
||||
// registrationHelper.register(new ElytraFeatureRenderer<>(entityRenderer, context.getModelLoader()));
|
||||
|
||||
if (entityRenderer instanceof BipedEntityRenderer<?, ?, ?> bipedEntityRenderer) {
|
||||
// It works, method ref is encouraged
|
||||
|
|
|
@ -55,7 +55,7 @@ public class RegistryLoaderMixin {
|
|||
REGISTRIES.set(cir.getReturnValue());
|
||||
}
|
||||
|
||||
// TODO 24w33a - Double Check if replacement above will work
|
||||
// TODO 24w33a - Double Check if replacement above will work - it doesnt
|
||||
/*@WrapOperation(method = "loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Lnet/minecraft/registry/RegistryLoader;load(Lnet/minecraft/registry/RegistryLoader$RegistryLoadable;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;"))
|
||||
private static DynamicRegistryManager.Immutable captureRegistries(@Coerce Object registryLoadable, DynamicRegistryManager baseRegistryManager, List<RegistryLoader.Entry<?>> entries, Operation<DynamicRegistryManager.Immutable> original) {
|
||||
try {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stick"
|
||||
}
|
||||
"minecraft:stick"
|
||||
],
|
||||
"result": {
|
||||
"id": "minecraft:diamond"
|
||||
|
|
Loading…
Reference in a new issue