mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 10:59:07 +00:00
fix(client-mod): 修复注册的方块状态不对的问题
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package net.momirealms.craftEngineFabricMod;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.momirealms.craftEngineFabricMod.util.RegisterBlocks;
|
||||
import net.momirealms.craftEngineFabricMod.util.YamlUtils;
|
||||
|
||||
@@ -22,10 +27,17 @@ public class CraftEngineFabricMod implements ModInitializer {
|
||||
} else {
|
||||
blockCount.put(blockName, 0);
|
||||
}
|
||||
RegisterBlocks.register(blockName + "_" + blockCount.get(blockName));
|
||||
RegisterBlocks.register(
|
||||
blockName + "_" + blockCount.get(blockName),
|
||||
Registries.BLOCK.get(keyOfBlock(blockName))
|
||||
);
|
||||
}
|
||||
});
|
||||
mappings.clear();
|
||||
blockCount.clear();
|
||||
}
|
||||
|
||||
private static RegistryKey<Block> keyOfBlock(String name) {
|
||||
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of("minecraft", name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.momirealms.craftEngineFabricMod.util;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
@@ -13,8 +12,8 @@ import net.momirealms.craftEngineFabricMod.CraftEngineFabricMod;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class RegisterBlocks {
|
||||
public static Block register(String name) {
|
||||
return register(name, Block::new, Block.Settings.copy(Blocks.STONE));
|
||||
public static Block register(String name, Block block) {
|
||||
return register(name, Block::new, Block.Settings.copy(block));
|
||||
}
|
||||
|
||||
public static Block register(String name, Function<AbstractBlock.Settings, Block> blockFactory, AbstractBlock.Settings settings) {
|
||||
@@ -24,7 +23,7 @@ public class RegisterBlocks {
|
||||
return Registry.register(Registries.BLOCK, blockKey, block);
|
||||
}
|
||||
|
||||
public static RegistryKey<Block> keyOfBlock(String name) {
|
||||
private static RegistryKey<Block> keyOfBlock(String name) {
|
||||
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(CraftEngineFabricMod.MOD_ID, name));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user