You forgot some stuff.

This commit is contained in:
Waterpicker 2021-10-11 06:42:58 -05:00
parent f43263c751
commit d12c069ae6
5 changed files with 26 additions and 17 deletions

View file

@ -62,6 +62,7 @@ import com.google.gson.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.util.ResourceUtil;
import org.dimdev.dimdoors.world.decay.DecayPattern;
import org.dimdev.dimdoors.world.decay.DecayPredicate;
import org.dimdev.dimdoors.world.decay.DecayProcessor;
@ -75,6 +76,7 @@ import net.minecraft.data.DataCache;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.loot.LootManager;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import java.io.IOException;
@ -186,8 +188,8 @@ public class LimboDecayProvider implements DataProvider {
public void run(BiConsumer<Identifier, JsonObject> consumer) {
JsonObject object = new JsonObject();
object.add("predicate", predicate.toJson(new JsonObject()));
object.add("processor", processor.toJson(new JsonObject()));
object.add("predicate", ResourceUtil.NBT_TO_JSON.apply(predicate.toNbt(new NbtCompound())));
object.add("processor", ResourceUtil.NBT_TO_JSON.apply(processor.toNbt(new NbtCompound())));
consumer.accept(id, object);
}

View file

@ -29,6 +29,8 @@ public class ResourceUtil {
public static final ComposableFunction<JsonElement, NbtElement> JSON_TO_NBT = json -> JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json);
public static final ComposableFunction<NbtElement, JsonElement> NBT_TO_JSON = json -> NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, json);
public static final ComposableFunction<InputStream, JsonElement> JSON_READER = inputStream -> GSON.fromJson(new InputStreamReader(inputStream), JsonElement.class);
public static final ComposableFunction<InputStream, NbtElement> NBT_READER = JSON_READER.andThenComposable(JSON_TO_NBT);
public static final ComposableFunction<InputStream, NbtCompound> COMPRESSED_NBT_READER = inputStream -> {

View file

@ -6,6 +6,8 @@ import org.dimdev.dimdoors.world.decay.DecayPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
@ -23,16 +25,16 @@ public class SimpleDecayPredicate implements DecayPredicate {
}
@Override
public DecayPredicate fromJson(JsonObject json) {
block = Registry.BLOCK.get(Identifier.tryParse(json.get("block").getAsString()));
public DecayPredicate fromNbt(NbtCompound nbt) {
block = Registry.BLOCK.get(Identifier.tryParse(nbt.getString("block")));
return this;
}
@Override
public JsonObject toJson(JsonObject json) {
DecayPredicate.super.toJson(json);
json.addProperty("block", Registry.BLOCK.getId(block).toString());
return json;
public NbtCompound toNbt(NbtCompound nbt) {
DecayPredicate.super.toNbt(nbt);
nbt.putString("block", Registry.BLOCK.getId(block).toString());
return nbt;
}
@Override

View file

@ -6,6 +6,8 @@ import com.google.gson.JsonObject;
import org.dimdev.dimdoors.world.decay.DecayProcessor;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -19,7 +21,7 @@ public class SelfDecayProcessor implements DecayProcessor {
}
@Override
public DecayProcessor fromJson(JsonObject json) {
public DecayProcessor fromNbt(NbtCompound nbt) {
return this;
}

View file

@ -6,6 +6,7 @@ import org.dimdev.dimdoors.world.decay.DecayProcessor;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
@ -26,18 +27,18 @@ public class SimpleDecayProcesor implements DecayProcessor {
}
@Override
public DecayProcessor fromJson(JsonObject json) {
block = Registry.BLOCK.get(Identifier.tryParse(json.get("block").getAsString()));
entropy = json.get("entropy").getAsInt();
public DecayProcessor fromNbt(NbtCompound json) {
block = Registry.BLOCK.get(Identifier.tryParse(json.getString("block")));
entropy = json.getInt("entropy");
return this;
}
@Override
public JsonObject toJson(JsonObject json) {
DecayProcessor.super.toJson(json);
json.addProperty("block", Registry.BLOCK.getId(block).toString());
json.addProperty("entropy", entropy);
return json;
public NbtCompound toNbt(NbtCompound nbt) {
DecayProcessor.super.toNbt(nbt);
nbt.putString("block", Registry.BLOCK.getId(block).toString());
nbt.putInt("entropy", entropy);
return nbt;
}
@Override