Defer block registering

This commit is contained in:
SD 2021-01-07 14:56:34 +05:30
parent 1d3a46a7b1
commit 169762c689
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
3 changed files with 15 additions and 6 deletions

View file

@ -31,8 +31,8 @@ dependencies {
include 'com.github.Waterpicker:OpenWorlds:c5a1ced'
modImplementation("io.github.boogiemonster1o1:libcbe:${libcbe_version}")
include("io.github.boogiemonster1o1:libcbe:${libcbe_version}") // Includes LibCBE as a Jar-in-Jar embedded dependency
modImplementation("curse.maven:worldedit:3039223") // For saving schematics
modImplementation("curse.maven:wecui:2995033") // Cos why not
// modImplementation("curse.maven:worldedit:3039223") // For saving schematics
// modImplementation("curse.maven:wecui:2995033") // Cos why not
modCompileOnly("io.github.prospector:modmenu:1.14.6+build.31") {
exclude module: "fabric-api"
}

View file

@ -2,7 +2,7 @@ minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7
loader_version=0.10.8
fabric_version=0.27.1+1.16
fabric_version=0.29.3+1.16
libcbe_version = 1.1.0

View file

@ -1,5 +1,9 @@
package org.dimdev.dimdoors.block;
import java.util.Map;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
@ -13,6 +17,7 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
public final class ModBlocks {
private static final Map<String, Block> BLOCKS = Maps.newLinkedHashMap();
public static final Block GOLD_DOOR = register("dimdoors:gold_door", new DoorBlock(FabricBlockSettings.of(Material.METAL, MaterialColor.GOLD).nonOpaque()));
public static final Block QUARTZ_DOOR = register("dimdoors:quartz_door", new DoorBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.QUARTZ).nonOpaque()));
public static final Block OAK_DIMENSIONAL_DOOR = register("dimdoors:oak_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).nonOpaque().lightLevel(state -> ((DimensionalDoorBlock) state.getBlock()).hasBlockEntity(state) ? 10 : 0)));
@ -64,10 +69,11 @@ public final class ModBlocks {
public static final Block MARKING_PLATE = register("dimdoors:marking_plate", new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).nonOpaque()));
private static Block register(String string, Block block) {
return Registry.register(Registry.BLOCK, string, block);
BLOCKS.put(string, block);
return block;
}
public static Block registerAncientFabric(String id, DyeColor color) {
private static Block registerAncientFabric(String id, DyeColor color) {
return register(id, new Block(FabricBlockSettings.of(Material.STONE, color).strength(-1.0F, 3600000.0F).dropsNothing()));
}
@ -76,7 +82,10 @@ public final class ModBlocks {
}
public static void init() {
// just loads the class
BLOCKS.forEach((str, block) -> {
Registry.register(Registry.BLOCK, str, block);
});
BLOCKS.clear();
}
@Environment(EnvType.CLIENT)