Example #1
0
 protected BlockBaseMushroom()
 {
     Name = "BaseMushroom";
     IsAir = true;
     IsSingleHit = true;
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.3, 0, 0.3, 0.7, 0.4, 0.7);
 }
Example #2
0
 public BlockSlab()
 {
     Name = "Slab";
     Type = BlockData.Blocks.Slab;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.5, 1);
 }
Example #3
0
 public BlockRedstoneRepeater()
 {
     Name = "RedstoneRepeater";
     Type = BlockData.Blocks.Redstone_Repeater;
     Opacity = 0x0;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)BlockData.Items.Redstone_Repeater, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #4
0
 public BlockTracks()
 {
     Name = "Tracks";
     Type = BlockData.Blocks.Tracks;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #5
0
 public BlockWoodenPressurePlate()
 {
     Name = "WoodenPressurePlate";
     Type = BlockData.Blocks.Wooden_Pressure_Plate;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.0625, 0, 0.0625, 0.9375, 0.0625, 0.9375);
 }
Example #6
0
 public BlockDetectorRail()
 {
     Name = "DetectorRail";
     Type = BlockData.Blocks.DetectorRail;
     IsAir = true;
     Opacity = 0x0;
     LootTable.Add(new ItemStack((short)Type, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #7
0
 public BlockSnow()
 {
     Name = "Snow";
     Type = BlockData.Blocks.Snow;
     IsAir = true;
     Opacity = 0x0;
     IsSolid = true;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #8
0
 public BlockCactus()
 {
     Name = "Cactus";
     Type = BlockData.Blocks.Cactus;
     IsSolid = true;
     Opacity = 0x0;
     LootTable.Add(new ItemStack((short)Type, 1));
     BlockBoundsOffset = new BoundingBox(0.0625, 0, 0.0625, 0.9375, 0.9375, 0.9375);
 }
Example #9
0
 public BlockSoil()
 {
     Name = "Soil";
     Type = BlockData.Blocks.Soil;
     IsSolid = true;
     IsFertile = true;
     IsPlowed = true;
     LootTable.Add(new ItemStack((short)BlockData.Blocks.Dirt, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.9375, 1);
 }
Example #10
0
 public BlockBed()
 {
     Name = "Bed";
     Type = BlockData.Blocks.Bed;
     BurnEfficiency = 300;
     var item = ItemHelper.GetInstance((short)BlockData.Items.Bed);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.5625, 1);
 }
Example #11
0
 public BlockDeadBush()
 {
     Name = "DeadBush";
     Type = BlockData.Blocks.DeadBush;
     IsSingleHit = true;
     IsAir = true;
     IsSolid = true;
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.1, 0, 0.1, 0.9, 0.8, 0.9);
 }
Example #12
0
 public BlockSapling()
 {
     Name = "Sapling";
     Type = BlockData.Blocks.Sapling;
     IsAir = true;
     IsSingleHit = true;
     BurnEfficiency = 100;
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.1, 0, 0.1, 0.9, 0.8, 0.9);
 }
Example #13
0
 public BlockRedstoneWire()
 {
     Name = "RedstoneWire";
     Type = BlockData.Blocks.Redstone_Wire;
     IsAir = true;
     IsSingleHit = true;
     LootTable.Add(new ItemStack((short)BlockData.Items.Redstone, 1));
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.0625, 1);
 }
Example #14
0
 public BlockSlab()
 {
     Name = "Slab";
     Type = BlockData.Blocks.Slab;
     IsSolid = true;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.5, 1);
 }
Example #15
0
 public BlockYellowFlower()
 {
     Name = "YellowFlower";
     Type = BlockData.Blocks.Yellow_Flower;
     IsAir = true;
     IsSingleHit = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.3, 0, 0.3, 0.7, 0.6, 0.7);
 }
Example #16
0
 public BlockTallGrass()
 {
     Name = "TallGrass";
     Type = BlockData.Blocks.TallGrass;
     IsSingleHit = true;
     IsAir = true;
     IsSolid = true;
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.1, 0, 0.1, 0.9, 0.8, 0.9);
 }
Example #17
0
 public BlockTracks()
 {
     Name = "Tracks";
     Type = BlockData.Blocks.Tracks;
     IsAir = true;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #18
0
 public BlockWoodenPressurePlate()
 {
     Name = "WoodenPressurePlate";
     Type = BlockData.Blocks.Wooden_Pressure_Plate;
     IsAir = true;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.0625, 0, 0.0625, 0.9375, 0.0625, 0.9375);
 }
Example #19
0
 public BlockRedstoneRepeater()
 {
     Name = "RedstoneRepeater";
     Type = BlockData.Blocks.Redstone_Repeater;
     Opacity = 0x0;
     IsSolid = true;
     var item = ItemHelper.GetInstance(BlockData.Items.Redstone_Repeater);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #20
0
 public BlockPoweredRail()
 {
     Name = "PoweredRail";
     Type = BlockData.Blocks.PoweredRail;
     IsAir = true;
     Opacity = 0x0;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Example #21
0
 public BlockCactus()
 {
     Name = "Cactus";
     Type = BlockData.Blocks.Cactus;
     IsSolid = true;
     Opacity = 0x0;
     var item = ItemHelper.GetInstance((short)Type);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0.0625, 0, 0.0625, 0.9375, 0.9375, 0.9375);
 }
Example #22
0
 public BlockRedRose()
 {
     Name = "RedRose";
     Type = BlockData.Blocks.Red_Rose;
     IsAir = true;
     IsSingleHit = true;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.3, 0, 0.3, 0.7, 0.6, 0.7);
 }
Example #23
0
 public BlockYellowFlower()
 {
     Name = "YellowFlower";
     Type = BlockData.Blocks.Yellow_Flower;
     IsAir = true;
     IsSingleHit = true;
     var item = ItemHelper.GetInstance(Type);
     item.Count = 1;
     LootTable.Add(item);
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0.3, 0, 0.3, 0.7, 0.6, 0.7);
 }
Example #24
0
 public BlockRedstoneWire()
 {
     Name = "RedstoneWire";
     Type = BlockData.Blocks.Redstone_Wire;
     IsAir = true;
     IsSingleHit = true;
     var item = ItemHelper.GetInstance(BlockData.Items.Redstone);
     item.Count = 1;
     LootTable.Add(item);
     Opacity = 0x0;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.0625, 1);
 }
Example #25
0
 public BlockSoil()
 {
     Name = "Soil";
     Type = BlockData.Blocks.Soil;
     IsSolid = true;
     IsFertile = true;
     IsPlowed = true;
     var item = ItemHelper.GetInstance(BlockData.Blocks.Soil);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.9375, 1);
 }
Example #26
0
 public BlockReed()
 {
     Name = "Reed";
     Type = BlockData.Blocks.Reed;
     Opacity = 0x0;
     IsAir = true;
     IsSolid = true;
     IsSingleHit = true;
     IsWaterProof = true;
     var item = ItemHelper.GetInstance(BlockData.Items.Reeds);
     item.Count = 1;
     LootTable.Add(item);
     BlockBoundsOffset = new BoundingBox(0.125, 0, 0.125, 0.875, 1, 0.875);
 }
Example #27
0
 /// <summary>
 /// Base contructor
 /// </summary>
 protected BlockBase()
 {
     Name = "BaseBlock";
     Type = BlockData.Blocks.Air;
     IsAir = false;
     IsLiquid = false;
     Opacity = 0xf;
     IsSolid = false;
     IsSingleHit = false;
     IsFertile = false;
     IsPlowed = false;
     BurnEfficiency = 0;
     LootTable = new List<ItemStack>();
     Luminance = 0;
     IsWaterProof = false;
     Slipperiness = 0.6;
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 1, 1);
 }
Example #28
0
 public bool Equals(BoundingBox other)
 {
     return other._minimum.Equals(_minimum) && other._maximum.Equals(_maximum);
 }
Example #29
0
 /// <summary>
 /// Determines if this intersects with <paramref name="boundingBox"/>.
 /// </summary>
 /// <returns>
 /// If true the bounding boxes intersect
 /// </returns>
 /// <param name='boundingBox'>
 /// The bounding box to check for an intersection with
 /// </param>
 public bool IntersectsWith(BoundingBox boundingBox)
 {
     return boundingBox.Maximum.X > Minimum.X && boundingBox.Minimum.X < Maximum.X &&
            boundingBox.Maximum.Y > Minimum.Y && boundingBox.Minimum.Y < Maximum.Y &&
            boundingBox.Maximum.Z > Minimum.Z && boundingBox.Minimum.Z < Maximum.Z;
 }
Example #30
0
        /// <summary>
        /// Offsets the BoundingBox with motion, with clipping based on potential collisions.
        /// </summary>
        /// <returns>
        /// The BoundingBox in the new location after clipping, and set motion to the actual offset used after clipping is applied.
        /// </returns>
        /// <param name='motion'>
        /// Motion to be applied. The value will be changed to reflect the actual offset used after clipping is applied.
        /// </param>
        /// <param name='potentialCollisions'>
        /// Potential collisions.
        /// </param>
        public BoundingBox OffsetWithClipping(ref Vector3 motion, BoundingBox[] potentialCollisions)
        {
            if (potentialCollisions == null || potentialCollisions.Length == 0)
                return this + motion;

            BoundingBox offsetBB = this;

            // If there is Y movement, calculate new Y offset for collisions
            // Y is calculated first to adjust for jumping height/falling before applying restrictions on X and Z
            if (System.Math.Abs(motion.Y) >= double.Epsilon)
            {
                foreach (var collision in potentialCollisions)
                {
                    // If the collision is on the same X or Z axis, then adjust the Y movement
                    if (collision.IsVectorWithinXZ(offsetBB.Minimum) || collision.IsVectorWithinXZ(offsetBB.Maximum))
                    {
                        if (motion.Y > 0.0d && offsetBB.Maximum.Y <= collision.Minimum.Y)
                        {
                            motion.Y = System.Math.Min(motion.Y, collision.Minimum.Y - offsetBB.Maximum.Y);
                        }
                        else if (motion.Y < 0.0d && offsetBB.Minimum.Y >= collision.Maximum.Y)
                        {
                            motion.Y = System.Math.Max(motion.Y, collision.Maximum.Y - offsetBB.Minimum.Y);
                        }
                    }
                }

                offsetBB = offsetBB + new Vector3(0, motion.Y, 0);
            }

            // If there is an X movement, calculate new X offset for collisions
            if (System.Math.Abs(motion.X) >= double.Epsilon)
            {
                foreach (var collision in potentialCollisions)
                {
                    // If the collision is on the same Y or Z axis, then adjust the X movement
                    if (collision.IsVectorWithinYZ(offsetBB.Minimum) || collision.IsVectorWithinYZ(offsetBB.Maximum))
                    {
                        if (motion.X > 0.0d && offsetBB.Maximum.X <= collision.Minimum.X)
                        {
                            motion.X = System.Math.Min(motion.X, collision.Minimum.X - offsetBB.Maximum.X);
                        }
                        else if (motion.X < 0.0d && offsetBB.Minimum.X >= collision.Maximum.X)
                        {
                            motion.X = System.Math.Max(motion.X, collision.Maximum.X - offsetBB.Minimum.X);
                        }
                    }
                }

                offsetBB = offsetBB + new Vector3(motion.X, 0, 0);
            }

            // If there is any Z movement, calculate new Z offset based on any collisions
            if (System.Math.Abs(motion.Z) >= double.Epsilon)
            {
                foreach (var collision in potentialCollisions)
                {
                    // If the collision is on the same Y or Z axis, then adjust the X movement
                    if (collision.IsVectorWithinXY(offsetBB.Minimum) || collision.IsVectorWithinXY(offsetBB.Maximum))
                    {
                        if (motion.Z > 0.0d && offsetBB.Maximum.Z <= collision.Minimum.Z)
                        {
                            motion.Z = System.Math.Min(motion.Z, collision.Minimum.Z - offsetBB.Maximum.Z);
                        }
                        else if (motion.Z < 0.0d && offsetBB.Minimum.Z >= collision.Maximum.Z)
                        {
                            motion.Z = System.Math.Max(motion.Z, collision.Maximum.Z - offsetBB.Minimum.Z);
                        }
                    }
                }

                offsetBB = offsetBB + new Vector3(motion.X, 0, 0);
            }

            return offsetBB;
        }