コード例 #1
0
ファイル: Chunk.cs プロジェクト: Gothen111/2DWorld-MonoGame
        public bool setBlockAtCoordinate(Vector3 _Position, Block.Block _Block)
        {
            int var_X = (int)Math.Abs(_Position.X - this.Position.X) / Block.Block.BlockSize;
            int var_Y = (int)Math.Abs(_Position.Y - this.Position.Y) / Block.Block.BlockSize;

            return(this.setBlockAtPosition(var_X, var_Y, _Block));
        }
コード例 #2
0
        public override void onDecorateChunk(Chunk _Chunk)
        {
            base.onDecorateChunk(_Chunk);
            int var_Count = this.getCount();

            for (int i = 0; i < var_Count; i++)
            {
                ItemObject var_itemObject = ItemFactory.itemFactory.createItemObject(this.itemEnum);

                int var_X = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.X * (Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.Y * (Block.Block.BlockSize) - 1);

                var_itemObject.Position     = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);
                var_itemObject.NextPosition = var_itemObject.Position;

                Block.Block var_Block = _Chunk.getBlockAtCoordinate(var_itemObject.Position);

                if (var_Block != null)
                {
                    if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                    {
                        if (_Chunk.Parent != null)
                        {
                            if (_Chunk.Parent != null)
                            {
                                //((Region.Region)_Chunk.Parent).getParent().addObject(var_itemObject, true, (Region.Region)_Chunk.Parent);
                            }
                            var_Block.addObject(var_itemObject);
                        }
                    }
                }
            }
        }
コード例 #3
0
        public virtual void createRegion()
        {
            //if (this.Position.X == 0 && this.Position.Y == 0)
            //{
            double[,] var_HeightMap = this.getParent().getHeightMap(this.Position, new Vector3(this.Size.X * Chunk.Chunk.chunkSizeX, this.Size.Y * Chunk.Chunk.chunkSizeY, 0));

            double var_AverageRegionHeight = 0;

            for (int x = 0; x < var_HeightMap.GetLength(0); x++)
            {
                for (int y = 0; y < var_HeightMap.GetLength(1); y++)
                {
                    Block.Block var_Block = this.getBlockAtCoordinate(new Vector3(this.Position.X + x * Block.Block.BlockSize, this.Position.Y + y * Block.Block.BlockSize, 0));
                    if (var_Block != null)
                    {
                        this.setBlockLayerFromHeight(var_Block, (int)var_HeightMap[x, y], 60);
                    }

                    var_AverageRegionHeight += var_HeightMap[x, y];
                }
            }
            var_AverageRegionHeight = var_AverageRegionHeight / (this.Size.X * Chunk.Chunk.chunkSizeX * this.Size.Y * Chunk.Chunk.chunkSizeY);
            Console.WriteLine(var_AverageRegionHeight);
            //}

            foreach (Chunk.Chunk var_Chunk in this.chunks)
            {
                if (var_Chunk != null)
                {
                    ChunkFactory.chunkFactory.generateChunk(var_Chunk, RegionDependency.regionDependency.getLayer(this.RegionEnum));
                    Decorator.decorator.decorateChunk(var_Chunk);
                    this.loadAllObjectsFromChunkToQuadTree(var_Chunk);
                }
            }
        }
コード例 #4
0
 public Object.Object addObject(Object.Object _Object, Boolean _InsertInQuadTree, Region.Region _Region)
 {
     if (_InsertInQuadTree)
     {
         this.quadTreeObject.Insert(_Object);
     }
     if (_Region != null)
     {
         Chunk.Chunk chunk = _Region.getChunkAtPosition(_Object.Position);
         if (chunk != null)
         {
             Block.Block var_Block = chunk.getBlockAtCoordinate(_Object.Position);
             if (var_Block != null)
             {
                 var_Block.addObject(_Object);
                 if (Configuration.Configuration.isHost)
                 {
                     Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.UpdateObjectMessage(_Object), GameMessageImportance.VeryImportant);
                 }
             }
         }
     }
     else
     {
         Logger.Logger.LogInfo("World.addObject: Object konnte der Region nicht hinzugefügt werden, da diese null war");
     }
     return(_Object);
 }
コード例 #5
0
        public ControlFlowGraph(ThreeAddressCodeVisitor code)
        {
            var code_blocks = new Block.Block(code);

            this.blocks = code_blocks.GenerateBlocks();
            cfg         = new Graph(this.blocks.Count);
            GenerateCFG();
        }
コード例 #6
0
 public bool setBlockAtCoordinate(Vector3 _Position, Block.Block _Block)
 {
     Region.Region var_Region = this.getRegionAtPosition(_Position);
     if (var_Region != null)
     {
         return(var_Region.setBlockAtCoordinate(_Position, _Block));
     }
     return(false);
 }
コード例 #7
0
 public bool setBlockAtCoordinate(Vector3 _Position, Block.Block _Block)
 {
     Chunk.Chunk var_Chunk = this.getChunkAtPosition(_Position);
     if (var_Chunk != null)
     {
         return(var_Chunk.setBlockAtCoordinate(_Position, _Block));
     }
     return(false);
 }
コード例 #8
0
        public List <LinkedList <ThreeCode> > Apply(ThreeAddressCodeVisitor visit)
        {
            Block.Block bl = new Block.Block(visit);
            List <LinkedList <ThreeCode> > res = bl.GenerateBlocks();

            Apply(ref res);

            return(res);
        }
コード例 #9
0
ファイル: Wallet.cs プロジェクト: WorldOfMogwais/WoMNetCore
 /// <summary>
 ///
 /// </summary>
 public async void Update()
 {
     await Task.Run(() =>
     {
         var height = Blockchain.Instance.MaxCachedBlockHeight;
         var hash   = Blockchain.Instance.GetBlockHash(height);
         var block  = Blockchain.Instance.GetBlock(hash);
         LastBlock  = block;
     });
 }
コード例 #10
0
 public Item(Block.Block block, int ItemId, String InGameName, int MaxStack)
 {
     itemBlock   = block;
     isBlockItem = true;
     id          = ItemId;
     stackLimit  = MaxStack;
     name        = InGameName;
     //basename = TextureBaseName;
     texture = Content.Load <Texture2D>("Items/" + basename);
 }
コード例 #11
0
ファイル: ItemStack.cs プロジェクト: PAT457/Reality
 public ItemStack(Block.Block blockObj, int totalStack)
 {
     maxStack = blockObj.getMaxStack();
     if (totalStack < maxStack)
     {
         totalStack = maxStack;
     }
     block = blockObj;
     total = totalStack;
     type  = true;
 }
コード例 #12
0
 public override void SetBlock(Block.Block block)
 {
     if (Width <= block.Transform.Position.X)
     {
         throw new OutOfBoundsException($"{nameof(PieceBuilder)}::{nameof(SetBlock)}: ${nameof(block.Transform.Position.X)} Out-Of-Bounds Exception");
     }
     if (Height <= block.Transform.Position.Y)
     {
         throw new OutOfBoundsException($"{nameof(PieceBuilder)}::{nameof(SetBlock)}: ${nameof(block.Transform.Position.Y)} Out-Of-Bounds Exception");
     }
 }
コード例 #13
0
 protected virtual void setBlockLayerFromHeight(Block.Block _Block, int _Height, int _MaxHeight)
 {
     if (_Height < 20)
     {
         _Block.setFirstLayer(BlockEnum.Water);
     }
     else if (_Height > 40)
     {
         _Block.setFirstLayer(BlockEnum.Wall);
     }
 }
コード例 #14
0
        /// <summary>
        /// Given a block, enters the initialization state for handling a block.
        /// </summary>
        /// <param name="state">The state to set.</param>
        /// <param name="block">The block which will be processed.</param>
        public override void Initialize(State.State state, Block.Block block)
        {
            // We enter our initialization state
            state.BlockGasUsed = 0;
            state.Bloom        = 0;
            state.TransactionReceipts.Clear();

            // Set our current block
            state.UpdateCurrentBlock(block);

            // TODO: Handle DAO fork transfer
        }
コード例 #15
0
        public List <LinkedList <ThreeCode> > Apply(ThreeAddressCodeVisitor visit)
        {
            Block.Block bl = new Block.Block(visit);
            List <LinkedList <ThreeCode> > res = bl.GenerateBlocks();

            for (int i = 0; i < res.Count; i++)
            {
                Apply(res[i]);
            }

            return(res);
        }
コード例 #16
0
        // Genesis Block
        /// <summary>
        /// Adds the genesis block from the current configuration to the chain's database.
        /// </summary>
        private void AddGenesisBlockToDatabase()
        {
            // Obtain the genesis block and it's hash
            Block.Block genesisBlock     = Configuration.GenesisBlock;
            byte[]      genesisBlockHash = genesisBlock.Header.GetHash();

            // Set the block number -> block hash lookup.
            SetBlockHashForBlockNumber(genesisBlock.Header.BlockNumber, genesisBlock.Header.GetHash());

            // Set the block hash -> block lookup
            SetBlock(genesisBlock);
        }
コード例 #17
0
        /// <summary>
        /// Reverts this chain state using a state snapshot obtained from this chain's state earlier.
        /// </summary>
        /// <param name="snapshot"></param>
        public void Revert(State.StateSnapshot snapshot)
        {
            // Obtain our block number in our current state to know how much to roll back in our chain database.
            BigInteger laterBlockNumber = State.CurrentBlock.Header.BlockNumber;

            // Revert our state
            State.Revert(snapshot);

            // Obtain our block number after reverting so we know how much we need to roll back.
            BigInteger earlierBlockNumber = State.CurrentBlock.Header.BlockNumber;

            // Verify this is a revert operation that is occuring to a subset of this chain.
            if (earlierBlockNumber > laterBlockNumber)
            {
                throw new Exception("Reverting to a state that was not a subset of the current state is not yet supported.");
            }

            // Clear any children out (to avoid conflicts: normally snapshot/revert is only applied to state, not chain. Chain snapshot/revert is a test node feature only, and databases don't prune so old data post-revert can cause issues).
            // Note: We only delete children for all newer blocks and our most recent block, since reverting here, our head will have the same hash as originally, and may have children, and potential later blocks may too.
            // Because of this, we clear all children instances in our in-memory database so they don't get parsed as "uncles" waiting to be processed on the side.
            for (BigInteger blockNum = laterBlockNumber; blockNum >= earlierBlockNumber; blockNum--)
            {
                // Obtain our block hash for this number
                byte[] blockHash = GetBlockHashFromBlockNumber(blockNum);

                // Remove the children.
                DeleteChildren(blockHash);

                // Remove the block number->block hash lookup and transaction position lookups
                // NOTE: We do this as long as we're not the genesis block, or the most recent block, since we still want information for those, just not anything after (children, etc).
                if (blockNum > 0 && blockNum > earlierBlockNumber)
                {
                    // Grab the block and remove transaction positions for it.
                    Block.Block block = GetBlock(blockHash);
                    foreach (var transaction in block.Transactions)
                    {
                        RemoveTransactionPosition(transaction.GetHash());
                    }

                    // Remove the block hash lookup for this block.
                    RemoveBlockHashForBlockNumber(blockNum);

                    // Remove the block data itself finally
                    RemoveBlock(blockHash);
                }
            }

            // Update our head block hash
            HeadBlockHash = GetBlockHashFromBlockNumber(earlierBlockNumber);
        }
コード例 #18
0
ファイル: Chunk.cs プロジェクト: Gothen111/2DWorld-MonoGame
 public void setAllNeighboursOfBlocks()
 {
     for (int x = 0; x < this.Size.X; x++)
     {
         for (int y = 0; y < this.Size.Y; y++)
         {
             Block.Block var_Block = this.getBlockAtPosition(x, y);
             if (var_Block != null)
             {
                 var_Block.Parent = this;
                 var_Block.setNeighbours();
             }
         }
     }
 }
コード例 #19
0
ファイル: BlockHandler.cs プロジェクト: zaoqi-clone/MineCase
        public virtual Slot DropBlock(ItemState item, BlockState blockState)
        {
            Block.Block blockObject = Block.Block.FromBlockState(blockState);
            switch ((BlockId)blockState.Id)
            {
            case BlockId.Air:
            case BlockId.Water:
                return(Slot.Empty);

            default:
                ItemState dropItem = blockObject.BlockBrokenItem(item, false);
                return(new Slot {
                    BlockId = (short)dropItem.Id, ItemCount = 1
                });
            }
        }
コード例 #20
0
        public override void onDecorateChunk(Chunk _Chunk)
        {
            base.onDecorateChunk(_Chunk);
            int var_Count = this.getCount();

            for (int i = 0; i < var_Count; i++)
            {
                EquipmentObject var_EquipmentObject = null;

                if (this.equipmentType == ItemEnum.Weapon)
                {
                    var_EquipmentObject = EquipmentFactory.equipmentFactory.createEquipmentWeaponObject(WeaponEnum.Sword);
                }
                else if (this.equipmentType == ItemEnum.Armor)
                {
                    var_EquipmentObject = EquipmentFactory.equipmentFactory.createEquipmentArmorObject(ArmorEnum.GoldenArmor);
                }

                if (var_EquipmentObject != null)
                {
                    int var_X = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.X * (Block.Block.BlockSize) - 1);
                    int var_Y = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.Y * (Block.Block.BlockSize) - 1);

                    var_EquipmentObject.Position     = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);
                    var_EquipmentObject.NextPosition = var_EquipmentObject.Position;

                    Block.Block var_Block = _Chunk.getBlockAtCoordinate(var_EquipmentObject.Position);

                    if (var_Block != null)
                    {
                        if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                        {
                            if (_Chunk.Parent != null)
                            {
                                //((Region.Region)_Chunk.Parent).getParent().addObject(var_EquipmentObject, true, (Region.Region)_Chunk.Parent);
                            }
                            var_Block.addObject(var_EquipmentObject);
                        }
                    }
                }
            }
        }
コード例 #21
0
        // 0 == Wall ! 1 == Floor  ! 2 == StairUp ! 3 == Treasure
        private void generateDungeon(int _Width, int _Heigth)
        {
            int var_Width  = _Width * 10;
            int var_Heigth = _Heigth * 10;

            int[,] var_Map = this.generateMap(var_Width, var_Heigth, 5);
            this.placeStairUp(var_Width, var_Heigth, var_Map);
            this.placeTreasure(var_Width, var_Heigth, var_Map);
            for (int x = 0; x < var_Width; x++)
            {
                for (int y = 0; y < var_Heigth; y++)
                {
                    if (var_Map[x, y] == 0)
                    {
                        Block.Block var_Block = this.getBlockAtCoordinate(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize);
                        var_Block.setFirstLayer(BlockEnum.Ground2);
                    }
                    else if (var_Map[x, y] == 1)
                    {
                        Block.Block var_Block = this.getBlockAtCoordinate(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize);
                        var_Block.setFirstLayer(BlockEnum.Ground1);
                    }
                    else if (var_Map[x, y] == 2)
                    {
                        Block.Block var_Block = this.getBlockAtCoordinate(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize);
                        var_Block.setFirstLayer(BlockEnum.Ground1);
                        //var_Block.DrawColor = Color.Green;
                    }
                    else if (var_Map[x, y] == 3)
                    {
                        Block.Block var_Block = this.getBlockAtCoordinate(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize);
                        //var_Block = new Block.Blocks.TeleportBlock(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize, BlockEnum.Ground1, (Chunk.Chunk)var_Block.Parent, this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize, false, 0);
                        var_Block.setFirstLayer(BlockEnum.Ground1);
                        //var_Block.DrawColor = Color.Yellow;
                        this.setBlockAtCoordinate(this.Position + new Vector3(x, y, 0) * Block.Block.BlockSize, var_Block);
                        this.Exits.Add(var_Block);
                    }
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// Given a block, enters the finalization state for handling a block.
        /// </summary>
        /// <param name="state">The state to set.</param>
        /// <param name="block">The block which will be processed.</param>
        public override void Finalize(State.State state, Block.Block block)
        {
            // Obtain the rewards accordingly
            BigInteger blockReward  = 0;
            BigInteger nephewReward = 0;

            if (state.Configuration.Version >= Configuration.EthereumRelease.Byzantium)
            {
                blockReward  = state.Configuration.BlockRewardByzantium;
                nephewReward = state.Configuration.NephewRewardByzantium;
            }
            else
            {
                blockReward  = state.Configuration.BlockReward;
                nephewReward = state.Configuration.NephewReward;
            }

            // Calculate our total reward, which is our reward for the immediate block, plus rewards for each uncle processed.
            BigInteger totalReward = blockReward + (nephewReward * block.Uncles.Length);

            // Award the money to the coinbase
            state.ModifyBalanceDelta(state.CurrentBlock.Header.Coinbase, totalReward);

            // Next, we'll want to factor in our depth penalty factor for our uncles, depending on their distance from the current block.
            foreach (BlockHeader uncle in block.Uncles)
            {
                // We apply our factor to our uncle distance from the current block to obtain a multiplier for reward which takes into account penalty, which we multiply the reward by.
                BigInteger uncleReward = blockReward * (state.Configuration.UncleDepthPenaltyFactor + (uncle.BlockNumber - state.CurrentBlock.Header.BlockNumber)) / state.Configuration.UncleDepthPenaltyFactor;

                // Award our reward to the uncle's coinbase.
                state.ModifyBalanceDelta(uncle.Coinbase, uncleReward);
            }

            // We'll want to remove any recent uncles past our max after finalizing this block.
            BigInteger lastUncleBlockNumber = state.CurrentBlock.Header.BlockNumber - state.Configuration.MaxUncleDepth;

            // Check if this uncle is in our recent uncle list
            state.RecentUncleHashes.Remove(lastUncleBlockNumber);
        }
コード例 #23
0
        /// <summary>
        /// Obtains a State instance that represents the state after the block with the given hash was processed.
        /// </summary>
        /// <param name="blockHash">The hash of the block to obtain post-processed state of.</param>
        /// <returns>Returns a State instance that represents the state after the block with the given hash was processed.</returns>
        public State.State GetPostBlockState(byte[] blockHash)
        {
            // Obtain the block.
            Block.Block block = GetBlock(blockHash);
            if (block == null)
            {
                return(null);
            }

            // Otherwise we obtain the state with the block's given state root hash and set the current block.
            State.State state = new State.State(Configuration, block.Header.StateRootHash);
            state.UpdateCurrentBlock(block);
            state.BlockGasUsed = block.Header.GasUsed;

            // We'll want to populate our previous block hashes for this state (and one for this block)
            Block.Block currentBlock = block;
            for (int i = 0; i < Configuration.PreviousHashDepth + 1; i++)
            {
                // Add our previous header
                state.PreviousHeaders.Add(currentBlock.Header);

                // If our index is less than our max uncle depth, we add our uncles
                if (i < Configuration.MaxUncleDepth)
                {
                    state.UpdateUncleHashes(currentBlock);
                }

                // Iterate to the previous block.
                currentBlock = GetParentBlock(currentBlock);
                if (currentBlock == null)
                {
                    break;
                }
            }

            return(state);
        }
コード例 #24
0
ファイル: Chunk.cs プロジェクト: Gothen111/2DWorld-MonoGame
 public bool setBlockAtPosition(int _PosX, int _PosY, Block.Block _Block)
 {
     if (_PosX >= 0 && _PosX < this.Size.X)
     {
         if (_PosY >= 0 && _PosY < this.Size.Y)
         {
             int var_Position = (int)(_PosX + _PosY * chunkSizeX);
             this.blocks[var_Position] = _Block;
             //this.setAllNeighboursOfBlocks();// HIER!!!
             _Block.setNeighbours();
             return(true);
         }
         else
         {
             Logger.Logger.LogErr("Chunk->setBlockAtPosition(...) : Platzierung nicht möglich: PosX " + _PosX + " PosY " + _PosY);
             return(false);
         }
     }
     else
     {
         Logger.Logger.LogErr("Chunk->setBlockAtPosition(...) : Platzierung nicht möglich: PosX " + _PosX + " PosY " + _PosY);
         return(false);
     }
 }
コード例 #25
0
 static Blocks()
 {
     Air                        = new BlockAir();
     Stone                      = new BlockStone();
     Grass                      = new BlockGrass();
     Dirt                       = new BlockDirt();
     Cobblestone                = new BlockCobblestone();
     Planks                     = new BlockPlanks();
     Sapling                    = new BlockSapling();
     Bedrock                    = new BlockBedrock();
     FlowingWater               = new BlockFlowingWater();
     Water                      = new BlockWater();
     FlowingLava                = new BlockFlowingLava();
     Lava                       = new BlockLava();
     Sand                       = new BlockSand();
     Gravel                     = new BlockGravel();
     GoldOre                    = new BlockGoldOre();
     IronOre                    = new BlockIronOre();
     CoalOre                    = new BlockCoalOre();
     Log                        = new BlockOldLog();
     Log2                       = new BlockNewLog();
     Leaves                     = new BlockOldLeaf();
     Leaves2                    = new BlockNewLeaf();
     Sponge                     = new BlockSponge();
     Glass                      = new BlockGlass();
     LapisOre                   = new BlockLapisOre();
     LapisBlock                 = new BlockLapis();
     Dispenser                  = new BlockDispenser();
     SandStone                  = new BlockSandStone();
     NoteBlock                  = new BlockNote();
     Bed                        = new BlockBed();
     GoldenRail                 = new BlockRailPowered();
     DetectorRail               = new BlockRailDetector();
     StickyPiston               = new BlockStickyPistonBase();
     Web                        = new BlockWeb();
     TallGrass                  = new BlockTallGrass();
     DeadBush                   = new BlockDeadBush();
     Piston                     = new BlockPistonBase();
     PistonHead                 = new BlockPistonExtension();
     Wool                       = new BlockWool();
     PistonExtension            = new BlockPistonMoving();
     YellowFlower               = new BlockYellowFlower();
     RedFlower                  = new BlockRedFlower();
     BrownMushroom              = new BlockBrownMushroom();
     RedMushroom                = new BlockRedMushroom();
     GoldBlock                  = new BlockGold();
     IronBlock                  = new BlockIron();
     DoubleStoneSlab            = new BlockDoubleStoneSlab();
     StoneSlab                  = new BlockHalfStoneSlab();
     BrickBlock                 = new BlockBrick();
     TNT                        = new BlockTNT();
     Bookshelf                  = new BlockBookshelf();
     MossyCobblestone           = new BlockMossyCobblestone();
     Obsidian                   = new BlockObsidian();
     Torch                      = new BlockTorch();
     Fire                       = new BlockFire();
     MobSpawner                 = new BlockMobSpawner();
     OakStairs                  = new BlockOakStairs();
     Chest                      = new BlockChest();
     RedstoneWire               = new BlockRedstoneWire();
     DiamondOre                 = new BlockDiamondOre();
     DiamondBlock               = new BlockDiamond();
     CraftingTable              = new BlockWorkbench();
     Wheat                      = new BlockWheat();
     Farmland                   = new BlockFarmland();
     Furnace                    = new BlockFurnace();
     LitFurnace                 = new BlockLitFurnace();
     StandingSign               = new BlockStandingSign();
     OakDoor                    = new BlockOakDoor();
     SpruceDoor                 = new BlockSpruceDoor();
     BirchDoor                  = new BlockBirchDoor();
     JungleDoor                 = new BlockJungleDoor();
     AcaciaDoor                 = new BlockAcaciaDoor();
     DarkOakDoor                = new BlockDarkOakDoor();
     Ladder                     = new BlockLadder();
     Rail                       = new BlockRail();
     StoneStairs                = new BlockStoneStairs();
     WallSign                   = new BlockWallSign();
     Lever                      = new BlockLever();
     StonePressurePlate         = new BlockStonePressurePlate();
     IronDoor                   = new BlockIronDoor();
     WoodenPressurePlate        = new BlockWoodenPressurePlate();
     RedstoneOre                = new BlockRedstoneOre();
     LitRedstoneOre             = new BlockLitRedstoneOre();
     UnlitRedstoneTorch         = new BlockUnlitRedstoneTorch();
     RedstoneTorch              = new BlockRedstoneTorch();
     StoneButton                = new BlockButtonStone();
     SnowLayer                  = new BlockSnow();
     Ice                        = new BlockIce();
     Snow                       = new BlockSnowBlock();
     Cactus                     = new BlockCactus();
     Clay                       = new BlockClay();
     Reeds                      = new BlockReed();
     Jukebox                    = new BlockJukebox();
     OakFence                   = new BlockOakFence();
     SpruceFence                = new BlockSpruceFence();
     BirchFence                 = new BlockBirchFence();
     JungleFence                = new BlockJungleFence();
     DarkOakFence               = new BlockDarkOakFence();
     AcaciaFence                = new BlockAcaciaFence();
     Pumpkin                    = new BlockPumpkin();
     Netherrack                 = new BlockNetherrack();
     SoulSand                   = new BlockSoulSand();
     Glowstone                  = new BlockGlowstone();
     Portal                     = new BlockPortal();
     LitPumpkin                 = new BlockLitPumpkin();
     Cake                       = new BlockCake();
     UnpoweredRedstoneRepeater  = new BlockUnpoweredRedstoneRepeater();
     RedstoneRepeater           = new BlockRedstoneRepeater();
     TrapDoor                   = new BlockTrapDoor();
     MonsterEgg                 = new BlockSilverfish();
     StoneBrick                 = new BlockStoneBrick();
     BrownMushroomBlock         = new BlockHugeBrownMushroom();
     RedMushroomBlock           = new BlockHugeRedMushroom();
     IronBars                   = new BlockIronPane();
     GlassPane                  = new BlockGlassPane();
     MelonBlock                 = new BlockMelon();
     PumpkinStem                = new BlockPumpkinStem();
     MelonStem                  = new BlockMelonStem();
     Vine                       = new BlockVine();
     OakFenceGate               = new BlockOakFenceGate();
     SpruceFenceGate            = new BlockSpruceFenceGate();
     BirchFenceGate             = new BlockBirchFenceGate();
     JungleFenceGate            = new BlockJungleFenceGate();
     DarkOakFenceGate           = new BlockDarkOakFenceGate();
     AcaciaFenceGate            = new BlockAcaciaFenceGate();
     BrickStairs                = new BlockBrickStairs();
     StoneBrickStairs           = new BlockStoneBrickStairs();
     Mycelium                   = new BlockMycelium();
     WaterLily                  = new BlockLilyPad();
     NetherBrick                = new BlockNetherBrick();
     NetherBrickFence           = new BlockNetherBrickFence();
     NetherBrickStairs          = new BlockNetherBrickStairs();
     NetherWart                 = new BlockNetherWart();
     EnchantingTable            = new BlockEnchantingTable();
     BrewingStand               = new BlockBrewingStand();
     Cauldron                   = new BlockCauldron();
     EndPortal                  = new BlockEndPortal();
     EndPortalFrame             = new BlockEndPotalFrame();
     EndStone                   = new BlockEndStone();
     DragonEgg                  = new BlockDragonEgg();
     RedstoneLamp               = new BlockRedstoneLight();
     LitRedstoneLamp            = new BlockLitRedstoneLight();
     DoubleWoodenSlab           = new BlockDoubleWoodSlab();
     WoodenSlab                 = new BlockHalfWoodSlab();
     Cocoa                      = new BlockCocoa();
     SandStoneStairs            = new BlockSandStoneSiatrs();
     EmeraldOre                 = new BlockEmeraldOre();
     EnderChest                 = new BlockEnderChest();
     TripWireHook               = new BlockTripWireHook();
     TripWire                   = new BlockTripWire();
     EmeraldBlock               = new BlockEmerald();
     SpruceStairs               = new BlockSpruceStairs();
     BirchStairs                = new BlockBirchStairs();
     JungleStairs               = new BlockJungleStairs();
     CommandBlock               = new BlockCommandBlock();
     Beacon                     = new BlockBeacon();
     CobblestoneWall            = new BlockCobblestoneWall();
     FlowerPot                  = new BlockFlowerPot();
     Carrots                    = new BlockCarrot();
     Potatoes                   = new BlockPotato();
     WoodenButton               = new BlockButtonWood();
     Skull                      = new BlockSkull();
     Anvil                      = new BlockAnvil();
     TrappedChest               = new BlockTrapChest();
     LightWeightedPressurePlate = new BlockPressurePlateLightWeighted();
     HeavyWeightedPressurePlate = new BlockPressurePlateHeavyWeighted();
     UnpoweredComparator        = new BlockUnpoweredRedstoneComparator();
     PoweredComparator          = new BlockRedstoneComparator();
     DaylightDetector           = new BlockDaylightDetector();
     DaylightDetectorInverted   = new BlockInvertedDaylightDetector();
     RedstoneBlock              = new BlockCompressedPowered();
     QuartzOre                  = new BlockQuartzOre();
     Hopper                     = new BlockHopper();
     QuartzBlock                = new BlockQuartz();
     QuartzStairs               = new BlockQuartzStairs();
     ActivatorRail              = new BlockActivatorRail();
     Dropper                    = new BlockDropper();
     StainedHardenedClay        = new BlockStainedHardenedClay();
     Barrier                    = new BlockBarrier();
     IronTrapDoor               = new BlockIronTrapDoor();
     HayBlock                   = new BlockHay();
     Carpet                     = new BlockCarpet();
     HardenedClay               = new BlockHardenedClay();
     CoalBlock                  = new BlockCoal();
     PackedIce                  = new BlockPackedIce();
     AcaciaStairs               = new BlockAcaciaStairs();
     DarkOakStairs              = new BlockDarkOakStairs();
     SlimeBlock                 = new BlockSlime();
     DoublePlant                = new BlockDoublePlant();
     StainedGlass               = new BlockStainedGlass();
     StainedGlassPane           = new BlockStainedGlassPane();
     Prismarine                 = new BlockPrismarine();
     SeaLantern                 = new BlockSeaLantern();
     StandingBanner             = new BlockBannerStanding();
     WallBanner                 = new BlockBannerHanging();
     RedSandStone               = new BlockRedSandStone();
     RedSandStoneStairs         = new BlockRedSandStoneStairs();
     DoubleStoneSlab2           = new BlockDoubleStoneSlabNew();
     StoneSlab2                 = new BlockHalfStoneSlabNew();
     EndRod                     = new BlockEndRod();
     ChorusPlant                = new BlockChorusPlant();
     ChorusFlower               = new BlockChorusFlower();
     PurpurBlock                = new BlockPurpur();
     PurpurPillar               = new BlockPurpurPillar();
     PurpurStairs               = new BlockPurpurStairs();
     PurpurDoubleSlab           = new BlockPurpurDoubleSlab();
     PurpurSlab                 = new BlockPurpurHalfSlab();
     EndBricks                  = new BlockEndBricks();
     Beetroots                  = new BlockBeetroot();
     GrassPath                  = new BlockGrassPath();
     EndGateway                 = new BlockEndGateway();
     RepeatingCommandBlock      = new BlockCommandBlockRepeating();
     ChainCommandBlock          = new BlockCommandBlockChain();
     FrostedIce                 = new BlockFrostedIce();
     Magma                      = new BlockMagma();
     NetherWartBlock            = new BlockNetherWartBlock();
     RedNetherBrick             = new BlockRedNetherBrick();
     BoneBlock                  = new BlockBone();
     StructureVoid              = new BlockStructureVoid();
     Observer                   = new BlockObserver();
     WhiteShulkerBox            = new BlockShulkerBoxWhite();
     OrangeShulkerBox           = new BlockShulkerBoxOrange();
     MagentaShulkerBox          = new BlockShulkerBoxMagenta();
     LightBlueShulkerBox        = new BlockShulkerBoxLightBlue();
     YellowShulkerBox           = new BlockShulkerBoxYellow();
     LimeShulkerBox             = new BlockShulkerBoxLime();
     PinkShulkerBox             = new BlockShulkerBoxPink();
     GrayShulkerBox             = new BlockShulkerBoxGray();
     SilverShulkerBox           = new BlockShulkerBoxSilver();
     CyanShulkerBox             = new BlockShulkerBoxCyan();
     PurpleShulkerBox           = new BlockShulkerBoxPurple();
     BlueShulkerBox             = new BlockShulkerBoxBlue();
     BrownShulkerBox            = new BlockShulkerBoxBrown();
     GreenShulkerBox            = new BlockShulkerBoxGreen();
     RedShulkerBox              = new BlockShulkerBoxRed();
     BlackShulkerBox            = new BlockShulkerBoxBlack();
     StructureBlock             = new BlockStructure();
 }
コード例 #26
0
 public override bool IsBlockAvailavle(Block.Block block)
 {
     throw new System.NotImplementedException();
 }
コード例 #27
0
        /// <summary>
        /// Verifies all uncles in a given block to be processed.
        /// </summary>
        /// <param name="state">The state which accompanied the block to verify the uncles of.</param>
        /// <param name="block">The block to verify the uncles of.</param>
        /// <returns>Returns true if verification succeeded, returns false or throws an exception otherwise.</returns>
        public override bool VerifyUncles(State.State state, Block.Block block)
        {
            // Verify our uncles hash matches
            if (!block.Header.UnclesHash.ValuesEqual(block.CalculateUnclesHash()))
            {
                throw new BlockException("Block validation failed due to a hash mismatch when validating uncles.");
            }

            // Verify our uncle hash count did not exceed the maximum uncle count
            if (block.Uncles.Length > state.Configuration.MaxUncleDepth)
            {
                throw new BlockException("Block validation failed because the amount of uncles attached exceeded the maximum uncle count.");
            }

            // By definition, any uncle should be lower block number than the given block, since its only included as an uncle after it fails to be included at its desired block number.
            foreach (BlockHeader uncle in block.Uncles)
            {
                if (uncle.BlockNumber >= block.Header.BlockNumber)
                {
                    throw new BlockException("Block validation failed because an uncle's block number was not less than the block number it was included in.");
                }
            }

            // Obtain our list of ancestors.
            BlockHeader[] ancestors = new BlockHeader[Math.Min(state.Configuration.MaxUncleDepth + 1, state.PreviousHeaders.Count) + 1];
            ancestors[0] = block.Header;
            for (int i = 1; i < ancestors.Length; i++)
            {
                ancestors[i] = state.PreviousHeaders[i - 1];
            }

            // Create our valid ancestor list, the uncle header could've been
            Dictionary <byte[], BlockHeader> validUncleParents = new Dictionary <byte[], BlockHeader>();

            for (int i = 2; i < ancestors.Length; i++)
            {
                validUncleParents[ancestors[i].GetHash()] = ancestors[i];
            }

            // Uncles cannot be ancestors, and also can only be included once every max uncle depth.
            Dictionary <byte[], bool> invalidUncleList = new Dictionary <byte[], bool>(new ArrayComparer <byte[]>());

            foreach (var recentUncleHashes in state.RecentUncleHashes)
            {
                // Verify this uncle list comes from a block number before the current block.
                if (state.CurrentBlock.Header.BlockNumber <= recentUncleHashes.Key)
                {
                    continue;
                }

                // Verify this uncle list comes at a block number not past our max uncle depth from our current block number.
                if (recentUncleHashes.Key < state.CurrentBlock.Header.BlockNumber - state.Configuration.MaxUncleDepth)
                {
                    continue;
                }

                // Add our uncle hash to our list.
                foreach (byte[] uncleHash in recentUncleHashes.Value)
                {
                    invalidUncleList[uncleHash] = true;
                }
            }

            // Loop for all this current blocks uncles
            foreach (BlockHeader uncle in block.Uncles)
            {
                // Verify uncle's parent is part of our valid list
                if (!validUncleParents.TryGetValue(uncle.PreviousHash, out var parent))
                {
                    throw new BlockException("Block validation failed because uncles previous hash referenced a block that was not deemed a valid uncle parent.");
                }

                // Verify our difficulty
                BigInteger calculatedDifficulty = Block.Block.CalculateDifficulty(parent, uncle.Timestamp, state.Configuration);
                if (uncle.Difficulty != calculatedDifficulty)
                {
                    throw new BlockException($"Block validation failed because uncle had a difficulty mismatch. Expected = {calculatedDifficulty}, Actual = {uncle.Difficulty}");
                }

                // Verify block number
                if (uncle.BlockNumber != parent.BlockNumber + 1)
                {
                    throw new BlockException("Block validation failed because uncle's block number was not sequentially following its parent.");
                }

                // Verify timestamp
                if (uncle.Timestamp < parent.Timestamp)
                {
                    throw new BlockException($"Block validation failed because uncle's timestamp was less than its parent. Uncle = {uncle.Timestamp}, Parent={parent.Timestamp}");
                }

                // Verify our uncle isn't in our invalid list
                byte[] uncleHash = uncle.GetHash();
                if (invalidUncleList.ContainsKey(uncleHash))
                {
                    throw new BlockException("Block validation failed because uncle was also a direct ancestor or didn't meet depth requirements.");
                }

                // Verify our uncle didn't use more gas than the limit
                if (uncle.GasUsed > uncle.GasLimit)
                {
                    throw new BlockException("Block validation failed because uncle gas used exceeded the uncle gas limit.");
                }

                // Check the proof for our uncle
                if (!CheckProof(state, uncle))
                {
                    throw new BlockException("Block validation failed because uncle has a proof of work check failure!");
                }

                // Add this uncle to in invalid uncle list, as there should be no duplicates going forward.
                invalidUncleList[uncleHash] = true;
            }

            // Return our boolean indicating we succeeded.
            return(true);
        }
コード例 #28
0
ファイル: ItemStack.cs プロジェクト: PAT457/Reality
 public void changeBlock(Block.Block newBlock)
 {
     block    = newBlock;
     maxStack = newBlock.getMaxStack();
     type     = true;
 }
コード例 #29
0
        public void updatePlayerObjectNeighborhood(GameTime _GameTime, Object.PlayerObject _PlayerObject)
        {
            List <Chunk.Chunk> var_ChunksInRange = new List <Chunk.Chunk>();

            foreach (Chunk.Chunk var_Chunk in this.chunksOutOfRange)
            {
                if (Vector3.Distance(var_Chunk.Position, new Vector3(_PlayerObject.Position.X, _PlayerObject.Position.Y, 0)) <= (Setting.Setting.blockDrawRange * Block.Block.BlockSize))
                {
                    var_ChunksInRange.Add(var_Chunk);
                }
            }

            foreach (Chunk.Chunk var_Chunk in var_ChunksInRange)
            {
                this.chunksOutOfRange.Remove(var_Chunk);
            }

            if (_PlayerObject != null)
            {
                Vector3 var_PlayerPos = _PlayerObject.Position;

                if (_PlayerObject.CurrentBlock != null)
                {
                    var_PlayerPos = _PlayerObject.CurrentBlock.Position;
                }
                int var_DrawSizeX = Setting.Setting.blockDrawRange;
                int var_DrawSizeY = Setting.Setting.blockDrawRange;

                for (int x = 0; x < var_DrawSizeX; x++)
                {
                    for (int y = 0; y < var_DrawSizeY; y++)
                    {
                        Vector3     var_Position = new Vector3(var_PlayerPos.X + (-var_DrawSizeX / 2 + x) * Block.Block.BlockSize, var_PlayerPos.Y + (-var_DrawSizeY / 2 + y) * Block.Block.BlockSize, 0);
                        Block.Block var_Block    = this.getBlockAtCoordinate(var_Position);
                        if (var_Block != null)
                        {
                            var_Block.update(_GameTime);
                        }
                        else
                        {
                            Region.Region var_Region = this.getRegionAtPosition(var_Position);
                            if (var_Region == null)
                            {
                                var_Region = this.createRegionAt(var_Position);
                            }
                            else
                            {
                                Chunk.Chunk var_Chunk = this.getChunkAtPosition(var_Position);
                                if (var_Chunk == null)
                                {
                                    var_Chunk = this.createChunkAt(var_Position);
                                }
                            }
                        }
                    }
                }
            }

            List <Object.Object> var_Objects = this.getObjectsInRange(_PlayerObject.Position, 600);

            foreach (Object.Object var_Object in var_Objects)
            {
                if (!this.objectsToUpdate.Contains(var_Object))
                {
                    this.objectsToUpdate.Add(var_Object);
                }
            }
        }
コード例 #30
0
 public virtual void SetBlock(Block.Block block)
 {
     throw new NotImplementedException($"{nameof(PieceBuilderBase)}::{nameof(SetBlock)}: Not-Implemented Exception");
 }