- 627
- 72
- 178
Всем привет. Делаю крафт через стол кузнеца для всех предметов, содержащихся в моём дата-теге. Столкнулся с проблемой - не вдупляю, как на выходе крафта получить предмет из входного Ingredient (объект улучшения). Идей ноль. Прошу совета: куда копать, что делать? Я конечно могу в assemble вытянуть предмет из 0-го слота, но меня не устраивает несовместимость с отображением в jei, так что хотелось бы услышать ваше мнение.
Java:
{
"type": "amethystsmithing:amethysting",
"base": {
"tag": "amethystsmithing:smithable"
},
"special": false
}
JSON:
{
"replace": false,
"values": [
"minecraft:iron_sword",
"minecraft:netherite_axe",
"minecraft:stone_hoe",
"minecraft:diamond_hoe"
]
}
Java:
public class AmethystingRecipe extends UpgradeRecipe {
public boolean isSpecial;
public AmethystingRecipe(ResourceLocation p_44523_, Ingredient p_44524_, boolean flag) {
super(p_44523_, p_44524_, Ingredient.of(flag ? Items.DIAMOND_BLOCK : Items.DIAMOND), /** result item **/); // проблемная строка, нужно чтобы предмет на выходе был тем же, что и на входе
this.isSpecial = flag;
}
@Override
public ItemStack assemble(Container p_44531_) {
ItemStack result = super.assemble(p_44531_);
if (result.getTag() != null)
result.getTag().putBoolean("$TAG$", true);
return result;
}
public RecipeSerializer<?> getSerializer() {
return AmethystSmithing.SERIALIZER;
}
public static class Serializer extends ForgeRegistryEntry<RecipeSerializer<?>>
implements RecipeSerializer<AmethystingRecipe> {
public AmethystingRecipe fromJson(ResourceLocation p_44562_, JsonObject p_44563_) {
Ingredient ingredient = Ingredient.fromJson(GsonHelper.getAsJsonObject(p_44563_, "base"));
boolean flag = GsonHelper.getAsBoolean(p_44563_, "special");
return new AmethystingRecipe(p_44562_, ingredient, flag);
}
public AmethystingRecipe fromNetwork(ResourceLocation p_44565_, FriendlyByteBuf p_44566_) {
Ingredient ingredient = Ingredient.fromNetwork(p_44566_);
boolean flag = p_44566_.readBoolean();
return new AmethystingRecipe(p_44565_, ingredient, flag);
}
public void toNetwork(FriendlyByteBuf p_44553_, AmethystingRecipe p_44554_) {
((Ingredient) ObfuscationReflectionHelper.getPrivateValue(UpgradeRecipe.class, p_44554_, "f_126375_")).toNetwork(p_44553_);
p_44553_.writeBoolean(p_44554_.isSpecial);
}
}
Последнее редактирование: