Possibility to add NBT data for Infusion recipes output (#215)
This commit is contained in:
parent
13e169c458
commit
3f225c59a1
5 changed files with 38 additions and 25 deletions
24
build.gradle
24
build.gradle
|
@ -43,30 +43,30 @@ dependencies {
|
||||||
|
|
||||||
def useOptional(String dep) {
|
def useOptional(String dep) {
|
||||||
dependencies.modRuntime (dep) {
|
dependencies.modRuntime (dep) {
|
||||||
exclude group: "net.fabricmc.fabric-api"
|
exclude group: 'net.fabricmc.fabric-api'
|
||||||
exclude group: "net.fabricmc"
|
exclude group: 'net.fabricmc'
|
||||||
if (!dep.contains("me.shedaniel")) {
|
if (!dep.contains("me.shedaniel")) {
|
||||||
exclude group: "me.shedaniel.cloth"
|
exclude group: 'me.shedaniel.cloth'
|
||||||
exclude group: "me.shedaniel"
|
exclude group: 'me.shedaniel'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies.modCompileOnly (dep) {
|
dependencies.modCompileOnly (dep) {
|
||||||
exclude group: "net.fabricmc.fabric-api"
|
exclude group: 'net.fabricmc.fabric-api'
|
||||||
exclude group: "net.fabricmc"
|
exclude group: 'net.fabricmc'
|
||||||
if (!dep.contains("me.shedaniel")) {
|
if (!dep.contains("me.shedaniel")) {
|
||||||
exclude group: "me.shedaniel.cloth"
|
exclude group: 'me.shedaniel.cloth'
|
||||||
exclude group: "me.shedaniel"
|
exclude group: 'me.shedaniel'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def useApi(String dep) {
|
def useApi(String dep) {
|
||||||
dependencies.modApi (dep) {
|
dependencies.modApi (dep) {
|
||||||
exclude group: "net.fabricmc.fabric-api"
|
exclude group: 'net.fabricmc.fabric-api'
|
||||||
exclude group: "net.fabricmc"
|
exclude group: 'net.fabricmc'
|
||||||
if (!dep.contains("me.shedaniel")) {
|
if (!dep.contains("me.shedaniel")) {
|
||||||
exclude group: "me.shedaniel.cloth"
|
exclude group: 'me.shedaniel.cloth'
|
||||||
exclude group: "me.shedaniel"
|
exclude group: 'me.shedaniel'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ archives_base_name = better-end
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
patchouli_version = 50-FABRIC
|
patchouli_version = 53-FABRIC
|
||||||
fabric_version = 0.32.9+1.16
|
fabric_version = 0.36.0+1.16
|
||||||
canvas_version = 1.0.+
|
|
||||||
bclib_version = 0.1.44
|
bclib_version = 0.1.44
|
||||||
rei_version = 5.8.10
|
rei_version = 5.12.248
|
||||||
|
canvas_version = 1.0.+
|
|
@ -95,7 +95,7 @@ public abstract class LivingEntityMixin extends Entity {
|
||||||
info.setReturnValue(false);
|
info.setReturnValue(false);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
BetterEnd.LOGGER.warning("Blindness resistance attribute haven't registered.");
|
BetterEnd.LOGGER.warning("Blindness resistance attribute haven't been registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,10 @@ import ru.bclib.util.ColorUtil;
|
||||||
import ru.betterend.registry.EndParticles;
|
import ru.betterend.registry.EndParticles;
|
||||||
|
|
||||||
public class InfusionParticleType extends ParticleType<InfusionParticleType> implements ParticleOptions {
|
public class InfusionParticleType extends ParticleType<InfusionParticleType> implements ParticleOptions {
|
||||||
public static final Codec<InfusionParticleType> CODEC = ItemStack.CODEC.xmap(itemStack -> {
|
public static final Codec<InfusionParticleType> CODEC = ItemStack.CODEC.xmap(
|
||||||
return new InfusionParticleType(EndParticles.INFUSION, itemStack);
|
itemStack -> new InfusionParticleType(EndParticles.INFUSION, itemStack),
|
||||||
}, infusionParticleType -> {
|
infusionParticleType -> infusionParticleType.itemStack);
|
||||||
return infusionParticleType.itemStack;
|
|
||||||
});
|
|
||||||
public static final ParticleOptions.Deserializer<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Deserializer<InfusionParticleType>() {
|
public static final ParticleOptions.Deserializer<InfusionParticleType> PARAMETERS_FACTORY = new ParticleOptions.Deserializer<InfusionParticleType>() {
|
||||||
public InfusionParticleType fromCommand(ParticleType<InfusionParticleType> particleType, StringReader stringReader) throws CommandSyntaxException {
|
public InfusionParticleType fromCommand(ParticleType<InfusionParticleType> particleType, StringReader stringReader) throws CommandSyntaxException {
|
||||||
stringReader.expect(' ');
|
stringReader.expect(' ');
|
||||||
|
@ -35,8 +34,8 @@ public class InfusionParticleType extends ParticleType<InfusionParticleType> imp
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ParticleType<InfusionParticleType> type;
|
private final ParticleType<InfusionParticleType> type;
|
||||||
private ItemStack itemStack;
|
private final ItemStack itemStack;
|
||||||
|
|
||||||
public InfusionParticleType(ParticleType<InfusionParticleType> particleType, ItemStack stack) {
|
public InfusionParticleType(ParticleType<InfusionParticleType> particleType, ItemStack stack) {
|
||||||
super(true, PARAMETERS_FACTORY);
|
super(true, PARAMETERS_FACTORY);
|
||||||
|
|
|
@ -4,11 +4,15 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.util.NbtType;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.nbt.*;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.tags.TagLoader;
|
||||||
import net.minecraft.util.GsonHelper;
|
import net.minecraft.util.GsonHelper;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
@ -17,6 +21,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.storage.loot.GsonAdapterFactory;
|
||||||
import ru.bclib.recipes.BCLRecipeManager;
|
import ru.bclib.recipes.BCLRecipeManager;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.config.Configs;
|
import ru.betterend.config.Configs;
|
||||||
|
@ -209,6 +214,15 @@ public class InfusionRecipe implements Recipe<InfusionRitual>, BetterEndRecipe {
|
||||||
if (recipe.output == null) {
|
if (recipe.output == null) {
|
||||||
throw new IllegalStateException("Output item does not exists!");
|
throw new IllegalStateException("Output item does not exists!");
|
||||||
}
|
}
|
||||||
|
if (result.has("nbt")) {
|
||||||
|
try {
|
||||||
|
String nbtData = GsonHelper.getAsString(result, "nbt");
|
||||||
|
CompoundTag nbt = TagParser.parseTag(nbtData);
|
||||||
|
recipe.output.setTag(nbt);
|
||||||
|
} catch (CommandSyntaxException ex) {
|
||||||
|
BetterEnd.LOGGER.warning("Error parse nbt data for output.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
recipe.group = GsonHelper.getAsString(json, "group", GROUP);
|
recipe.group = GsonHelper.getAsString(json, "group", GROUP);
|
||||||
recipe.time = GsonHelper.getAsInt(json, "time", 1);
|
recipe.time = GsonHelper.getAsInt(json, "time", 1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue