public void Init() { this.Set(new BlockAir()); this.Set(new BlockStone()); this.Set(new BlockGrass()); this.Set(new BlockDirt()); this.Set(new Block(4, "Cobblestone") { Hardness = 2f, Resistance = 30f, ToolType = ItemToolType.PICKAXE }); this.Set(new BlockPlanks()); this.Set(new BlockSapling()); this.Set(new BlockEmptyDrops(7, "Bedrock") { Resistance = 18000000f }); this.Set(new BlockDynamicLiquid(8, "FlowingWater") { Resistance = 500f, LightOpacity = 3 }); this.Set(new BlockStaticLiquid(9, "Water") { Resistance = 500f, LightOpacity = 3 }); this.Set(new BlockDynamicLiquid(10, "FlowingLava") { Resistance = 500f, LightLevel = 15 }); this.Set(new BlockStaticLiquid(11, "Lava") { Resistance = 500f, LightLevel = 15 }); this.Set(new BlockSand()); this.Set(new BlockGravel()); this.Set(new BlockGoldOre()); this.Set(new BlockIronOre()); this.Set(new BlockCoalOre()); this.Set(new BlockLog()); this.Set(new BlockLeave(18, "Leaves")); this.Set(new BlockSponge()); this.Set(new BlockGlass(20, "Glass")); this.Set(new BlockLapisOre()); this.Set(new BlockSolid(22, "LapisBlock") { Hardness = 3f, Resistance = 15f, ToolType = ItemToolType.PICKAXE, ToolTier = ItemToolTier.STONE }); this.Set(new BlockDispenser()); this.Set(new BlockSandstone()); FieldInfo[] fields = new BlockIDs().GetType().GetFields(); for (int i = 25; i < fields.Length; ++i) { FieldInfo field = fields[i]; this.Set(new Block((int)field.GetValue(null), field.Name)); } this.Set(new BlockChest()); }
BlockIDs GetBlockIDs() { var ids = new BlockIDs(); var registry = World.GetOrCreateSystem <BlockRegistrySystem>(); ids.dirt = registry.GetBlockID("Dirt"); ids.sand = registry.GetBlockID("Sand"); ids.grass = registry.GetBlockID("Grass"); ids.stone = registry.GetBlockID("Stone"); return(ids); }
private static bool isOptimisableBlock(BlockIDs block) { if (optimisableBlockCache.ContainsKey((int)block)) { return(optimisableBlockCache[(int)block]); } bool result = block.ToString().EndsWith("Cube", StringComparison.InvariantCultureIgnoreCase); optimisableBlockCache[(int)block] = result; return(result); }
internal ProcessedVoxelObjectNotation Process() { BlockIDs block = ConversionUtility.BlockIDsToEnum(name.Split('\t')[0]); return(new ProcessedVoxelObjectNotation { block = block, blueprint = block == BlockIDs.Invalid, color = ColorSpaceUtility.QuantizeToBlockColor(color), metadata = name, position = ConversionUtility.FloatArrayToFloat3(position), rotation = ConversionUtility.FloatArrayToFloat3(rotation), scale = ConversionUtility.FloatArrayToFloat3(scale), }); }
public static Tuple <int, int> GetItemIdFromString(string name) { string[] data = name.Replace("minecraft:", "").Replace(" ", "_").ToUpper().Split(':'); int id = 0; int meta = 0; if (data.Length == 1) { int.TryParse(data[0], out id); } if (data.Length == 2) { int.TryParse(data[0], out id); int.TryParse(data[1], out meta); } ItemIDs ids = new ItemIDs(); FieldInfo info = ids.GetType().GetField(data[0]); if (info != null) { id = (int)info.GetValue(ids); } else { BlockIDs ids2 = new BlockIDs(); FieldInfo info2 = ids2.GetType().GetField(data[0]); if (info2 != null) { id = (int)info2.GetValue(ids2); if (id > 255) { id = -id + 255; } } } return(new Tuple <int, int>(id, meta)); }
static ChunkBlockType SelectBlock(int height, int maxHeight, ref BlockIDs ids) { ChunkBlockType block = default; int sandHeight = 4; int dirtHeight = 7; int grassHeight = 10; int stonHeight = int.MaxValue; // Sand if (height <= sandHeight) { block = ids.sand; } // Dirt else if (height <= dirtHeight) { block = ids.dirt; } // Grass else if (height <= grassHeight) { if (height == maxHeight) { block = ids.grass; } else { block = ids.dirt; } } // Stone else if (height < stonHeight) { block = ids.stone; } return(block); }
public static Item Get(string name) { string[] data = name.Replace("minecraft:", "").Replace(" ", "_").ToUpper().Split(':'); int id = 0; int damage = 0; if (data.Length > 0) { int.TryParse(data[0], out id); } if (data.Length > 1) { int.TryParse(data[1], out damage); } ItemIDs factory = new ItemIDs(); FieldInfo info = factory.GetType().GetField(data[0]); if (info != null) { id = (int)info.GetValue(factory); } else { BlockIDs factory2 = new BlockIDs(); FieldInfo info2 = factory2.GetType().GetField(data[0]); if (info2 != null) { id = (int)info2.GetValue(factory2); if (id > 255) { id = -id + 255; } } } return(Item.Get(id, damage)); }
public IChunk this[BlockIDs blockId, ChunkIDs chunkId] { get => GetChunk <IChunk>(blockId, chunkId);