当前位置: 首页>>代码示例>>C#>>正文


C# World.setBlockWithNotify方法代码示例

本文整理汇总了C#中World.setBlockWithNotify方法的典型用法代码示例。如果您正苦于以下问题:C# World.setBlockWithNotify方法的具体用法?C# World.setBlockWithNotify怎么用?C# World.setBlockWithNotify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World.setBlockWithNotify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: onItemUse

 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     if (world.getBlockId(i, j, k) == Block.snow.blockID)
     {
         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))
     {
         Block block = Block.blocksList[field_253_a];
         if (world.setBlockWithNotify(i, j, k, field_253_a))
         {
             Block.blocksList[field_253_a].onBlockPlaced(world, i, j, k, l);
             Block.blocksList[field_253_a].onBlockPlacedBy(world, i, j, k, entityplayer);
             world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F,
                                   block.stepSound.func_737_c(), (block.stepSound.func_738_a() + 1.0F)/2.0F,
                                   block.stepSound.func_739_b()*0.8F);
             itemstack.stackSize--;
         }
     }
     return true;
 }
开发者ID:riverar,项目名称:Crafty,代码行数:53,代码来源:ItemReed.cs

示例2: onItemUse

 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     int i1 = world.getBlockId(i, j, k);
     Material material = world.getBlockMaterial(i, j + 1, k);
     if (!material.isSolid() && i1 == Block.grass.blockID || i1 == Block.dirt.blockID)
     {
         Block block = Block.tilledField;
         world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, block.stepSound.func_737_c(),
                               (block.stepSound.func_738_a() + 1.0F)/2.0F, block.stepSound.func_739_b()*0.8F);
         if (world.singleplayerWorld)
         {
             return true;
         }
         world.setBlockWithNotify(i, j, k, block.blockID);
         itemstack.damageItem(1);
         if (world.rand.nextInt(8) == 0 && i1 == Block.grass.blockID)
         {
             int j1 = 1;
             for (int k1 = 0; k1 < j1; k1++)
             {
                 float f = 0.7F;
                 float f1 = world.rand.nextFloat()*f + (1.0F - f)*0.5F;
                 float f2 = 1.2F;
                 float f3 = world.rand.nextFloat()*f + (1.0F - f)*0.5F;
                 var entityitem = new EntityItem(world, i + f1, j + f2, k + f3,
                                                 new ItemStack(seeds));
                 entityitem.delayBeforeCanPickup = 10;
                 world.entityJoinedWorld(entityitem);
             }
         }
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:38,代码来源:ItemHoe.cs

示例3: onItemUse

 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, 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(i + 0.5D, j + 0.5D, k + 0.5D, "fire.ignite", 1.0F,
                               itemRand.nextFloat()*0.4F + 0.8F);
         world.setBlockWithNotify(i, j, k, Block.fire.blockID);
     }
     itemstack.damageItem(1);
     return true;
 }
开发者ID:riverar,项目名称:Crafty,代码行数:37,代码来源:ItemFlintAndSteel.cs

示例4: checkIfAttachedToBlock

 private bool checkIfAttachedToBlock(World world, int i, int j, int k)
 {
     if (!canPlaceBlockAt(world, i, j, k))
     {
         dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
         world.setBlockWithNotify(i, j, k, 0);
         return false;
     }
     else
     {
         return true;
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:13,代码来源:BlockLever.cs

示例5: onNeighborBlockChange

 public override void onNeighborBlockChange(World world, int i, int j, int k, int l)
 {
     if (checkIfAttachedToBlock(world, i, j, k))
     {
         int i1 = world.getBlockMetadata(i, j, k) & 7;
         bool flag = false;
         if (!world.isBlockOpaqueCube(i - 1, j, k) && i1 == 1)
         {
             flag = true;
         }
         if (!world.isBlockOpaqueCube(i + 1, j, k) && i1 == 2)
         {
             flag = true;
         }
         if (!world.isBlockOpaqueCube(i, j, k - 1) && i1 == 3)
         {
             flag = true;
         }
         if (!world.isBlockOpaqueCube(i, j, k + 1) && i1 == 4)
         {
             flag = true;
         }
         if (!world.isBlockOpaqueCube(i, j - 1, k) && i1 == 5)
         {
             flag = true;
         }
         if (flag)
         {
             dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));
             world.setBlockWithNotify(i, j, k, 0);
         }
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:33,代码来源:BlockLever.cs


注:本文中的World.setBlockWithNotify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。