public static BlockEntity ReadFrom(NbtCompound compound, World world, Block block) { if (compound.TryGet("id", out var tag)) { var id = tag.StringValue; BlockEntity blockEntity = null; switch (id.ToLower()) { case "minecraft:chest": case "chest": blockEntity = new ChestBlockEntity(block, world, ChestTexture); break; default: Log.Warn($"Missing block entity type: {id}"); break; } if (blockEntity != null) { blockEntity.Read(compound); } return(blockEntity); } return(null); }
public static BlockEntity ReadFrom(NbtCompound compound, World world, Block block) { if (compound.TryGet("id", out var tag) || compound.TryGet("ID", out tag)) { var id = tag.StringValue; BlockEntity blockEntity = null; switch (id.ToLower()) { case "minecraft:chest": case "chest": blockEntity = new ChestBlockEntity(block, world, ChestTexture); break; case "minecraft:ender_chest": case "ender_chest": case "enderchest": blockEntity = new EnderChestBlockEntity(block, world, EnderChestTexture); break; case "minecraft:sign": case "sign": blockEntity = new SignBlockEntity(world, block); break; case "minecraft:skull": case "skull": blockEntity = new SkullBlockEntity(world, block, SkullTexture); break; case "minecraft:flowerpot": case "flowerpot": blockEntity = new FlowerPotBlockEntity(world, block); break; case "minecraft:itemframe": case "itemframe": blockEntity = new ItemFrameBlockEntity(world, block); break; case "minecraft:furnace": case "furnace": blockEntity = new FurnaceBlockEntity(world, block); break; default: Log.Debug($"Missing block entity type: {id}"); break; } if (blockEntity != null) { blockEntity.Read(compound); } return(blockEntity); } return(null); }