public Chunk(ChunkPos pos, World world) { Pos = pos; World = world; _loadManager = World.LoadManager; BoundingBox = new AxisAlignedBB(Vector3.Zero, Vector3.One * ChunkSize + Vector3.UnitY * 240).offset(Pos.ToVec()); }
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.IsSolid) { continue; } blocks.Add(state.Block.BoundingBox.offset(pos.ToVec())); } } } return(blocks); }
public float CalculateXOffset(AxisAlignedBB bb, float x) { if (bb.Size.Y <= this.Position.Y || bb.Position.Y >= this.Size.Y) { return(x); } if (bb.Size.Z <= this.Position.Z || bb.Position.Z >= this.Size.Z) { return(x); } if (x > 0 && bb.Size.X <= this.Position.X) { float x1 = this.Position.X - bb.Size.X; if (x1 < x) { x = x1; } } else if (x < 0 && bb.Position.X >= this.Size.X) { float x2 = this.Size.X - bb.Position.X; if (x2 > x) { x = x2; } } return(x); }
/// <summary> /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been /// cleared to be reused) /// </summary> public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { bool flag = CanConnectFenceTo(par1World, par2, par3, par4 - 1); bool flag1 = CanConnectFenceTo(par1World, par2, par3, par4 + 1); bool flag2 = CanConnectFenceTo(par1World, par2 - 1, par3, par4); bool flag3 = CanConnectFenceTo(par1World, par2 + 1, par3, par4); float f = 0.375F; float f1 = 0.625F; float f2 = 0.375F; float f3 = 0.625F; if (flag) { f2 = 0.0F; } if (flag1) { f3 = 1.0F; } if (flag2) { f = 0.0F; } if (flag3) { f1 = 1.0F; } return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + f, par3, (float)par4 + f2, (float)par2 + f1, (float)par3 + 1.5F, (float)par4 + f3)); }
public float CalculateYOffset(AxisAlignedBB bb, float y) { if (bb.Size.X <= this.Position.X || bb.Position.X >= this.Size.X) { return(y); } if (bb.Size.Z <= this.Position.Z || bb.Position.Z >= this.Size.Z) { return(y); } if (y > 0 && bb.Size.Y <= this.Position.Y) { float y1 = this.Position.Y - bb.Size.Y; if (y1 < y) { y = y1; } } else if (y < 0 && bb.Position.Y >= this.Size.Y) { float y2 = this.Size.Y - bb.Position.Y; if (y2 > y) { y = y2; } } return(y); }
private Block(int id = 0, bool isTransparent = false) { ShouldRender = true; ID = id; IsTransparent = isTransparent; BoundingBox = new AxisAlignedBB(); }
public float CalculateZOffset(AxisAlignedBB bb, float z) { if (bb.Size.X <= this.Position.X || bb.Position.X >= this.Size.X) { return(z); } if (bb.Size.Y <= this.Position.Y || bb.Position.Y >= this.Size.Y) { return(z); } if (z > 0 && bb.Size.Z <= this.Position.Z) { float z1 = this.Position.Z - bb.Size.Z; if (z1 < z) { z = z1; } } else if (z < 0 && bb.Position.Z >= this.Size.Z) { float z2 = this.Size.Z - bb.Position.Z; if (z2 > z) { z = z2; } } return(z); }
public BlockLadder() : base("ladder") { IsFullCube = false; BoundingBox = new AxisAlignedBB(0, 0, 0.8f, 1, 1, 1); Hardness = 32; }
public BlockTallGrass() : base("tallgrass") { IsFullCube = false; IsSolid = false; IsReplaceable = true; BoundingBox = new AxisAlignedBB(0.85f).offset(new Vector3(0.075f, 0, 0.075f)); Hardness = 0; }
public bool IntersectsWith(AxisAlignedBB bb, float epsilon = 0.00001f) { if (bb.Size.X - this.Position.X > epsilon && this.Size.X - bb.Position.X > epsilon) { if (bb.Size.Y - this.Position.Y > epsilon && this.Size.Y - bb.Position.Y > epsilon) { return(bb.Size.Z - this.Position.Z > epsilon && this.Size.Z - bb.Position.Z > epsilon); } } return(false); }
public void TestMethod() { AxisAlignedBB box = new AxisAlignedBB(Vector3.Zero, Vector3.One); Console.WriteLine(box.Center); Assert.IsFalse(box.ContainsVector(new Vector3(1f, 2f, 1f))); Assert.IsTrue(box.ContainsVector(new Vector3(1f, 0.5f, 1f))); Assert.IsTrue(box.ContainsVector(new Vector3(1f, 1f, 1f))); Assert.IsFalse(box.ContainsVector(new Vector3(1f, 1.1f, 1f))); }
private void doTick() { var arraylist = new ArrayList(); for (Iterator iterator = field_6037_b.keySet().iterator(); iterator.hasNext();) { var s = (string)iterator.next(); int k = ((Integer)field_6037_b.get(s)).intValue(); if (k > 0) { field_6037_b.put(s, Integer.valueOf(k - 1)); } else { arraylist.add(s); } } for (int i = 0; i < arraylist.size(); i++) { field_6037_b.remove(arraylist.get(i)); } AxisAlignedBB.clearBoundingBoxPool(); Vec3D.initialize(); deathTime++; if (deathTime % 20 == 0) { configManager.sendPacketToAllPlayers(new Packet4UpdateTime(worldMngr.getWorldTime())); } worldMngr.tick(); while (worldMngr.func_6156_d()) { ; } worldMngr.updateEntities(); networkServer.func_715_a(); configManager.func_637_b(); entityTracker.updateTrackedEntities(); for (int j = 0; j < field_9010_p.size(); j++) { ((IUpdatePlayerListBox)field_9010_p.get(j)).update(); } try { commandLineParser(); } catch (java.lang.Exception exception) { logger.log(Level.WARNING, "Unexpected exception while parsing console command", exception); } }
public BlockSlab() : base("slab") { IsFullCube = false; var size = Vector3.One; size.Y = 0.5f; BoundingBox = new AxisAlignedBB(size); Hardness = 64; //TODO - set based on the state }
public Entity() { PreviousPosition = new Vector3(); Position = new Vector3(0, 0, 0); LastTickPosition = new Vector3(); Velocity = new Vector3(); Rotation = new Vector3(); Scale = new Vector3(1, 1, 1); Height = Scale.Y; Width = Scale.X; BoundingBox = new AxisAlignedBB(); BoundingBox.SetFromCenter(Position, Scale); BoundingBox.Offset(0, (-Height) / 8, 0); }
public Block(World world, BlockLocation location, int id = 1, bool isTransparent = false) { ShouldRender = true; World = world; Location = location; ID = id; //Hardness = hardness; //Resistance = resistance; IsTransparent = isTransparent; if (location.Chunk != null) { BlockLocation blockLocation = GridLatch.GetBlockOffsetByChunk(location, location.Chunk.Location); BoundingBox = new AxisAlignedBB(blockLocation); } }
protected Particle(World world, Vector3 pos, Vector3 motion, float scale, int textureID, Vector2 UVmin, Vector2 UVmax) : base(world, pos, motion) { lastParticleScale = particleScale = scale / 10; this.textureID = textureID; this.UVmin = UVmin; this.UVmax = UVmax; collisionBoundingBox = new AxisAlignedBB(particleScale); boundingBox = collisionBoundingBox.offset(pos - (Vector3.UnitX * collisionBoundingBox.size.X / 2 + Vector3.UnitZ * collisionBoundingBox.size.Z / 2)); particleMaxAge = (int)MathUtil.NextFloat(10, 50); gravity = 0.9f; }
/// <summary> /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been /// cleared to be reused) /// </summary> public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { int i = par1World.GetBlockMetadata(par2, par3, par4); if (IsFenceGateOpen(i)) { return(null); } if (i == 2 || i == 0) { return(AxisAlignedBB.GetBoundingBoxFromPool(par2, par3, (float)par4 + 0.375F, par2 + 1, (float)par3 + 1.5F, (float)par4 + 0.625F)); } else { return(AxisAlignedBB.GetBoundingBoxFromPool((float)par2 + 0.375F, par3, par4, (float)par2 + 0.625F, (float)par3 + 1.5F, par4 + 1)); } }
public AxisAlignedBB[] GetCollisionCubes(Entity entity, AxisAlignedBB bb, bool entities = true) { List <AxisAlignedBB> collides = new List <AxisAlignedBB>(); int minX = (int)Math.Floor(bb.Position.X - 1); int minY = (int)Math.Floor(bb.Position.Y - 1); int minZ = (int)Math.Floor(bb.Position.Z - 1); int maxX = (int)Math.Floor(bb.Size.X + 1); int maxY = (int)Math.Floor(bb.Size.Y + 1); int maxZ = (int)Math.Floor(bb.Size.Z + 1); for (int z = minZ; z <= maxZ; ++z) { for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { Block block = this.GetBlock(x, y, z); //if (block.CanPassThrough()) AxisAlignedBB[] boundingBoxes = block.GetCollisionBoxes(); for (int i = 0; i < boundingBoxes.Length; ++i) { if (boundingBoxes[i].IntersectsWith(bb)) { collides.Add(boundingBoxes[i]); } } } } } if (entities) { Entity[] boundEntities = this.GetCollidingEntities(bb.Expand(0.25f, 0.25f, 0.25f), entity); for (int i = 0; i < boundEntities.Length; ++i) { collides.Add(boundEntities[i].BoundingBox); } } return(collides.ToArray()); }
public Entity[] GetCollidingEntities(AxisAlignedBB bb, Entity entity = null) { List <Entity> nearby = new List <Entity>(); if (entity == null) //TODO : if (entity == null || entity.CanCollide) { int minX = (int)Math.Floor(bb.Position.X - 2) >> 4; int minZ = (int)Math.Floor(bb.Position.Z - 2) >> 4; int maxX = (int)Math.Floor(bb.Size.X + 2) >> 4; int maxZ = (int)Math.Floor(bb.Size.Z + 2) >> 4; for (int x = minX; x <= maxX; ++x) { for (int z = minZ; z <= maxZ; ++z) { //TODO } } } return(nearby.ToArray()); }
public override AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { return(AxisAlignedBB.getBoundingBoxFromPool(i, j, k, i + 1, j + 1.5F, k + 1)); }
/// <summary> /// Returns true if the bounding box is inside all 6 clipping planes, otherwise returns false. /// </summary> public virtual bool IsBoundingBoxInFrustum(AxisAlignedBB par1AxisAlignedBB) { return(IsBoxInFrustum(par1AxisAlignedBB.MinX, par1AxisAlignedBB.MinY, par1AxisAlignedBB.MinZ, par1AxisAlignedBB.MaxX, par1AxisAlignedBB.MaxY, par1AxisAlignedBB.MaxZ)); }
/// <summary> /// Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been /// cleared to be reused) /// </summary> public override AxisAlignedBB GetCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return(AxisAlignedBB.GetBoundingBoxFromPool(par2 + MinX, par3 + MinY, par4 + MinZ, par2 + MaxX, par3 + MaxY, par4 + MaxZ)); }
public override AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { float f = 0.125F; return(AxisAlignedBB.getBoundingBoxFromPool(i, j, k, i + 1, (j + 1) - f, k + 1)); }
public GameStatePlay(string playerSkin) { _backColor = new Color4(0.6f, 0.8f, 0.85f, 1f); // SHADERS RETRIEVING *********************************************************** // _flatColorShader = ShaderManager.Get("FlatColorShader"); _baseShader = ShaderManager.Get("Shader"); _3dSpriteShader = ShaderManager.Get("SpriteSheet"); // FONT RETRIEVING ************************************************************** // _font = FontManager.Get("glyphs"); // TEXT INITIALISATION ********************************************************** // _scoreText = new Text(new Vector2(13, 30), _font, _flatColorShader, "Test"); var x = ((24 / 32f) * 1.7f) / 2; var u = 24.0f / 240; _playerMesh = new Object3D(new[] { new Mesh { Vertices = new List <Vertex> { new Vertex(new Vector3(-x, 1.7f, 0f), new Vector2(0, 0)), new Vertex(new Vector3(-x, 0f, 0f), new Vector2(0, 1)), new Vertex(new Vector3(x, 1.7f, 0f), new Vector2(u, 0)), new Vertex(new Vector3(x, 1.7f, 0f), new Vector2(u, 0)), new Vertex(new Vector3(-x, 0f, 0f), new Vector2(0, 1)), new Vertex(new Vector3(x, 0f, 0f), new Vector2(u, 1)), } } }); _playerMesh.LoadInGl(_3dSpriteShader); // TEXTURES INITIALISATION ****************************************************** // _playerSpriteSheet = new SpriteSheet(_playerMesh, playerSkin, 24, 32, TextureMinFilter.Nearest, TextureMagFilter.Nearest); // MESH INITIALISATION ********************************************************** // _groundMesh = new Object3D("wall.obj", false, false, true); _groundMesh.LoadInGl(_baseShader); GroundSimple.MeshToUse = _groundMesh; _groundStairsMesh = new Object3D("stairs.obj", false, false, true); _groundStairsMesh.LoadInGl(_baseShader); GroundStairs.MeshToUse = _groundStairsMesh; _groundClusterMesh = new Object3D("cluster.obj", false, false, true); _groundClusterMesh.LoadInGl(_baseShader); GroundCluster.MeshToUse = _groundClusterMesh; _cubeMesh = new Object3D("cube.obj", false, false, false); _cubeMesh.LoadInGl(_baseShader); AxisAlignedBB.SetMesh(_cubeMesh); _interLeftMesh = new Object3D("inter_l.obj", false, false, true); _interLeftMesh.LoadInGl(_baseShader); Intersection.Left_Mesh = _interLeftMesh; _interRightMesh = new Object3D("inter_r.obj", false, false, true); _interRightMesh.LoadInGl(_baseShader); Intersection.Right_Mesh = _interRightMesh; _interLeftRightMesh = new Object3D("inter_lr.obj", false, false, true); _interLeftRightMesh.LoadInGl(_baseShader); Intersection.LeftRight_Mesh = _interLeftRightMesh; _trashMesh = new Object3D("trash.obj", false, false, true); _trashMesh.LoadInGl(_baseShader); ObstacleTrash.MeshToUse = _trashMesh; _coinMesh = new Object3D("coin.obj", false, false, true); _coinMesh.LoadInGl(_baseShader); Coin.MeshToUse = _coinMesh; // WORLD INITIALISATION ********************************************************* // _world = new World(); // PLAYER INITIALISATION ******************************************************** // _player = new Player { World = _world, Position = new Vector3(0, 0, -3f), Speed = 12.5f }; _camera = new Camera(new Vector3(0, 2f, 2f), _player.PositionForCamera + new Vector3(0, 2.5f, 0), (float)(80f * (Math.PI / 180f))); // TERRAIN GENERATION *********************************************************** // var tilesToGenerate = 10; for (int i = 0; i < tilesToGenerate; i++) { _world.Grounds.Add(new Ground { BoundingBox = new AxisAlignedBB(new Vector3(-3f, -0.5f, -6f), new Vector3(3f, 0f, 0f)), Mesh = _groundMesh, Position = new Vector3(0, 0, -6f * i), Direction = Direction.NORTH }); } var intersection = GroundFactory.NewIntersection(_player, _world, new Vector3(0, 0, -6f * tilesToGenerate), Direction.NORTH, (int)Intersection.IntersectionDirection.LEFT); _world.Grounds.Add(intersection); var rotation = DirectionHelper.GetRotationFromDirection(Direction.NORTH); var w1p1 = new Vector3(new Vector4(-3f, 0f, -7f, 1) * rotation); var w1p2 = new Vector3(new Vector4(3f, 5f, -6f, 1) * rotation); _world.Obstacles.Add(new Obstacle(new AxisAlignedBB(Vector3.ComponentMin(w1p1, w1p2), Vector3.ComponentMax(w1p1, w1p2)), intersection.Position, Direction.NORTH)); var w2p1 = new Vector3(new Vector4(3f, 0f, -6f, 1) * rotation); var w2p2 = new Vector3(new Vector4(4f, 5f, 0f, 1) * rotation); _world.Obstacles.Add(new Obstacle(new AxisAlignedBB(Vector3.ComponentMin(w2p1, w2p2), Vector3.ComponentMax(w2p1, w2p2)), intersection.Position, Direction.NORTH)); GC.Collect(); GC.WaitForPendingFinalizers(); }
public List <AxisAlignedBB> GetIntersectingEntitiesBBs(AxisAlignedBB with) { return((from entity in Entities where !(entity is EntityItem) select entity.GetEntityBoundingBox() into bb where bb.IntersectsWith(with) select bb).ToList()); }
/// <summary> /// Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count /// ticks and creates a new spawn inside its implementation. /// </summary> public override void UpdateEntity() { Yaw2 = Yaw; if (!AnyPlayerInRange()) { return; } double d = (float)XCoord + WorldObj.Rand.NextFloat(); double d1 = (float)YCoord + WorldObj.Rand.NextFloat(); double d2 = (float)ZCoord + WorldObj.Rand.NextFloat(); WorldObj.SpawnParticle("smoke", d, d1, d2, 0.0F, 0.0F, 0.0F); WorldObj.SpawnParticle("flame", d, d1, d2, 0.0F, 0.0F, 0.0F); for (Yaw += 1000F / ((float)Delay + 200F); Yaw > 360D;) { Yaw -= 360D; Yaw2 -= 360D; } if (!WorldObj.IsRemote) { if (Delay == -1) { UpdateDelay(); } if (Delay > 0) { Delay--; return; } sbyte byte0 = 4; for (int i = 0; i < byte0; i++) { EntityLiving entityliving = (EntityLiving)EntityList.CreateEntityByName(MobID, WorldObj); if (entityliving == null) { return; } int j = WorldObj.GetEntitiesWithinAABB(entityliving.GetType(), AxisAlignedBB.GetBoundingBoxFromPool(XCoord, YCoord, ZCoord, XCoord + 1, YCoord + 1, ZCoord + 1).Expand(8F, 4F, 8F)).Count; if (j >= 6) { UpdateDelay(); return; } if (entityliving == null) { continue; } float d3 = XCoord + (WorldObj.Rand.NextFloat() - WorldObj.Rand.NextFloat()) * 4F; float d4 = (YCoord + WorldObj.Rand.Next(3)) - 1; float d5 = ZCoord + (WorldObj.Rand.NextFloat() - WorldObj.Rand.NextFloat()) * 4F; entityliving.SetLocationAndAngles(d3, d4, d5, WorldObj.Rand.NextFloat() * 360F, 0.0F); if (entityliving.GetCanSpawnHere()) { WorldObj.SpawnEntityInWorld(entityliving); WorldObj.PlayAuxSFX(2004, XCoord, YCoord, ZCoord, 0); entityliving.SpawnExplosionParticle(); UpdateDelay(); } } } base.UpdateEntity(); }
public void GetMouseOverObject() { if (World == null) { return; } float radius = 5.5f; MouseOverObject final = new MouseOverObject(); float dist = float.MaxValue; Vector3 camPos = Vector3.One * 0.5f + Camera.pos; var air = BlockRegistry.GetBlock <BlockAir>(); for (float z = -radius; z <= radius; z++) { for (float y = -radius; y <= radius; y++) { for (float x = -radius; x <= radius; x++) { Vector3 vec = camPos; vec.X += x; vec.Y += y; vec.Z += z; float f = (vec - Camera.pos).LengthFast; if (f <= radius + 0.5f) { BlockPos pos = new BlockPos(vec); BlockState state = World.GetBlockState(pos); if (state.Block != air) { AxisAlignedBB bb = state.Block.BoundingBox.offset(pos.ToVec()); bool hitSomething = RayHelper.RayIntersectsBB(Camera.pos, Camera.GetLookVec(), bb, out Vector3 hitPos, out Vector3 normal); if (hitSomething) { FaceSides sideHit = FaceSides.Null; if (normal.X < 0) { sideHit = FaceSides.West; } else if (normal.X > 0) { sideHit = FaceSides.East; } if (normal.Y < 0) { sideHit = FaceSides.Down; } else if (normal.Y > 0) { sideHit = FaceSides.Up; } if (normal.Z < 0) { sideHit = FaceSides.North; } else if (normal.Z > 0) { sideHit = FaceSides.South; } BlockPos p = new BlockPos(hitPos - normal * bb.size / 2); if (sideHit == FaceSides.Null) { continue; } float l = Math.Abs((Camera.pos - (p.ToVec() + bb.size / 2)).Length); if (l < dist) { dist = l; final.hit = HitType.Block; final.hitVec = hitPos; final.blockPos = p; final.normal = normal; final.sideHit = sideHit; final.boundingBox = bb; } } } } } } } MouseOverObject = final; }
public static bool RayIntersectsBB(Vector3 /*ray*/ origin, Vector3 /*ray*/ direction, AxisAlignedBB bb, out Vector3 hitPosition, out Vector3 hitNormal) { direction = direction.Normalized(); hitNormal = Vector3.One.Normalized(); hitPosition = Vector3.Zero; float tmin, tmax, tymin, tymax, tzmin, tzmax; Vector3 invrd = direction; invrd.X = 1.0f / invrd.X; invrd.Y = 1.0f / invrd.Y; invrd.Z = 1.0f / invrd.Z; if (invrd.X >= 0.0f) { tmin = (bb.min.X - origin.X) * invrd.X; tmax = (bb.max.X - origin.X) * invrd.X; } else { tmin = (bb.max.X - origin.X) * invrd.X; tmax = (bb.min.X - origin.X) * invrd.X; } if (invrd.Y >= 0.0f) { tymin = (bb.min.Y - origin.Y) * invrd.Y; tymax = (bb.max.Y - origin.Y) * invrd.Y; } else { tymin = (bb.max.Y - origin.Y) * invrd.Y; tymax = (bb.min.Y - origin.Y) * invrd.Y; } if (tmin > tymax || tymin > tmax) { return(false); } if (tymin > tmin) { tmin = tymin; } if (tymax < tmax) { tmax = tymax; } if (invrd.Z >= 0.0f) { tzmin = (bb.min.Z - origin.Z) * invrd.Z; tzmax = (bb.max.Z - origin.Z) * invrd.Z; } else { tzmin = (bb.max.Z - origin.Z) * invrd.Z; tzmax = (bb.min.Z - origin.Z) * invrd.Z; } if (tmin > tzmax || tzmin > tmax) { return(false); } if (tzmin > tmin) { tmin = tzmin; } if (tzmax < tmax) { tmax = tzmax; } if (tmin < 0) { tmin = tmax; } if (tmax < 0) { return(false); } float t = tmin; hitPosition = origin + t * direction; Vector3 AABBCenter = (bb.min + bb.max) * 0.5f; Vector3 dir = hitPosition - AABBCenter; Vector3 width = bb.max - bb.min; width.X = Math.Abs(width.X); width.Y = Math.Abs(width.Y); width.Z = Math.Abs(width.Z); Vector3 ratio = Vector3.One; ratio.X = Math.Abs(dir.X / width.X); ratio.Y = Math.Abs(dir.Y / width.Y); ratio.Z = Math.Abs(dir.Z / width.Z); hitNormal = Vector3.Zero; int maxDir = 0; // x if (ratio.X >= ratio.Y && ratio.X >= ratio.Z) { // x is the greatest maxDir = 0; } else if (ratio.Y >= ratio.X && ratio.Y >= ratio.Z) { // y is the greatest maxDir = 1; } else if (ratio.Z >= ratio.X && ratio.Z >= ratio.Y) { // z is the greatest maxDir = 2; } if (dir[maxDir] > 0) { hitNormal[maxDir] = 1.0f; } else { hitNormal[maxDir] = -1.0f; } return(true); }
public AxisAlignedBB SetBB(AxisAlignedBB bb) { return(this.SetBounds(bb.Position.X, bb.Position.Y, bb.Position.Z, bb.Size.X, bb.Size.Y, bb.Size.Z)); }
public override void updateEntity() { yaw2 = yaw; if (!anyPlayerInRange()) { return; } double d = xCoord + worldObj.rand.nextFloat(); double d2 = yCoord + worldObj.rand.nextFloat(); double d4 = zCoord + worldObj.rand.nextFloat(); worldObj.spawnParticle("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", d, d2, d4, 0.0D, 0.0D, 0.0D); for (yaw += 1000F / (delay + 200F); yaw > 360D;) { yaw -= 360D; yaw2 -= 360D; } if (delay == -1) { updateDelay(); } if (delay > 0) { delay--; return; } byte byte0 = 4; for (int i = 0; i < byte0; i++) { var entityliving = (EntityLiving)EntityList.createEntityInWorld(mobID, worldObj); if (entityliving == null) { return; } int j = worldObj.getEntitiesWithinAABB(entityliving.GetType(), AxisAlignedBB.getBoundingBoxFromPool(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(8D, 4D, 8D)). size(); if (j >= 6) { updateDelay(); return; } if (entityliving == null) { continue; } double d6 = xCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D; double d7 = (yCoord + worldObj.rand.nextInt(3)) - 1; double d8 = zCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * 4D; entityliving.setLocationAndAngles(d6, d7, d8, worldObj.rand.nextFloat() * 360F, 0.0F); if (!entityliving.getCanSpawnHere()) { continue; } worldObj.entityJoinedWorld(entityliving); for (int k = 0; k < 20; k++) { double d1 = xCoord + 0.5D + (worldObj.rand.nextFloat() - 0.5D) * 2D; double d3 = yCoord + 0.5D + (worldObj.rand.nextFloat() - 0.5D) * 2D; double d5 = zCoord + 0.5D + (worldObj.rand.nextFloat() - 0.5D) * 2D; worldObj.spawnParticle("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D); } entityliving.spawnExplosionParticle(); updateDelay(); } base.updateEntity(); }