Esempio n. 1
0
        public static BlockEntity GetBlockEntityById(string blockEntityId)
        {
            BlockEntity blockEntity = null;

            if (blockEntityId == "Sign")
            {
                blockEntity = new Sign();
            }
            else if (blockEntityId == "Chest")
            {
                blockEntity = new ChestBlockEntity();
            }
            else if (blockEntityId == "EnchantTable")
            {
                blockEntity = new EnchantingTableBlockEntity();
            }
            else if (blockEntityId == "Furnace")
            {
                blockEntity = new FurnaceBlockEntity();
            }
            else if (blockEntityId == "Skull")
            {
                blockEntity = new SkullBlockEntity();
            }
            else if (blockEntityId == "ItemFrame")
            {
                blockEntity = new ItemFrameBlockEntity();
            }
            else if (blockEntityId == "Bed")
            {
                blockEntity = new BedBlockEntity();
            }
            else if (blockEntityId == "Banner")
            {
                blockEntity = new BannerBlockEntity();
            }
            else if (blockEntityId == "FlowerPot")
            {
                blockEntity = new FlowerPotBlockEntity();
            }
            else if (blockEntityId == "Beacon")
            {
                blockEntity = new BeaconBlockEntity();
            }
            else if (blockEntityId == "MobSpawner")
            {
                blockEntity = new MobSpawnerBlockEntity();
            }

            return(blockEntity);
        }
Esempio n. 2
0
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            FacingDirection = (int)face;

            var bannerBlockEntity = new BannerBlockEntity
            {
                Coordinates = Coordinates,
                Base        = Base,
            };

            bannerBlockEntity.SetCompound(ExtraData);
            world.SetBlockEntity(bannerBlockEntity);

            return(false);
        }
Esempio n. 3
0
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            // metadata for banner is a value 0-15 that signify the orientation of the banner. Same as PC metadata.
            Metadata = (byte)((int)(Math.Floor((player.KnownPosition.Yaw + 180) * 16 / 360) + 0.5) & 0x0f);

            var bannerBlockEntity = new BannerBlockEntity
            {
                Coordinates = Coordinates,
                Base        = Base,
            };

            bannerBlockEntity.SetCompound(ExtraData);
            world.SetBlockEntity(bannerBlockEntity);

            return(false);
        }
Esempio n. 4
0
        public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);

            if (face == BlockFace.Up)             // On top of block
            {
                var banner = new StandingBanner();
                banner.Coordinates = coor;
                // metadata for banner is a value 0-15 that signify the orientation of the banner. Same as PC metadata.
                banner.Metadata = (byte)((int)(Math.Floor((player.KnownPosition.Yaw + 180) * 16 / 360) + 0.5) & 0x0f);
                world.SetBlock(banner);
            }
            else if (face == BlockFace.North)             // At the bottom of block
            {
                // Doesn't work, ignore if that happen.
                return;
            }
            else
            {
                var banner = new WallBanner();
                banner.Coordinates = coor;
                banner.Metadata    = (byte)face;
                world.SetBlock(banner);
            }

            // Then we create and set the wall block entity that has all the intersting data

            var bannerBlockEntity = new BannerBlockEntity
            {
                Coordinates = coor,
                Base        = Metadata,
            };

            bannerBlockEntity.SetCompound(ExtraData);

            world.SetBlockEntity(bannerBlockEntity);
        }
Esempio n. 5
0
        public static BlockEntity GetBlockEntityById(string blockEntityId)
        {
            BlockEntity blockEntity = CustomBlockEntityFactory?.GetBlockEntityById(blockEntityId);

            if (blockEntity != null)
            {
                return(blockEntity);
            }

            if (blockEntityId == "Sign")
            {
                blockEntity = new SignBlockEntity();
            }
            else if (blockEntityId == "Chest")
            {
                blockEntity = new ChestBlockEntity();
            }
            else if (blockEntityId == "EnchantTable")
            {
                blockEntity = new EnchantingTableBlockEntity();
            }
            else if (blockEntityId == "Furnace")
            {
                blockEntity = new FurnaceBlockEntity();
            }
            else if (blockEntityId == "BlastFurnace")
            {
                blockEntity = new BlastFurnaceBlockEntity();
            }
            else if (blockEntityId == "Skull")
            {
                blockEntity = new SkullBlockEntity();
            }
            else if (blockEntityId == "ItemFrame")
            {
                blockEntity = new ItemFrameBlockEntity();
            }
            else if (blockEntityId == "Bed")
            {
                blockEntity = new BedBlockEntity();
            }
            else if (blockEntityId == "Banner")
            {
                blockEntity = new BannerBlockEntity();
            }
            else if (blockEntityId == "FlowerPot")
            {
                blockEntity = new FlowerPotBlockEntity();
            }
            else if (blockEntityId == "Beacon")
            {
                blockEntity = new BeaconBlockEntity();
            }
            else if (blockEntityId == "MobSpawner")
            {
                blockEntity = new MobSpawnerBlockEntity();
            }
            else if (blockEntityId == "ChalkboardBlock")
            {
                blockEntity = new ChalkboardBlockEntity();
            }
            else if (blockEntityId == "ShulkerBox")
            {
                blockEntity = new ShulkerBoxBlockEntity();
            }
            else if (blockEntityId == "StructureBlock")
            {
                blockEntity = new StructureBlockBlockEntity();
            }

            return(blockEntity);
        }