Beispiel #1
0
        private bool isConnectedTo(MinecartTrackLogic minecarttracklogic)
        {
            for (int i = 0; i < connectedTracks.size(); i++)
            {
                var chunkposition = (ChunkPosition)connectedTracks.get(i);
                if (chunkposition.x == minecarttracklogic.trackX && chunkposition.z == minecarttracklogic.trackZ)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        private bool func_592_c(int i, int j, int k)
        {
            MinecartTrackLogic minecarttracklogic = getMinecartTrackLogic(new ChunkPosition(i, j, k));

            if (minecarttracklogic == null)
            {
                return(false);
            }
            else
            {
                minecarttracklogic.func_591_b();
                return(minecarttracklogic.handleKeyPress(this));
            }
        }
Beispiel #3
0
 private void func_591_b()
 {
     for (int i = 0; i < connectedTracks.size(); i++)
     {
         MinecartTrackLogic minecarttracklogic = getMinecartTrackLogic((ChunkPosition)connectedTracks.get(i));
         if (minecarttracklogic == null || !minecarttracklogic.isConnectedTo(this))
         {
             connectedTracks.remove(i--);
         }
         else
         {
             connectedTracks.set(i,
                                 new ChunkPosition(minecarttracklogic.trackX, minecarttracklogic.trackY,
                                                   minecarttracklogic.trackZ));
         }
     }
 }
Beispiel #4
0
        private bool handleKeyPress(MinecartTrackLogic minecarttracklogic)
        {
            if (isConnectedTo(minecarttracklogic))
            {
                return(true);
            }
            if (connectedTracks.size() == 2)
            {
                return(false);
            }
            if (connectedTracks.size() == 0)
            {
                return(true);
            }
            var chunkposition = (ChunkPosition)connectedTracks.get(0);

            return(minecarttracklogic.trackY != trackY || chunkposition.y != trackY ? true : true);
        }
Beispiel #5
0
        public override void onNeighborBlockChange(World world, int i, int j, int k, int l)
        {
            if (world.singleplayerWorld)
            {
                return;
            }
            int  i1   = world.getBlockMetadata(i, j, k);
            bool flag = false;

            if (!world.isBlockOpaqueCube(i, j - 1, k))
            {
                flag = true;
            }
            if (i1 == 2 && !world.isBlockOpaqueCube(i + 1, j, k))
            {
                flag = true;
            }
            if (i1 == 3 && !world.isBlockOpaqueCube(i - 1, j, k))
            {
                flag = true;
            }
            if (i1 == 4 && !world.isBlockOpaqueCube(i, j, k - 1))
            {
                flag = true;
            }
            if (i1 == 5 && !world.isBlockOpaqueCube(i, j, k + 1))
            {
                flag = true;
            }
            if (flag)
            {
                dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
                world.setBlockWithNotify(i, j, k, 0);
            }
            else if (l > 0 && blocksList[l].canProvidePower() &&
                     MinecartTrackLogic.getNAdjacentTracks(new MinecartTrackLogic(this, world, i, j, k)) == 3)
            {
                func_4038_g(world, i, j, k);
            }
        }
Beispiel #6
0
        private bool isConnectedTo(MinecartTrackLogic minecarttracklogic)
        {
            for (int i = 0; i < connectedTracks.size(); i++)
            {
                var chunkposition = (ChunkPosition) connectedTracks.get(i);
                if (chunkposition.x == minecarttracklogic.trackX && chunkposition.z == minecarttracklogic.trackZ)
                {
                    return true;
                }
            }

            return false;
        }
Beispiel #7
0
 private bool handleKeyPress(MinecartTrackLogic minecarttracklogic)
 {
     if (isConnectedTo(minecarttracklogic))
     {
         return true;
     }
     if (connectedTracks.size() == 2)
     {
         return false;
     }
     if (connectedTracks.size() == 0)
     {
         return true;
     }
     var chunkposition = (ChunkPosition) connectedTracks.get(0);
     return minecarttracklogic.trackY != trackY || chunkposition.y != trackY ? true : true;
 }
Beispiel #8
0
 public static int getNAdjacentTracks(MinecartTrackLogic minecarttracklogic)
 {
     return minecarttracklogic.getAdjacentTracks();
 }
Beispiel #9
0
 private void func_598_d(MinecartTrackLogic minecarttracklogic)
 {
     connectedTracks.add(new ChunkPosition(minecarttracklogic.trackX, minecarttracklogic.trackY,
                                           minecarttracklogic.trackZ));
     bool flag = func_599_b(trackX, trackY, trackZ - 1);
     bool flag1 = func_599_b(trackX, trackY, trackZ + 1);
     bool flag2 = func_599_b(trackX - 1, trackY, trackZ);
     bool flag3 = func_599_b(trackX + 1, trackY, trackZ);
     sbyte byte0 = -1;
     if (flag || flag1)
     {
         byte0 = 0;
     }
     if (flag2 || flag3)
     {
         byte0 = 1;
     }
     if (flag1 && flag3 && !flag && !flag2)
     {
         byte0 = 6;
     }
     if (flag1 && flag2 && !flag && !flag3)
     {
         byte0 = 7;
     }
     if (flag && flag2 && !flag1 && !flag3)
     {
         byte0 = 8;
     }
     if (flag && flag3 && !flag1 && !flag2)
     {
         byte0 = 9;
     }
     if (byte0 == 0)
     {
         if (worldObj.getBlockId(trackX, trackY + 1, trackZ - 1) == minecartTrack.blockID)
         {
             byte0 = 4;
         }
         if (worldObj.getBlockId(trackX, trackY + 1, trackZ + 1) == minecartTrack.blockID)
         {
             byte0 = 5;
         }
     }
     if (byte0 == 1)
     {
         if (worldObj.getBlockId(trackX + 1, trackY + 1, trackZ) == minecartTrack.blockID)
         {
             byte0 = 2;
         }
         if (worldObj.getBlockId(trackX - 1, trackY + 1, trackZ) == minecartTrack.blockID)
         {
             byte0 = 3;
         }
     }
     if (byte0 < 0)
     {
         byte0 = 0;
     }
     worldObj.setBlockMetadataWithNotify(trackX, trackY, trackZ, byte0);
 }
Beispiel #10
0
 public static int getNAdjacentTracks(MinecartTrackLogic minecarttracklogic)
 {
     return(minecarttracklogic.getAdjacentTracks());
 }
Beispiel #11
0
        public void func_596_a(bool flag)
        {
            bool flag1 = func_592_c(trackX, trackY, trackZ - 1);
            bool flag2 = func_592_c(trackX, trackY, trackZ + 1);
            bool flag3 = func_592_c(trackX - 1, trackY, trackZ);
            bool flag4 = func_592_c(trackX + 1, trackY, trackZ);
            int  i     = -1;

            if ((flag1 || flag2) && !flag3 && !flag4)
            {
                i = 0;
            }
            if ((flag3 || flag4) && !flag1 && !flag2)
            {
                i = 1;
            }
            if (flag2 && flag4 && !flag1 && !flag3)
            {
                i = 6;
            }
            if (flag2 && flag3 && !flag1 && !flag4)
            {
                i = 7;
            }
            if (flag1 && flag3 && !flag2 && !flag4)
            {
                i = 8;
            }
            if (flag1 && flag4 && !flag2 && !flag3)
            {
                i = 9;
            }
            if (i == -1)
            {
                if (flag1 || flag2)
                {
                    i = 0;
                }
                if (flag3 || flag4)
                {
                    i = 1;
                }
                if (flag)
                {
                    if (flag2 && flag4)
                    {
                        i = 6;
                    }
                    if (flag3 && flag2)
                    {
                        i = 7;
                    }
                    if (flag4 && flag1)
                    {
                        i = 9;
                    }
                    if (flag1 && flag3)
                    {
                        i = 8;
                    }
                }
                else
                {
                    if (flag1 && flag3)
                    {
                        i = 8;
                    }
                    if (flag4 && flag1)
                    {
                        i = 9;
                    }
                    if (flag3 && flag2)
                    {
                        i = 7;
                    }
                    if (flag2 && flag4)
                    {
                        i = 6;
                    }
                }
            }
            if (i == 0)
            {
                if (worldObj.getBlockId(trackX, trackY + 1, trackZ - 1) == minecartTrack.blockID)
                {
                    i = 4;
                }
                if (worldObj.getBlockId(trackX, trackY + 1, trackZ + 1) == minecartTrack.blockID)
                {
                    i = 5;
                }
            }
            if (i == 1)
            {
                if (worldObj.getBlockId(trackX + 1, trackY + 1, trackZ) == minecartTrack.blockID)
                {
                    i = 2;
                }
                if (worldObj.getBlockId(trackX - 1, trackY + 1, trackZ) == minecartTrack.blockID)
                {
                    i = 3;
                }
            }
            if (i < 0)
            {
                i = 0;
            }
            trackMetadata = i;
            calculateConnectedTracks();
            worldObj.setBlockMetadataWithNotify(trackX, trackY, trackZ, i);
            for (int j = 0; j < connectedTracks.size(); j++)
            {
                MinecartTrackLogic minecarttracklogic = getMinecartTrackLogic((ChunkPosition)connectedTracks.get(j));
                if (minecarttracklogic == null)
                {
                    continue;
                }
                minecarttracklogic.func_591_b();
                if (minecarttracklogic.handleKeyPress(this))
                {
                    minecarttracklogic.func_598_d(this);
                }
            }
        }
Beispiel #12
0
        private void func_598_d(MinecartTrackLogic minecarttracklogic)
        {
            connectedTracks.add(new ChunkPosition(minecarttracklogic.trackX, minecarttracklogic.trackY,
                                                  minecarttracklogic.trackZ));
            bool  flag  = func_599_b(trackX, trackY, trackZ - 1);
            bool  flag1 = func_599_b(trackX, trackY, trackZ + 1);
            bool  flag2 = func_599_b(trackX - 1, trackY, trackZ);
            bool  flag3 = func_599_b(trackX + 1, trackY, trackZ);
            sbyte byte0 = -1;

            if (flag || flag1)
            {
                byte0 = 0;
            }
            if (flag2 || flag3)
            {
                byte0 = 1;
            }
            if (flag1 && flag3 && !flag && !flag2)
            {
                byte0 = 6;
            }
            if (flag1 && flag2 && !flag && !flag3)
            {
                byte0 = 7;
            }
            if (flag && flag2 && !flag1 && !flag3)
            {
                byte0 = 8;
            }
            if (flag && flag3 && !flag1 && !flag2)
            {
                byte0 = 9;
            }
            if (byte0 == 0)
            {
                if (worldObj.getBlockId(trackX, trackY + 1, trackZ - 1) == minecartTrack.blockID)
                {
                    byte0 = 4;
                }
                if (worldObj.getBlockId(trackX, trackY + 1, trackZ + 1) == minecartTrack.blockID)
                {
                    byte0 = 5;
                }
            }
            if (byte0 == 1)
            {
                if (worldObj.getBlockId(trackX + 1, trackY + 1, trackZ) == minecartTrack.blockID)
                {
                    byte0 = 2;
                }
                if (worldObj.getBlockId(trackX - 1, trackY + 1, trackZ) == minecartTrack.blockID)
                {
                    byte0 = 3;
                }
            }
            if (byte0 < 0)
            {
                byte0 = 0;
            }
            worldObj.setBlockMetadataWithNotify(trackX, trackY, trackZ, byte0);
        }