public static void UpdateSurvInv() { for (int i = 0; i < 27; i++) { int bID = Player.PStatus.SurvivalInv[i].BlockID; int cID = Player.PStatus.SurvivalInv[i].Count; if (bID != 0) { Player.PStatus.SurvInventoryGOs[i].GetComponent <Image>().sprite = Sprite.Create( BlockRegistry.GetBlockFromID(bID).GetIcon(), new Rect(0, 0, 50, 50), new Vector2(0.5f, 0.5f) ); if (cID == 1) { Player.PStatus.SurvInventoryGOs[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } else { Player.PStatus.SurvInventoryGOs[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); Player.PStatus.SurvInventoryGOs[i].GetComponentInChildren <Text>().text = cID.ToString(); } } else { Player.PStatus.SurvInventoryGOs[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; Player.PStatus.SurvInventoryGOs[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } } }
public static void UpdateArm() { string name = "Arm"; int bID = Player.PStatus.ToolBox9[Player.PStatus.CurrentItem].BlockID; if (bID == BlockRegistry.GID("Pickaxe")) { name = "Pickaxe"; } else if (bID == BlockRegistry.GID("Sword")) { name = "Sword"; } else if (bID == BlockRegistry.GID("Axe")) { name = "Axe"; } else if (bID == BlockRegistry.GID("Shovel")) { name = "Shovel"; } Player.PStatus.Hands["Arm"].SetActive(false); Player.PStatus.Hands["Pickaxe"].SetActive(false); Player.PStatus.Hands["Sword"].SetActive(false); Player.PStatus.Hands["Axe"].SetActive(false); Player.PStatus.Hands["Shovel"].SetActive(false); Player.PStatus.Hands[name].SetActive(true); }
public WorldServer() : base("world", "world", "0") { foreach (var block in BlockRegistry.AllBlocks()) { _worldLut.Put(block.UnlocalizedName); } }
public static void UpdateCraftingTable() { for (int i = 0; i < 10; i++) { int bID = GameManager._Instance.CraftTableData.B[i].BlockID; int cID = GameManager._Instance.CraftTableData.B[i].Count; if (bID != 0) { GameManager._Instance.CraftTableData.P[i].GetComponent <Image>().sprite = Sprite.Create( BlockRegistry.GetBlockFromID(bID).GetIcon(), new Rect(0, 0, 50, 50), new Vector2(0.5f, 0.5f) ); if (cID == 1) { GameManager._Instance.CraftTableData.P[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } else { GameManager._Instance.CraftTableData.P[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); GameManager._Instance.CraftTableData.P[i].GetComponentInChildren <Text>().text = cID.ToString(); } } else { GameManager._Instance.CraftTableData.P[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; GameManager._Instance.CraftTableData.P[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } } }
public List <AxisAlignedBb> GetBlockCollisionBoxes(AxisAlignedBb box) { List <AxisAlignedBb> blocks = new List <AxisAlignedBb>(); AxisAlignedBb bb = box.Union(box); var air = BlockRegistry.GetBlock <BlockAir>(); for (int x = (int)bb.Min.X, maxX = (int)bb.Max.X; x < maxX; x++) { for (int y = (int)bb.Min.Y, maxY = (int)bb.Max.Y; y < maxY; y++) { for (int z = (int)bb.Min.Z, maxZ = (int)bb.Max.Z; z < maxZ; z++) { BlockPos pos = new BlockPos(x, y, z); BlockState state = SharpCraft.Instance.World.GetBlockState(pos); if (state.Block == air || state.Block.Material.CanWalkThrough) { continue; } blocks.Add(state.Block.BoundingBox.Offset(pos.ToVec())); } } } return(blocks); }
private void Init() { //TODO - just a test - WORKS! //_installedMods.Add(new TestMod()); GlSetup(); _itemRegistry = new ItemRegistry(); _blockRegistry = new BlockRegistry(); _recipeRegistry = new RecipeRegistry(); LoadMods(); GameRegistry(); WorldRenderer = new WorldRenderer(); EntityRenderer = new EntityRenderer(); GuiRenderer = new GuiRenderer(); FontRenderer = new FontRenderer(); SettingsManager.Load(); //load settings Camera.SetTargetFov(SettingsManager.GetFloat("fov")); _sensitivity = SettingsManager.GetFloat("sensitivity"); WorldRenderer.RenderDistance = SettingsManager.GetInt("renderdistance"); OpenGuiScreen(new GuiScreenMainMenu()); }
public void OnClick(MouseButton btn) { MouseOverObject moo = SharpCraft.Instance.MouseOverObject; if (moo.hit == HitType.Block) { if (btn == MouseButton.Right) { BlockState state = World.GetBlockState(moo.blockPos); if (state.Block.CanBeInteractedWith) { if (state.Block == BlockRegistry.GetBlock <BlockCraftingTable>()) { SharpCraft.Instance.OpenGuiScreen(new GuiScreenCrafting()); } } else { PlaceBlock(); } } else if (btn == MouseButton.Left) { //BreakBlock(); TODO - UVMin breaking EDIT: whhhat? :DDD } } }
public void FillChunk(Chunk chunk, Vector2Int chunkPos) { var dirtBlockType = BlockRegistry.GetTypeByName("Dirt"); var grassBlockType = BlockRegistry.GetTypeByName("Grass"); for (int z = 0; z < Chunk.CHUNK_SIZE; ++z) { for (int x = 0; x < Chunk.CHUNK_SIZE; ++x) { int worldX = (int)(chunkPos.x * Chunk.CHUNK_SIZE + x); int worldZ = (int)(chunkPos.y * Chunk.CHUNK_SIZE + z); int height = HeightFunction(worldX, worldZ); //set top to be grass, the rest is dirt chunk.SetBlockType(x, height - 1, z, grassBlockType); for (int y = height - 2; y >= 0; y--) { chunk.SetBlockType(x, y, z, dirtBlockType); } } } }
private void RegisterItemsAndBlocks() { blockRegistry.Put(new BlockAir()); blockRegistry.Put(new BlockStone()); blockRegistry.Put(new BlockGrass()); blockRegistry.Put(new BlockDirt()); blockRegistry.Put(new BlockCobbleStone()); blockRegistry.Put(new BlockPlanks()); blockRegistry.Put(new BlockBedrock()); blockRegistry.Put(new BlockLog()); blockRegistry.Put(new BlockLeaves()); blockRegistry.Put(new BlockGlass()); blockRegistry.Put(new BlockCraftingTable()); blockRegistry.Put(new BlockFurnace()); blockRegistry.Put(new BlockSlab()); blockRegistry.Put(new BlockRare()); blockRegistry.Put(new BlockLadder()); blockRegistry.Put(new BlockTallGrass()); //POST - MOD Blocks and Items foreach (ModMain mod in installedMods) { mod.OnItemsAndBlocksRegistry(new RegistryEventArgs(blockRegistry, itemRegistry)); } foreach (var block in BlockRegistry.AllBlocks()) { itemRegistry.Put(new ItemBlock(block)); } JsonModelLoader loader = new JsonModelLoader(Block.DefaultShader); blockRegistry.RegisterBlocksPost(loader); itemRegistry.RegisterItemsPost(loader); }
public static MeshData BuildChunk(Chunk chunk) { var meshData = new MeshData(); for (int x = 0; x < Chunk.Size; x++) { for (int y = 0; y < Chunk.Size; y++) { for (int z = 0; z < Chunk.Size; z++) { var offsetPosition = new Vector3(x, y, z) + (chunk.Position * Chunk.Size); if (chunk[x, y, z].Definition.ShouldRender()) { foreach (Direction direction in Enum.GetValues(typeof(Direction))) { var adjacentBlock = chunk.World.GetAdjacentBlock(offsetPosition, direction); if (adjacentBlock.Definition == BlockRegistry.Get("air") || !adjacentBlock.Definition.ShouldRender() /* || * adjacentBlock.Definition.HasCustomModel || adjacentBlock.Definition.Translucent */&& adjacentBlock.Definition.GetRegistryName() != chunk[x, y, z].Definition.GetRegistryName()) { meshData.AddQuad(new Vector3(x, y, z), direction, Rectangle.Empty);//chunk[x, y, z].Definition.GetTexture(direction).UV); } } } } } } chunk.Dirty = false; return(meshData); }
public void SetHands() { string name = "Arm"; int bID = ToolBox9[CurrentItem].BlockID; if (bID == BlockRegistry.GID("Pickaxe")) { name = "Pickaxe"; } else if (bID == BlockRegistry.GID("Sword")) { name = "Sword"; } else if (bID == BlockRegistry.GID("Axe")) { name = "Axe"; } else if (bID == BlockRegistry.GID("Shovel")) { name = "Shovel"; } foreach (GameObject o in GameObject.FindGameObjectsWithTag("Arm")) { Hands.Add(o.name, o); if (o.name != name) { o.SetActive(false); } } }
void OnCreateButton() { Close(); BlockRegistry.LoadBlockType(new Grass()); BlockRegistry.LoadBlockType(new Dirt()); BlockRegistry.LoadBlockType(new Cobblestone()); BlockRegistry.LoadBlockType(new MossyCobblestone()); BlockRegistry.LoadBlockType(new Stone()); GameObject ob = new GameObject("World-" + worldName, typeof(World)); ob.transform.position = Vector3.zero; ob.transform.rotation = Quaternion.identity; World world = ob.GetComponent <World>(); world.Seed = seed.GetHashCode(); switch (type) { case VolumeType.MarchingCubes: world.Mesher = new MCMesher(); break; case VolumeType.Block: default: world.Mesher = new BlockMesher(); break; } world.EditMode = true; world.WorldGenerator = new GroundGenerator(); world.GenerateWorld(); // Load the world into the plugin API ModEngineEditor.LoadedWorld = ob; }
private void HandleBuildModeLogic() { if (Input.GetKeyDown("mouse 0")) { PlaceBlock(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { selectedBlock = BlockRegistry.GetTypeByName("Dirt"); } if (Input.GetKeyDown(KeyCode.Alpha2)) { selectedBlock = BlockRegistry.GetTypeByName("Grass"); } if (Input.GetKeyDown(KeyCode.Alpha3)) { selectedBlock = BlockRegistry.GetTypeByName("Stone"); } if (Input.GetKeyDown(KeyCode.Alpha4)) { selectedBlock = BlockRegistry.GetTypeByName("Sand"); } if (Input.GetKeyDown(KeyCode.Alpha5)) { selectedBlock = BlockRegistry.GetTypeByName("Brick"); } }
public void PickBlock() { MouseOverObject moo = SharpCraft.Instance.MouseOverObject; if (moo.hit == HitType.Block) { var clickedState = World.GetBlockState(moo.blockPos); if (clickedState.Block != BlockRegistry.GetBlock <BlockAir>()) { for (int i = 0; i < Hotbar.Length; i++) { ItemStack stack = Hotbar[i]; if (stack?.Item is ItemBlock ib && ib.Block == clickedState.Block && stack.Meta == clickedState.Block.GetMetaFromState(clickedState)) { SetSelectedSlot(i); return; } if (stack?.IsEmpty == true) { ItemBlock itemBlock = new ItemBlock(clickedState.Block); ItemStack itemStack = new ItemStack(itemBlock, 1, clickedState.Block.GetMetaFromState(clickedState)); SetItemStackInHotbar(i, itemStack); SetSelectedSlot(i); return; } } SetItemStackInSelectedSlot(new ItemStack(new ItemBlock(clickedState.Block), 1, clickedState.Block.GetMetaFromState(clickedState))); } } }
public void AddBlock(Type block, int x, int y, int z) { var blk = BlockRegistry.GetBlock(block); var fullname = blk.NSpace + ":" + blk.ID; AddBlock(fullname, x, y, z); }
public void BreakBlock() { MouseOverObject moo = SharpCraft.Instance.MouseOverObject; if (moo.hit != HitType.Block) { return; } BlockState state = World.GetBlockState(moo.blockPos); if (JsonModelLoader.GetModelForBlock(state.Block.UnlocalizedName) != null) { SharpCraft.Instance.ParticleRenderer.SpawnDestroyParticles(moo.blockPos, state); } World.SetBlockState(moo.blockPos, BlockRegistry.GetBlock <BlockAir>().GetState()); Vector3 motion = new Vector3(MathUtil.NextFloat(-0.15f, 0.15f), 0.3f, MathUtil.NextFloat(-0.15f, 0.15f)); EntityItem entityDrop = new EntityItem(World, moo.blockPos.ToVec() + Vector3.One * 0.5f, motion, new ItemStack(new ItemBlock(state.Block), 1, state.Block.GetMetaFromState(state))); World.AddEntity(entityDrop); SharpCraft.Instance.GetMouseOverObject(); }
//TODO - clientside only public WorldClient(string saveName, string levelName, string seed) : base(saveName, levelName, seed) { foreach (var block in BlockRegistry.AllBlocks()) { _worldLut.Put(block.UnlocalizedName); } }
public bool ConnectToServer(string ip, int port) { var b = ServerHandler.Connect(ip, port); if (b) { ParticleRenderer = new ParticleRenderer(); SkyboxRenderer = new SkyboxRenderer(); BlockPos playerPos = new BlockPos(0, 100, 0);//MathUtil.NextFloat(-100, 100)); World = new WorldClientServer(); Player = new EntityPlayerSp(World, playerPos.ToVec()); World.AddEntity(Player); Player.SetItemStackInInventory(0, new ItemStack(ItemRegistry.GetItem(BlockRegistry.GetBlock <BlockCraftingTable>()))); ResetMouse(); MouseState state = Mouse.GetState(); _mouseLast = new Point(state.X, state.Y); } return(b); }
public static void UpdateToolbar() // drop or sth { UpdateArm(); for (int i = 0; i < 9; i++) { int bID = Player.PStatus.ToolBox9[i].BlockID; int cID = Player.PStatus.ToolBox9[i].Count; if (bID != 0) { Sprite tmp = Sprite.Create( BlockRegistry.GetBlockFromID(bID).GetIcon(), new Rect(0, 0, 50, 50), new Vector2(0.5f, 0.5f) ); Player.PStatus.ToolbarItems[i].GetComponent <Image>().sprite = tmp; Player.PStatus.CreativeToolbarItems[i].GetComponent <Image>().sprite = tmp; Player.PStatus.SurvivalToolbarItems[i].GetComponent <Image>().sprite = tmp; Player.PStatus.CraftingToolbarItems[i].GetComponent <Image>().sprite = tmp; if (cID == 1) { Player.PStatus.ToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.CreativeToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.SurvivalToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.CraftingToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } else { Player.PStatus.ToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); Player.PStatus.ToolbarItems[i].GetComponentInChildren <Text>().text = cID.ToString(); Player.PStatus.CreativeToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); Player.PStatus.CreativeToolbarItems[i].GetComponentInChildren <Text>().text = cID.ToString(); Player.PStatus.SurvivalToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); Player.PStatus.SurvivalToolbarItems[i].GetComponentInChildren <Text>().text = cID.ToString(); Player.PStatus.CraftingToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0.196f, 0.196f, 0.196f, 1f); Player.PStatus.CraftingToolbarItems[i].GetComponentInChildren <Text>().text = cID.ToString(); } } else { Player.PStatus.ToolbarItems[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; Player.PStatus.ToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.CreativeToolbarItems[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; Player.PStatus.CreativeToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.SurvivalToolbarItems[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; Player.PStatus.SurvivalToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); Player.PStatus.CraftingToolbarItems[i].GetComponent <Image>().sprite = GameManager._Instance.Toolbar_Empty; Player.PStatus.CraftingToolbarItems[i].GetComponentInChildren <Text>().color = new Color(0, 0, 0, 0); } } }
public BlockWritingContext(IServiceLocator services, IObjectBlockWriter writer, BlockRegistry registry, object subject) { _services = services; _writer = writer; _registry = registry; _objectStack.Push(subject); }
public float GetBlockHealthRatio(int x, int y, int z) { Assert.IsTrue(x >= 0 && y >= 0 && z >= 0 && x < CHUNK_SIZE && y < CHUNK_SIZE && z < CHUNK_SIZE, "Invalid chunk block position"); int maxDamage = BlockRegistry.GetMaxDamage(GetBlockType(x, y, z)); int damage = blocks[GetBlockIdx(x, y, z)].damage; return(1 - (damage / (float)maxDamage)); }
public BlockTemplate(BlockRegistry.BlockTypes type, float mass, bool isSolid = true, bool isPlatform = false, bool isLadder = false) { Type = type; IsSolid = isSolid; IsPlatform = isPlatform; IsLadder = isLadder; Mass = mass; }
public void PlaceBlock() { MouseOverObject moo = SharpCraft.Instance.MouseOverObject; if (moo.hit != HitType.Block) { return; } ItemStack stack = GetEquippedItemStack(); if (!(stack?.Item is ItemBlock itemBlock)) { return; } Block air = BlockRegistry.GetBlock <BlockAir>(); Block glass = BlockRegistry.GetBlock <BlockGlass>(); Block grass = BlockRegistry.GetBlock <BlockGrass>(); Block dirt = BlockRegistry.GetBlock <BlockDirt>(); BlockState clickedState = World.GetBlockState(moo.blockPos); bool replacing; BlockPos pos = (replacing = clickedState.Block.IsReplaceable && itemBlock.Block != clickedState.Block) ? moo.blockPos : moo.blockPos.Offset(moo.sideHit); Block heldBlock = itemBlock.Block; AxisAlignedBB blockBb = heldBlock.BoundingBox.offset(pos.ToVec()); if (!replacing && World.GetBlockState(pos).Block != air || World.GetIntersectingEntitiesBBs(blockBb).Count > 0 && heldBlock.IsSolid) { return; } BlockPos posUnder = pos.Offset(FaceSides.Down); BlockState stateUnder = World.GetBlockState(posUnder); BlockState stateAbove = World.GetBlockState(pos.Offset(FaceSides.Up)); if (stateUnder.Block == grass && heldBlock != glass && heldBlock.IsSolid) { World.SetBlockState(posUnder, dirt.GetState()); } if (stateAbove.Block != air && stateAbove.Block != glass && heldBlock == grass && stateAbove.Block.IsSolid) { World.SetBlockState(pos, dirt.GetState()); } else { World.SetBlockState(pos, heldBlock.GetState(stack.Meta)); } stack.Count--; SharpCraft.Instance.GetMouseOverObject(); }
public string Translate(short id) { if (_forward.TryGetValue(id, out var name)) { return(name); } return(BlockRegistry.GetBlock <BlockAir>().UnlocalizedName); }
public ParsingScenario(string fileName) { _fileName = fileName; _files = new FileSystem(); _parser = new ObjectBlockParser(); _blockRegistry = BlockRegistry.Basic(); _reader = new ObjectBlockReader(_parser, ObjectResolver.Basic(), new InMemoryServiceLocator(), _blockRegistry); }
public BlockLevelGenerator( BlockRegistry BlockRegistry, BlockMaterialRegistry MaterialRegistry, CreateBlockFunctionType CreateBlockCb, TestBlockFunctionType TestBlockCb) { this.BlockRegistry = BlockRegistry; this.MaterialRegistry = MaterialRegistry; this.CreateBlockCb = CreateBlockCb; this.TestBlockCb = TestBlockCb; }
public void Load() { BlockRegistry.LoadBlockType(new Grass()); BlockRegistry.LoadBlockType(new Dirt()); BlockRegistry.LoadBlockType(new Cobblestone()); BlockRegistry.LoadBlockType(new MossyCobblestone()); BlockRegistry.LoadBlockType(new Stone()); Game.BlockRegistry.RegistrationComplete(); Debug.Log("Finished loading assets"); }
public static void Instantiate() { _Instance = new MainLoopable(); //register Logger.Instantiate(); World.Instantiate(); //Debug.Log("MainLoopable"); Block.Air.GetBlockName(); BlockRegistry.RegisterBlocks(); }
private void DetermineLevel() { isLevelType = false; if (BlockID == BlockRegistry.GID("Pickaxe") || BlockID == BlockRegistry.GID("Chestplate") || BlockID == BlockRegistry.GID("Sword") || BlockID == BlockRegistry.GID("Axe") || BlockID == BlockRegistry.GID("Shovel")) { isLevelType = true; Level = 1; } }
private void Awake() { foreach (Block block in blocks) { BlockRegistry.Blocks.Add(block.blockID, block); } BlockRegistry.InitializeBlocks(); TextureManager.SetTerrainTexture(terrainMaterial, tintedMaterial); blocks.Clear(); }
public void GenerateTree(Int3 Pos) { System.Random rnd = new System.Random(); int count = rnd.Next(3, 100) % 3 + 1; int treeheight = 6; for (int i = 0; i < count; i++) { int x = rnd.Next(3, Chunk.ChunkWidth - 4); int z = rnd.Next(3, Chunk.ChunkWidth - 4); Int3 Tree = new Int3(x, 0, z); Chunk ch; if (GetSurface(ref Pos, out ch, ref Tree)) { for (int k = 0; k < treeheight + 1; k++) { if (k < 3) { ch.SetBlock(Tree.x, Tree.y, Tree.z, BlockRegistry.GetBlockFromBlockName("Logbigoak")); } else if (k >= 3 && k <= 5) { ch.SetBlock(Tree.x - 1, Tree.y, Tree.z, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x, Tree.y, Tree.z, BlockRegistry.GetBlockFromBlockName("Logbigoak")); ch.SetBlock(Tree.x + 1, Tree.y, Tree.z, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x - 1, Tree.y, Tree.z - 1, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x, Tree.y, Tree.z - 1, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x + 1, Tree.y, Tree.z - 1, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x - 1, Tree.y, Tree.z + 1, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x, Tree.y, Tree.z + 1, BlockRegistry.GetBlockFromBlockName("Leaves")); ch.SetBlock(Tree.x + 1, Tree.y, Tree.z + 1, BlockRegistry.GetBlockFromBlockName("Leaves")); } else { ch.SetBlock(Tree.x, Tree.y, Tree.z, BlockRegistry.GetBlockFromBlockName("Leaves")); } Tree.y++; if (Tree.y >= Chunk.ChunkHeight) { Pos.y++; ch = GetChunk(Pos.x, Pos.y, Pos.z); Tree.y = 0; } } } } }
public static Texture2D GetTexture(BlockRegistry.BlockTypes name,byte textureSize) { byte i = 0; while(textureSize > 1 && textureSize != 0)//gets the array equivalents {1 = 1,4 = 2,16 = 3} { i++; textureSize /= 4; } if (name > BlockRegistry.BlockTypes.Collector) return Textures[i,(int)CoreTypes.Generic][(int)(name - BlockRegistry.BlockTypes.Collector)]; return Textures[i,(int)CoreTypes.Craft][(int)name]; }