Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Feb 29, 2024
1 parent 322417c commit e4b2a8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import net.fabricmc.fabric.impl.recipe.ingredient.builtin.AllIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.AnyIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.ComponentIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.ComponentsIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.DifferenceIngredient;

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ public static Ingredient components(Ingredient base, ComponentChanges components
Objects.requireNonNull(base, "Base ingredient cannot be null");
Objects.requireNonNull(components, "Component changes cannot be null");

return new ComponentIngredient(base, components).toVanilla();
return new ComponentsIngredient(base, components).toVanilla();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredientSerializer;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.AllIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.AnyIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.ComponentIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.ComponentsIngredient;
import net.fabricmc.fabric.impl.recipe.ingredient.builtin.DifferenceIngredient;

/**
Expand All @@ -32,6 +32,6 @@ public void onInitialize() {
CustomIngredientSerializer.register(AllIngredient.SERIALIZER);
CustomIngredientSerializer.register(AnyIngredient.SERIALIZER);
CustomIngredientSerializer.register(DifferenceIngredient.SERIALIZER);
CustomIngredientSerializer.register(ComponentIngredient.SERIALIZER);
CustomIngredientSerializer.register(ComponentsIngredient.SERIALIZER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredient;
import net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredientSerializer;

public class ComponentIngredient implements CustomIngredient {
public static final CustomIngredientSerializer<ComponentIngredient> SERIALIZER = new Serializer();
public class ComponentsIngredient implements CustomIngredient {
public static final CustomIngredientSerializer<ComponentsIngredient> SERIALIZER = new Serializer();

private final Ingredient base;
private final ComponentChanges components;

public ComponentIngredient(Ingredient base, ComponentChanges components) {
public ComponentsIngredient(Ingredient base, ComponentChanges components) {
if (components.isEmpty()) {
throw new IllegalArgumentException("ComponentIngredient must have at least one defined component");
}
Expand Down Expand Up @@ -114,22 +114,22 @@ private ComponentChanges getComponents() {
return components;
}

private static class Serializer implements CustomIngredientSerializer<ComponentIngredient> {
private static final Identifier ID = new Identifier("fabric", "component");
private static final Codec<ComponentIngredient> ALLOW_EMPTY_CODEC = createCodec(Ingredient.ALLOW_EMPTY_CODEC);
private static final Codec<ComponentIngredient> DISALLOW_EMPTY_CODEC = createCodec(Ingredient.DISALLOW_EMPTY_CODEC);
private static final PacketCodec<RegistryByteBuf, ComponentIngredient> PACKET_CODEC = PacketCodec.tuple(
Ingredient.PACKET_CODEC, ComponentIngredient::getBase,
ComponentChanges.PACKET_CODEC, ComponentIngredient::getComponents,
ComponentIngredient::new
private static class Serializer implements CustomIngredientSerializer<ComponentsIngredient> {
private static final Identifier ID = new Identifier("fabric", "components");
private static final Codec<ComponentsIngredient> ALLOW_EMPTY_CODEC = createCodec(Ingredient.ALLOW_EMPTY_CODEC);
private static final Codec<ComponentsIngredient> DISALLOW_EMPTY_CODEC = createCodec(Ingredient.DISALLOW_EMPTY_CODEC);
private static final PacketCodec<RegistryByteBuf, ComponentsIngredient> PACKET_CODEC = PacketCodec.tuple(
Ingredient.PACKET_CODEC, ComponentsIngredient::getBase,
ComponentChanges.PACKET_CODEC, ComponentsIngredient::getComponents,
ComponentsIngredient::new
);

private static Codec<ComponentIngredient> createCodec(Codec<Ingredient> ingredientCodec) {
private static Codec<ComponentsIngredient> createCodec(Codec<Ingredient> ingredientCodec) {
return RecordCodecBuilder.create(instance ->
instance.group(
ingredientCodec.fieldOf("base").forGetter(ComponentIngredient::getBase),
ComponentChanges.CODEC.fieldOf("components").forGetter(ComponentIngredient::getComponents)
).apply(instance, ComponentIngredient::new)
ingredientCodec.fieldOf("base").forGetter(ComponentsIngredient::getBase),
ComponentChanges.CODEC.fieldOf("components").forGetter(ComponentsIngredient::getComponents)
).apply(instance, ComponentsIngredient::new)
);
}

Expand All @@ -139,12 +139,12 @@ public Identifier getIdentifier() {
}

@Override
public Codec<ComponentIngredient> getCodec(boolean allowEmpty) {
public Codec<ComponentsIngredient> getCodec(boolean allowEmpty) {
return allowEmpty ? ALLOW_EMPTY_CODEC : DISALLOW_EMPTY_CODEC;
}

@Override
public PacketCodec<RegistryByteBuf, ComponentIngredient> getPacketCodec() {
public PacketCodec<RegistryByteBuf, ComponentsIngredient> getPacketCodec() {
return PACKET_CODEC;
}
}
Expand Down

0 comments on commit e4b2a8d

Please sign in to comment.