コード例 #1
0
 public override void DropBlockAsItemWithChance(net.minecraft.src.World world, int
                                                i, int j, int k, int l, float f)
 {
     if (world.singleplayerWorld)
     {
         return;
     }
     net.minecraft.src.TileEntityPiston tileentitypiston = GetTileEntityAtLocation(world
                                                                                   , i, j, k);
     if (tileentitypiston == null)
     {
         return;
     }
     else
     {
         net.minecraft.src.Block.blocksList[tileentitypiston.GetStoredBlockID()].DropBlockAsItem
             (world, i, j, k, tileentitypiston.Func_31005_e());
         return;
     }
 }
コード例 #2
0
        public override void PlayBlock(net.minecraft.src.World world, int i, int j, int k
                                       , int l, int i1)
        {
            ignoreUpdates = true;
            int j1 = i1;

            if (l == 0)
            {
                if (TryExtend(world, i, j, k, j1))
                {
                    world.SetBlockMetadataWithNotify(i, j, k, j1 | 8);
                    world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "tile.piston.out"
                                          , 0.5F, world.rand.NextFloat() * 0.25F + 0.6F);
                }
            }
            else
            {
                if (l == 1)
                {
                    net.minecraft.src.TileEntity tileentity = world.GetBlockTileEntity(i + net.minecraft.src.PistonBlockTextures
                                                                                       .field_31051_b[j1], j + net.minecraft.src.PistonBlockTextures.field_31054_c[j1],
                                                                                       k + net.minecraft.src.PistonBlockTextures.field_31053_d[j1]);
                    if (tileentity != null && (tileentity is net.minecraft.src.TileEntityPiston))
                    {
                        ((net.minecraft.src.TileEntityPiston)tileentity).ClearPistonTileEntity();
                    }
                    world.SetBlockAndMetadata(i, j, k, net.minecraft.src.Block.PISTON_MOVING.ID,
                                              j1);
                    world.SetBlockTileEntity(i, j, k, net.minecraft.src.BlockPistonMoving.GetTileEntity
                                                 (ID, j1, j1, false, true));
                    if (isSticky)
                    {
                        int  k1   = i + net.minecraft.src.PistonBlockTextures.field_31051_b[j1] * 2;
                        int  l1   = j + net.minecraft.src.PistonBlockTextures.field_31054_c[j1] * 2;
                        int  i2   = k + net.minecraft.src.PistonBlockTextures.field_31053_d[j1] * 2;
                        int  j2   = world.GetBlockId(k1, l1, i2);
                        int  k2   = world.GetBlockMetadata(k1, l1, i2);
                        bool flag = false;
                        if (j2 == net.minecraft.src.Block.PISTON_MOVING.ID)
                        {
                            net.minecraft.src.TileEntity tileentity1 = world.GetBlockTileEntity(k1, l1, i2);
                            if (tileentity1 != null && (tileentity1 is net.minecraft.src.TileEntityPiston))
                            {
                                net.minecraft.src.TileEntityPiston tileentitypiston = (net.minecraft.src.TileEntityPiston
                                                                                       )tileentity1;
                                if (tileentitypiston.Func_31008_d() == j1 && tileentitypiston.Func_31010_c())
                                {
                                    tileentitypiston.ClearPistonTileEntity();
                                    j2   = tileentitypiston.GetStoredBlockID();
                                    k2   = tileentitypiston.Func_31005_e();
                                    flag = true;
                                }
                            }
                        }
                        if (!flag && j2 > 0 && CanPushBlock(j2, world, k1, l1, i2, false) && (net.minecraft.src.Block
                                                                                              .blocksList[j2].GetMobilityFlag() == 0 || j2 == net.minecraft.src.Block.PISTON
                                                                                              .ID || j2 == net.minecraft.src.Block.PISTON_STICKY.ID))
                        {
                            ignoreUpdates = false;
                            world.SetBlockWithNotify(k1, l1, i2, 0);
                            ignoreUpdates = true;
                            i            += net.minecraft.src.PistonBlockTextures.field_31051_b[j1];
                            j            += net.minecraft.src.PistonBlockTextures.field_31054_c[j1];
                            k            += net.minecraft.src.PistonBlockTextures.field_31053_d[j1];
                            world.SetBlockAndMetadata(i, j, k, net.minecraft.src.Block.PISTON_MOVING.ID,
                                                      k2);
                            world.SetBlockTileEntity(i, j, k, net.minecraft.src.BlockPistonMoving.GetTileEntity
                                                         (j2, k2, j1, false, false));
                        }
                        else
                        {
                            if (!flag)
                            {
                                ignoreUpdates = false;
                                world.SetBlockWithNotify(i + net.minecraft.src.PistonBlockTextures.field_31051_b[
                                                             j1], j + net.minecraft.src.PistonBlockTextures.field_31054_c[j1], k + net.minecraft.src.PistonBlockTextures
                                                         .field_31053_d[j1], 0);
                                ignoreUpdates = true;
                            }
                        }
                    }
                    else
                    {
                        ignoreUpdates = false;
                        world.SetBlockWithNotify(i + net.minecraft.src.PistonBlockTextures.field_31051_b[
                                                     j1], j + net.minecraft.src.PistonBlockTextures.field_31054_c[j1], k + net.minecraft.src.PistonBlockTextures
                                                 .field_31053_d[j1], 0);
                        ignoreUpdates = true;
                    }
                    world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "tile.piston.in"
                                          , 0.5F, world.rand.NextFloat() * 0.15F + 0.6F);
                }
            }
            ignoreUpdates = false;
        }