コード例 #1
0
        private void SetStateIfMobInteractsWithPlate(net.minecraft.src.World world, int i
                                                     , int j, int k)
        {
            bool          flag  = world.GetBlockMetadata(i, j, k) == 1;
            bool          flag1 = false;
            float         f     = 0.125F;
            List <Entity> list  = null;

            if (triggerMobType == net.minecraft.src.EnumMobType.everything)
            {
                list = world.GetEntitiesWithinAABBExcludingEntity(null, net.minecraft.src.AxisAlignedBB
                                                                  .GetBoundingBoxFromPool((float)i + f, j, (float)k + f, (float)(i + 1) - f, (double
                                                                                                                                              )j + 0.25D, (float)(k + 1) - f));
            }
            if (triggerMobType == net.minecraft.src.EnumMobType.mobs)
            {
                list = world.GetEntitiesWithinAABB(Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.EntityLiving
                                                                                          )), net.minecraft.src.AxisAlignedBB.GetBoundingBoxFromPool((float)i + f, j, (float
                                                                                                                                                                       )k + f, (float)(i + 1) - f, (double)j + 0.25D, (float)(k + 1) - f));
            }
            if (triggerMobType == net.minecraft.src.EnumMobType.players)
            {
                list = world.GetEntitiesWithinAABB(Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.EntityPlayer
                                                                                          )), net.minecraft.src.AxisAlignedBB.GetBoundingBoxFromPool((float)i + f, j, (float
                                                                                                                                                                       )k + f, (float)(i + 1) - f, (double)j + 0.25D, (float)(k + 1) - f));
            }
            if (list.Count > 0)
            {
                flag1 = true;
            }
            if (flag1 && !flag)
            {
                world.SetBlockMetadataWithNotify(i, j, k, 1);
                world.NotifyBlocksOfNeighborChange(i, j, k, ID);
                world.NotifyBlocksOfNeighborChange(i, j - 1, k, ID);
                world.MarkBlocksDirty(i, j, k, i, j, k);
                world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.10000000000000001D, (double
                                                                                           )k + 0.5D, "random.click", 0.3F, 0.6F);
            }
            if (!flag1 && flag)
            {
                world.SetBlockMetadataWithNotify(i, j, k, 0);
                world.NotifyBlocksOfNeighborChange(i, j, k, ID);
                world.NotifyBlocksOfNeighborChange(i, j - 1, k, ID);
                world.MarkBlocksDirty(i, j, k, i, j, k);
                world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.10000000000000001D, (double
                                                                                           )k + 0.5D, "random.click", 0.3F, 0.5F);
            }
            if (flag1)
            {
                world.ScheduleUpdateTick(i, j, k, ID, TickRate());
            }
        }
コード例 #2
0
ファイル: BlockNote.cs プロジェクト: AlphaDelta/SharpBukkit
        public override void PlayBlock(net.minecraft.src.World world, int i, int j, int k
                                       , int l, int i1)
        {
            float  f = (float)System.Math.Pow(2D, (double)(i1 - 12) / 12D);
            string s = "harp";

            if (l == 1)
            {
                s = "bd";
            }
            if (l == 2)
            {
                s = "snare";
            }
            if (l == 3)
            {
                s = "hat";
            }
            if (l == 4)
            {
                s = "bassattack";
            }
            world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, (new
                                                                                         java.lang.StringBuilder()).Append("note.").Append(s).ToString(), 3F, f);
            world.SpawnParticle("note", (double)i + 0.5D, (double)j + 1.2D, (double)k + 0.5D,
                                (double)i1 / 24D, 0.0D, 0.0D);
        }
コード例 #3
0
        public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                       entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
        {
            int i1 = world.GetBlockId(i, j, k);
            int j1 = world.GetBlockId(i, j + 1, k);

            if (l != 0 && j1 == 0 && i1 == net.minecraft.src.Block.GRASS.ID || i1 == net.minecraft.src.Block
                .DIRT.ID)
            {
                net.minecraft.src.Block block = net.minecraft.src.Block.SOIL;
                world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, block.stepSound
                                      .Func_737_c(), (block.stepSound.GetVolume() + 1.0F) / 2.0F, block.stepSound.GetPitch
                                          () * 0.8F);
                if (world.singleplayerWorld)
                {
                    return(true);
                }
                else
                {
                    world.SetBlockWithNotify(i, j, k, block.ID);
                    itemstack.DamageItem(1, entityplayer);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
 public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
 {
     if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
     {
         l = 0;
     }
     else
     {
         if (l == 0)
         {
             j--;
         }
         if (l == 1)
         {
             j++;
         }
         if (l == 2)
         {
             k--;
         }
         if (l == 3)
         {
             k++;
         }
         if (l == 4)
         {
             i--;
         }
         if (l == 5)
         {
             i++;
         }
     }
     if (itemstack.stackSize == 0)
     {
         return(false);
     }
     if (world.CanBlockBePlacedAt(field_253_a, i, j, k, false, l))
     {
         net.minecraft.src.Block block = net.minecraft.src.Block.blocksList[field_253_a];
         if (world.SetBlockWithNotify(i, j, k, field_253_a))
         {
             net.minecraft.src.Block.blocksList[field_253_a].OnBlockPlaced(world, i, j, k, l);
             net.minecraft.src.Block.blocksList[field_253_a].OnBlockPlacedBy(world, i, j, k, entityplayer
                                                                             );
             world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, block.stepSound
                                   .Func_737_c(), (block.stepSound.GetVolume() + 1.0F) / 2.0F, block.stepSound.GetPitch
                                       () * 0.8F);
             itemstack.stackSize--;
         }
     }
     return(true);
 }
コード例 #5
0
ファイル: BlockFluid.cs プロジェクト: AlphaDelta/SharpBukkit
 protected internal virtual void Func_300_h(net.minecraft.src.World world, int i,
                                            int j, int k)
 {
     world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "random.fizz"
                           , 0.5F, 2.6F + (world.rand.NextFloat() - world.rand.NextFloat()) * 0.8F);
     for (int l = 0; l < 8; l++)
     {
         world.SpawnParticle("largesmoke", (double)i + rng.NextDouble(), (double)j + 1.2D
                             , (double)k + rng.NextDouble(), 0.0D, 0.0D, 0.0D);
     }
 }
コード例 #6
0
        public override void UpdateTick(net.minecraft.src.World world, int i, int j, int
                                        k, SharpRandom random)
        {
            if (world.singleplayerWorld)
            {
                return;
            }
            int l = world.GetBlockMetadata(i, j, k);

            if ((l & 8) == 0)
            {
                return;
            }
            world.SetBlockMetadataWithNotify(i, j, k, l & 7);
            world.NotifyBlocksOfNeighborChange(i, j, k, ID);
            int i1 = l & 7;

            if (i1 == 1)
            {
                world.NotifyBlocksOfNeighborChange(i - 1, j, k, ID);
            }
            else
            {
                if (i1 == 2)
                {
                    world.NotifyBlocksOfNeighborChange(i + 1, j, k, ID);
                }
                else
                {
                    if (i1 == 3)
                    {
                        world.NotifyBlocksOfNeighborChange(i, j, k - 1, ID);
                    }
                    else
                    {
                        if (i1 == 4)
                        {
                            world.NotifyBlocksOfNeighborChange(i, j, k + 1, ID);
                        }
                        else
                        {
                            world.NotifyBlocksOfNeighborChange(i, j - 1, k, ID);
                        }
                    }
                }
            }
            world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "random.click"
                                  , 0.3F, 0.5F);
            world.MarkBlocksDirty(i, j, k, i, j, k);
        }
コード例 #7
0
        public override bool BlockActivated(net.minecraft.src.World world, int i, int j,
                                            int k, net.minecraft.src.EntityPlayer entityplayer)
        {
            int l  = world.GetBlockMetadata(i, j, k);
            int i1 = l & 7;
            int j1 = 8 - (l & 8);

            if (j1 == 0)
            {
                return(true);
            }
            world.SetBlockMetadataWithNotify(i, j, k, i1 + j1);
            world.MarkBlocksDirty(i, j, k, i, j, k);
            world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "random.click"
                                  , 0.3F, 0.6F);
            world.NotifyBlocksOfNeighborChange(i, j, k, ID);
            if (i1 == 1)
            {
                world.NotifyBlocksOfNeighborChange(i - 1, j, k, ID);
            }
            else
            {
                if (i1 == 2)
                {
                    world.NotifyBlocksOfNeighborChange(i + 1, j, k, ID);
                }
                else
                {
                    if (i1 == 3)
                    {
                        world.NotifyBlocksOfNeighborChange(i, j, k - 1, ID);
                    }
                    else
                    {
                        if (i1 == 4)
                        {
                            world.NotifyBlocksOfNeighborChange(i, j, k + 1, ID);
                        }
                        else
                        {
                            world.NotifyBlocksOfNeighborChange(i, j - 1, k, ID);
                        }
                    }
                }
            }
            world.ScheduleUpdateTick(i, j, k, ID, TickRate());
            return(true);
        }
コード例 #8
0
        public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                       entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
        {
            if (l == 0)
            {
                j--;
            }
            if (l == 1)
            {
                j++;
            }
            if (l == 2)
            {
                k--;
            }
            if (l == 3)
            {
                k++;
            }
            if (l == 4)
            {
                i--;
            }
            if (l == 5)
            {
                i++;
            }
            int i1 = world.GetBlockId(i, j, k);

            if (i1 == 0)
            {
                world.PlaySoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite"
                                      , 1.0F, itemRand.NextFloat() * 0.4F + 0.8F);
                world.SetBlockWithNotify(i, j, k, net.minecraft.src.Block.FIRE.ID);
            }
            itemstack.DamageItem(1, entityplayer);
            return(true);
        }
コード例 #9
0
        public override void UpdateTick(net.minecraft.src.World world, int i, int j, int
                                        k, SharpBukkitLive.SharpBukkit.SharpRandom random)
        {
            bool flag = Func_30003_g(world, i, j, k);

            for (; torchUpdates.Count > 0 && world.GetWorldTime() - ((net.minecraft.src.RedstoneUpdateInfo
                                                                      )torchUpdates[0]).updateTime > 100L; torchUpdates.RemoveAt(0))
            {
            }
            if (torchActive)
            {
                if (flag)
                {
                    world.SetBlockAndMetadataWithNotify(i, j, k, net.minecraft.src.Block.REDSTONE_TORCH_OFF
                                                        .ID, world.GetBlockMetadata(i, j, k));
                    if (CheckForBurnout(world, i, j, k, true))
                    {
                        world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, "random.fizz"
                                              , 0.5F, 2.6F + (world.rand.NextFloat() - world.rand.NextFloat()) * 0.8F);
                        for (int l = 0; l < 5; l++)
                        {
                            double d  = (double)i + random.NextDouble() * 0.59999999999999998D + 0.20000000000000001D;
                            double d1 = (double)j + random.NextDouble() * 0.59999999999999998D + 0.20000000000000001D;
                            double d2 = (double)k + random.NextDouble() * 0.59999999999999998D + 0.20000000000000001D;
                            world.SpawnParticle("smoke", d, d1, d2, 0.0D, 0.0D, 0.0D);
                        }
                    }
                }
            }
            else
            {
                if (!flag && !CheckForBurnout(world, i, j, k, false))
                {
                    world.SetBlockAndMetadataWithNotify(i, j, k, net.minecraft.src.Block.REDSTONE_TORCH_ON
                                                        .ID, world.GetBlockMetadata(i, j, k));
                }
            }
        }
コード例 #10
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;
        }
コード例 #11
0
ファイル: ItemBucket.cs プロジェクト: AlphaDelta/SharpBukkit
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                                     )
        {
            float f  = 1.0F;
            float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer
                                                         .prevRotationPitch) * f;
            float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer
                                                       .prevRotationYaw) * f;
            double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, isFull == 0);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.CanMineBlock(entityplayer, i, j, k))
                {
                    return(itemstack);
                }
                if (isFull == 0)
                {
                    if (world.GetBlockMaterial(i, j, k) == net.minecraft.src.Material.water && world.
                        GetBlockMetadata(i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.WATER_BUCKET));
                    }
                    if (world.GetBlockMaterial(i, j, k) == net.minecraft.src.Material.lava && world.GetBlockMetadata
                            (i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.LAVA_BUCKET));
                    }
                }
                else
                {
                    if (isFull < 0)
                    {
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                    if (movingobjectposition.sideHit == 0)
                    {
                        j--;
                    }
                    if (movingobjectposition.sideHit == 1)
                    {
                        j++;
                    }
                    if (movingobjectposition.sideHit == 2)
                    {
                        k--;
                    }
                    if (movingobjectposition.sideHit == 3)
                    {
                        k++;
                    }
                    if (movingobjectposition.sideHit == 4)
                    {
                        i--;
                    }
                    if (movingobjectposition.sideHit == 5)
                    {
                        i++;
                    }
                    if (world.IsAirBlock(i, j, k) || !world.GetBlockMaterial(i, j, k).IsSolid())
                    {
                        if (world.worldProvider.isHellWorld && isFull == net.minecraft.src.Block.WATER
                            .ID)
                        {
                            world.PlaySoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F +
                                                  (world.rand.NextFloat() - world.rand.NextFloat()) * 0.8F);
                            for (int l = 0; l < 8; l++)
                            {
                                world.SpawnParticle("largesmoke", (double)i + SharpRandom.NextDouble(), (double)j + SharpRandom.NextDouble(), (double)k + SharpRandom.NextDouble(), 0.0D, 0.0D, 0.0D);
                            }
                        }
                        else
                        {
                            world.SetBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                        }
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                }
            }
            else
            {
                if (isFull == 0 && (movingobjectposition.entityHit is net.minecraft.src.EntityCow
                                    ))
                {
                    return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.MILK_BUCKET));
                }
            }
            return(itemstack);
        }