Skip to content

Commit

Permalink
Remove block loottable data
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 18, 2024
1 parent 338b1dc commit 6a33ab1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26,243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@
import com.google.gson.JsonObject;
import com.soulfiremc.generator.mixin.BlockAccessor;
import com.soulfiremc.generator.util.BlockSettingsAccessor;
import com.soulfiremc.generator.util.GsonInstance;
import lombok.SneakyThrows;
import net.minecraft.Util;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;

import java.nio.charset.StandardCharsets;
import java.util.Objects;

public class BlocksDataGenerator implements IDataGenerator {
@SneakyThrows
public static JsonObject generateBlock(Block block) {
Expand Down Expand Up @@ -60,23 +56,6 @@ public static JsonObject generateBlock(Block block) {
blockDesc.addProperty("fluidType",
BuiltInRegistries.FLUID.getKey(defaultState.getFluidState().getType()).toString());

JsonArray poolsArray;
var lootTable = block.getLootTable();
if (lootTable.isEmpty()) {
poolsArray = new JsonArray();
} else {
var lootTableFilePath = "/data/minecraft/loot_table/%s.json".formatted(lootTable.get().location().getPath());
try (var in = Objects.requireNonNull(BlocksDataGenerator.class.getResourceAsStream(lootTableFilePath))) {
var data = new String(in.readAllBytes(), StandardCharsets.UTF_8);
var dataJsonObject = GsonInstance.GSON.fromJson(data, JsonObject.class);

poolsArray = dataJsonObject.getAsJsonArray("pools");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
blockDesc.add("lootTableData", poolsArray);

if (defaultState.hasOffsetFunction()) {
var offsetData = new JsonObject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public String getDataName() {
@SneakyThrows
@Override
public String generateDataJson() {
var base = ResourceHelper.getResourceAsString("/templates/MapColor.java");
var registryField = MapColor.class.getDeclaredField("MATERIAL_COLORS");
registryField.setAccessible(true);
var registry = (MapColor[]) registryField.get(null);
Expand All @@ -47,6 +46,7 @@ public String generateDataJson() {
colorArray[i] = "new MapColor(%d, %s)".formatted(i, colField.get(registry[i]));
}

var base = ResourceHelper.getResourceAsString("/templates/MapColor.java");
return base.replace(
GeneratorConstants.VALUES_REPLACE,
"public static final MapColor[] COLORS = new MapColor[] {\n %s\n };".formatted(String.join(",\n ", colorArray)));
Expand Down
Loading

0 comments on commit 6a33ab1

Please sign in to comment.