Add occluding block states to block connections file

This commit is contained in:
Nassim Jahnke 2024-05-13 10:46:27 +02:00
parent 0694f4dfa8
commit ca63ea1611
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
3 changed files with 406 additions and 3 deletions

View File

@ -0,0 +1,379 @@
[
"stone",
"granite",
"polished_granite",
"diorite",
"polished_diorite",
"andesite",
"polished_andesite",
"grass_block[snowy=false]",
"dirt",
"coarse_dirt",
"podzol[snowy=false]",
"cobblestone",
"oak_planks",
"spruce_planks",
"birch_planks",
"jungle_planks",
"acacia_planks",
"dark_oak_planks",
"bedrock",
"sand",
"red_sand",
"gravel",
"gold_ore",
"iron_ore",
"coal_ore",
"oak_log[axis=x]",
"oak_log[axis=y]",
"oak_log[axis=z]",
"spruce_log[axis=x]",
"spruce_log[axis=y]",
"spruce_log[axis=z]",
"birch_log[axis=x]",
"birch_log[axis=y]",
"birch_log[axis=z]",
"jungle_log[axis=x]",
"jungle_log[axis=y]",
"jungle_log[axis=z]",
"acacia_log[axis=x]",
"acacia_log[axis=y]",
"acacia_log[axis=z]",
"dark_oak_log[axis=x]",
"dark_oak_log[axis=y]",
"dark_oak_log[axis=z]",
"oak_wood[axis=y]",
"spruce_wood[axis=y]",
"birch_wood[axis=y]",
"jungle_wood[axis=y]",
"acacia_wood[axis=y]",
"dark_oak_wood[axis=y]",
"sponge",
"wet_sponge",
"lapis_ore",
"lapis_block",
"dispenser[facing=north,triggered=true]",
"dispenser[facing=north,triggered=false]",
"dispenser[facing=east,triggered=true]",
"dispenser[facing=east,triggered=false]",
"dispenser[facing=south,triggered=true]",
"dispenser[facing=south,triggered=false]",
"dispenser[facing=west,triggered=true]",
"dispenser[facing=west,triggered=false]",
"dispenser[facing=up,triggered=true]",
"dispenser[facing=up,triggered=false]",
"dispenser[facing=down,triggered=true]",
"dispenser[facing=down,triggered=false]",
"sandstone",
"chiseled_sandstone",
"cut_sandstone",
"note_block[instrument=harp,note=0,powered=false]",
"white_wool",
"orange_wool",
"magenta_wool",
"light_blue_wool",
"yellow_wool",
"lime_wool",
"pink_wool",
"gray_wool",
"light_gray_wool",
"cyan_wool",
"purple_wool",
"blue_wool",
"brown_wool",
"green_wool",
"red_wool",
"black_wool",
"gold_block",
"iron_block",
"bricks",
"bookshelf",
"mossy_cobblestone",
"obsidian",
"spawner",
"diamond_ore",
"diamond_block",
"crafting_table",
"furnace[facing=north,lit=true]",
"furnace[facing=north,lit=false]",
"furnace[facing=south,lit=true]",
"furnace[facing=south,lit=false]",
"furnace[facing=west,lit=true]",
"furnace[facing=west,lit=false]",
"furnace[facing=east,lit=true]",
"furnace[facing=east,lit=false]",
"redstone_ore[lit=true]",
"redstone_ore[lit=false]",
"snow_block",
"clay",
"jukebox[has_record=true]",
"jukebox[has_record=false]",
"netherrack",
"soul_sand",
"carved_pumpkin[facing=north]",
"carved_pumpkin[facing=south]",
"carved_pumpkin[facing=west]",
"carved_pumpkin[facing=east]",
"jack_o_lantern[facing=north]",
"jack_o_lantern[facing=south]",
"jack_o_lantern[facing=west]",
"jack_o_lantern[facing=east]",
"infested_stone",
"infested_cobblestone",
"infested_stone_bricks",
"infested_mossy_stone_bricks",
"infested_cracked_stone_bricks",
"infested_chiseled_stone_bricks",
"stone_bricks",
"mossy_stone_bricks",
"cracked_stone_bricks",
"chiseled_stone_bricks",
"brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"brown_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"brown_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"brown_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"brown_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=false]",
"brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"red_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"red_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"red_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"red_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=false]",
"red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"melon",
"mycelium[snowy=false]",
"nether_bricks",
"end_stone",
"redstone_lamp[lit=true]",
"redstone_lamp[lit=false]",
"emerald_ore",
"emerald_block",
"command_block[conditional=true,facing=north]",
"command_block[conditional=true,facing=east]",
"command_block[conditional=true,facing=south]",
"command_block[conditional=true,facing=west]",
"command_block[conditional=true,facing=up]",
"command_block[conditional=true,facing=down]",
"command_block[conditional=false,facing=north]",
"command_block[conditional=false,facing=east]",
"command_block[conditional=false,facing=south]",
"command_block[conditional=false,facing=west]",
"command_block[conditional=false,facing=up]",
"command_block[conditional=false,facing=down]",
"nether_quartz_ore",
"quartz_block",
"chiseled_quartz_block",
"quartz_pillar[axis=x]",
"quartz_pillar[axis=y]",
"quartz_pillar[axis=z]",
"dropper[facing=north,triggered=true]",
"dropper[facing=north,triggered=false]",
"dropper[facing=east,triggered=true]",
"dropper[facing=east,triggered=false]",
"dropper[facing=south,triggered=true]",
"dropper[facing=south,triggered=false]",
"dropper[facing=west,triggered=true]",
"dropper[facing=west,triggered=false]",
"dropper[facing=up,triggered=true]",
"dropper[facing=up,triggered=false]",
"dropper[facing=down,triggered=true]",
"dropper[facing=down,triggered=false]",
"white_terracotta",
"orange_terracotta",
"magenta_terracotta",
"light_blue_terracotta",
"yellow_terracotta",
"lime_terracotta",
"pink_terracotta",
"gray_terracotta",
"light_gray_terracotta",
"cyan_terracotta",
"purple_terracotta",
"blue_terracotta",
"brown_terracotta",
"green_terracotta",
"red_terracotta",
"black_terracotta",
"slime_block",
"barrier",
"prismarine",
"prismarine_bricks",
"dark_prismarine",
"hay_block[axis=x]",
"hay_block[axis=y]",
"hay_block[axis=z]",
"terracotta",
"coal_block",
"packed_ice",
"red_sandstone",
"chiseled_red_sandstone",
"cut_red_sandstone",
"oak_slab[type=double,waterlogged=false]",
"spruce_slab[type=double,waterlogged=false]",
"birch_slab[type=double,waterlogged=false]",
"jungle_slab[type=double,waterlogged=false]",
"acacia_slab[type=double,waterlogged=false]",
"dark_oak_slab[type=double,waterlogged=false]",
"stone_slab[type=double,waterlogged=false]",
"sandstone_slab[type=double,waterlogged=false]",
"petrified_oak_slab[type=double,waterlogged=false]",
"cobblestone_slab[type=double,waterlogged=false]",
"brick_slab[type=double,waterlogged=false]",
"stone_brick_slab[type=double,waterlogged=false]",
"nether_brick_slab[type=double,waterlogged=false]",
"quartz_slab[type=double,waterlogged=false]",
"red_sandstone_slab[type=double,waterlogged=false]",
"purpur_slab[type=double,waterlogged=false]",
"smooth_stone",
"smooth_sandstone",
"smooth_quartz",
"smooth_red_sandstone",
"purpur_block",
"purpur_pillar[axis=x]",
"purpur_pillar[axis=y]",
"purpur_pillar[axis=z]",
"end_stone_bricks",
"repeating_command_block[conditional=true,facing=north]",
"repeating_command_block[conditional=true,facing=east]",
"repeating_command_block[conditional=true,facing=south]",
"repeating_command_block[conditional=true,facing=west]",
"repeating_command_block[conditional=true,facing=up]",
"repeating_command_block[conditional=true,facing=down]",
"repeating_command_block[conditional=false,facing=north]",
"repeating_command_block[conditional=false,facing=east]",
"repeating_command_block[conditional=false,facing=south]",
"repeating_command_block[conditional=false,facing=west]",
"repeating_command_block[conditional=false,facing=up]",
"repeating_command_block[conditional=false,facing=down]",
"chain_command_block[conditional=true,facing=north]",
"chain_command_block[conditional=true,facing=east]",
"chain_command_block[conditional=true,facing=south]",
"chain_command_block[conditional=true,facing=west]",
"chain_command_block[conditional=true,facing=up]",
"chain_command_block[conditional=true,facing=down]",
"chain_command_block[conditional=false,facing=north]",
"chain_command_block[conditional=false,facing=east]",
"chain_command_block[conditional=false,facing=south]",
"chain_command_block[conditional=false,facing=west]",
"chain_command_block[conditional=false,facing=up]",
"chain_command_block[conditional=false,facing=down]",
"magma_block",
"nether_wart_block",
"red_nether_bricks",
"bone_block[axis=x]",
"bone_block[axis=y]",
"bone_block[axis=z]",
"white_glazed_terracotta[facing=north]",
"white_glazed_terracotta[facing=south]",
"white_glazed_terracotta[facing=west]",
"white_glazed_terracotta[facing=east]",
"orange_glazed_terracotta[facing=north]",
"orange_glazed_terracotta[facing=south]",
"orange_glazed_terracotta[facing=west]",
"orange_glazed_terracotta[facing=east]",
"magenta_glazed_terracotta[facing=north]",
"magenta_glazed_terracotta[facing=south]",
"magenta_glazed_terracotta[facing=west]",
"magenta_glazed_terracotta[facing=east]",
"light_blue_glazed_terracotta[facing=north]",
"light_blue_glazed_terracotta[facing=south]",
"light_blue_glazed_terracotta[facing=west]",
"light_blue_glazed_terracotta[facing=east]",
"yellow_glazed_terracotta[facing=north]",
"yellow_glazed_terracotta[facing=south]",
"yellow_glazed_terracotta[facing=west]",
"yellow_glazed_terracotta[facing=east]",
"lime_glazed_terracotta[facing=north]",
"lime_glazed_terracotta[facing=south]",
"lime_glazed_terracotta[facing=west]",
"lime_glazed_terracotta[facing=east]",
"pink_glazed_terracotta[facing=north]",
"pink_glazed_terracotta[facing=south]",
"pink_glazed_terracotta[facing=west]",
"pink_glazed_terracotta[facing=east]",
"gray_glazed_terracotta[facing=north]",
"gray_glazed_terracotta[facing=south]",
"gray_glazed_terracotta[facing=west]",
"gray_glazed_terracotta[facing=east]",
"light_gray_glazed_terracotta[facing=north]",
"light_gray_glazed_terracotta[facing=south]",
"light_gray_glazed_terracotta[facing=west]",
"light_gray_glazed_terracotta[facing=east]",
"cyan_glazed_terracotta[facing=north]",
"cyan_glazed_terracotta[facing=south]",
"cyan_glazed_terracotta[facing=west]",
"cyan_glazed_terracotta[facing=east]",
"purple_glazed_terracotta[facing=north]",
"purple_glazed_terracotta[facing=south]",
"purple_glazed_terracotta[facing=west]",
"purple_glazed_terracotta[facing=east]",
"blue_glazed_terracotta[facing=north]",
"blue_glazed_terracotta[facing=south]",
"blue_glazed_terracotta[facing=west]",
"blue_glazed_terracotta[facing=east]",
"brown_glazed_terracotta[facing=north]",
"brown_glazed_terracotta[facing=south]",
"brown_glazed_terracotta[facing=west]",
"brown_glazed_terracotta[facing=east]",
"green_glazed_terracotta[facing=north]",
"green_glazed_terracotta[facing=south]",
"green_glazed_terracotta[facing=west]",
"green_glazed_terracotta[facing=east]",
"red_glazed_terracotta[facing=north]",
"red_glazed_terracotta[facing=south]",
"red_glazed_terracotta[facing=west]",
"red_glazed_terracotta[facing=east]",
"black_glazed_terracotta[facing=north]",
"black_glazed_terracotta[facing=south]",
"black_glazed_terracotta[facing=west]",
"black_glazed_terracotta[facing=east]",
"white_concrete",
"orange_concrete",
"magenta_concrete",
"light_blue_concrete",
"yellow_concrete",
"lime_concrete",
"pink_concrete",
"gray_concrete",
"light_gray_concrete",
"cyan_concrete",
"purple_concrete",
"blue_concrete",
"brown_concrete",
"green_concrete",
"red_concrete",
"black_concrete",
"white_concrete_powder",
"orange_concrete_powder",
"magenta_concrete_powder",
"light_blue_concrete_powder",
"yellow_concrete_powder",
"lime_concrete_powder",
"pink_concrete_powder",
"gray_concrete_powder",
"light_gray_concrete_powder",
"cyan_concrete_powder",
"purple_concrete_powder",
"blue_concrete_powder",
"brown_concrete_powder",
"green_concrete_powder",
"red_concrete_powder",
"black_concrete_powder",
"structure_block[mode=save]",
"structure_block[mode=load]",
"structure_block[mode=corner]",
"structure_block[mode=data]",
"glowstone"
]

View File

@ -42,9 +42,12 @@ public final class MappingsLoader {
public static final Logger LOGGER = LoggerFactory.getLogger(MappingsLoader.class.getSimpleName());
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create();
public static @Nullable JsonObject load(final String name) throws IOException {
return load(MappingsOptimizer.MAPPINGS_DIR, name);
return load(name, JsonObject.class);
}
public static <T> @Nullable T load(final String name, final Class<T> outputClass) throws IOException {
return load(MappingsOptimizer.MAPPINGS_DIR, name, outputClass);
}
/**
@ -55,13 +58,17 @@ public final class MappingsLoader {
* @return the mappings file as a JsonObject, or null if it does not exist
*/
public static @Nullable JsonObject load(final Path mappingsDir, final String name) throws IOException {
return load(mappingsDir, name, JsonObject.class);
}
public static <T> @Nullable T load(final Path mappingsDir, final String name, final Class<T> outputClass) throws IOException {
final Path path = mappingsDir.resolve(name);
if (!Files.exists(path)) {
return null;
}
try (final BufferedReader reader = Files.newBufferedReader(path)) {
return GSON.fromJson(reader, JsonObject.class);
return GSON.fromJson(reader, outputClass);
}
}

View File

@ -32,6 +32,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -114,9 +115,25 @@ public final class BlockConnections {
}
}
addOccludingBlockStates(tag, statesMap);
MappingsOptimizer.write(tag, MappingsOptimizer.OUTPUT_DIR.resolve("extra/blockConnections.nbt"));
}
private static void addOccludingBlockStates(final CompoundTag tag, final Object2IntMap<String> statesMap) throws IOException {
final JsonArray states = MappingsLoader.load("extra/occluding-states-1.13.json", JsonArray.class);
final int[] value = new int[states.size()];
int i = 0;
for (final JsonElement stateElement : states) {
final String state = stateElement.getAsString();
final int id = statesMap.getInt(state);
if (id == -1) {
throw new IllegalArgumentException("Invalid occluding state " + state);
}
value[i++] = id;
}
tag.put("occluding-states", new IntArrayTag(value));
}
private static byte connectionTypeToId(final String type) {
final byte id = (byte) CONNECTION_TYPES.indexOf(type);
if (id == -1) {