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


C# World.getBlockId方法代码示例

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


在下文中一共展示了World.getBlockId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(blockID, i, j, k, false))
     {
         Block block = Block.blocksList[blockID];
         if (world.setBlockAndMetadataWithNotify(i, j, k, blockID, getMetadata(itemstack.getItemDamage())))
         {
             Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
             Block.blocksList[blockID].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,代码来源:ItemBlock.cs

示例2: 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.jukebox.blockID && world.getBlockMetadata(i, j, k) == 0)
     {
         world.setBlockMetadataWithNotify(i, j, k, (shiftedIndex - record13.shiftedIndex) + 1);
         world.playRecord(recordName, i, j, k);
         itemstack.stackSize--;
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:15,代码来源:ItemRecord.cs

示例3: canPlaceBlockAt

 public override bool canPlaceBlockAt(World world, int i, int j, int k)
 {
     if (world.getBlockId(i, j - 1, k) == blockID)
     {
         return false;
     }
     if (!world.getBlockMaterial(i, j - 1, k).isSolid())
     {
         return false;
     }
     else
     {
         return base.canPlaceBlockAt(world, i, j, k);
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:15,代码来源:BlockFence.cs

示例4: activeBlockOrUseItem

 public bool activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j,
     int k, int l)
 {
     int i1 = world.getBlockId(i, j, k);
     if (i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
     {
         return true;
     }
     if (itemstack == null)
     {
         return false;
     }
     else
     {
         return itemstack.useItem(entityplayer, world, i, j, k, l);
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:17,代码来源:ItemInWorldManager.cs

示例5: onItemUse

 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     if (itemstack.getItemDamage() == 15)
     {
         int i1 = world.getBlockId(i, j, k);
         if (i1 == Block.sapling.blockID)
         {
             ((BlockSapling) Block.sapling).func_21027_b(world, i, j, k, world.rand);
             itemstack.stackSize--;
             return true;
         }
         if (i1 == Block.crops.blockID)
         {
             ((BlockCrops) Block.crops).func_21028_c(world, i, j, k);
             itemstack.stackSize--;
             return true;
         }
     }
     return false;
 }
开发者ID:riverar,项目名称:Crafty,代码行数:21,代码来源:ItemDye.cs

示例6: 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

示例7: 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

示例8: canBlockStay

 public override bool canBlockStay(World world, int i, int j, int k)
 {
     return world.getBlockLightValue(i, j, k) <= 13 &&
            canThisPlantGrowOnThisBlockID(world.getBlockId(i, j - 1, k));
 }
开发者ID:riverar,项目名称:Crafty,代码行数:5,代码来源:BlockMushroom.cs

示例9: func_4107_a

 public void func_4107_a(World world)
 {
     int i = (field_960_e - field_956_b) + 1;
     int j = (field_959_f - field_962_c) + 1;
     int k = (field_958_g - field_961_d) + 1;
     int l = i*j*k;
     if (l > 32768)
     {
         [email protected]("Light too large, skipping!");
         return;
     }
     int i1 = 0;
     int j1 = 0;
     bool flag = false;
     bool flag1 = false;
     for (int k1 = field_956_b; k1 <= field_960_e; k1++)
     {
         for (int l1 = field_961_d; l1 <= field_958_g; l1++)
         {
             int i2 = k1 >> 4;
             int j2 = l1 >> 4;
             bool flag2 = false;
             if (flag && i2 == i1 && j2 == j1)
             {
                 flag2 = flag1;
             }
             else
             {
                 flag2 = world.doChunksNearChunkExist(k1, 0, l1, 1);
                 if (flag2)
                 {
                     Chunk chunk = world.getChunkFromChunkCoords(k1 >> 4, l1 >> 4);
                     if (chunk.func_21101_g())
                     {
                         flag2 = false;
                     }
                 }
                 flag1 = flag2;
                 i1 = i2;
                 j1 = j2;
             }
             if (!flag2)
             {
                 continue;
             }
             if (field_962_c < 0)
             {
                 field_962_c = 0;
             }
             if (field_959_f >= 128)
             {
                 field_959_f = 127;
             }
             for (int k2 = field_962_c; k2 <= field_959_f; k2++)
             {
                 int l2 = world.getSavedLightValue(field_957_a, k1, k2, l1);
                 int i3 = 0;
                 int j3 = world.getBlockId(k1, k2, l1);
                 int k3 = Block.lightOpacity[j3];
                 if (k3 == 0)
                 {
                     k3 = 1;
                 }
                 int l3 = 0;
                 if (field_957_a == EnumSkyBlock.Sky)
                 {
                     if (world.canExistingBlockSeeTheSky(k1, k2, l1))
                     {
                         l3 = 15;
                     }
                 }
                 else if (field_957_a == EnumSkyBlock.Block)
                 {
                     l3 = Block.lightValue[j3];
                 }
                 if (k3 >= 15 && l3 == 0)
                 {
                     i3 = 0;
                 }
                 else
                 {
                     int i4 = world.getSavedLightValue(field_957_a, k1 - 1, k2, l1);
                     int k4 = world.getSavedLightValue(field_957_a, k1 + 1, k2, l1);
                     int l4 = world.getSavedLightValue(field_957_a, k1, k2 - 1, l1);
                     int i5 = world.getSavedLightValue(field_957_a, k1, k2 + 1, l1);
                     int j5 = world.getSavedLightValue(field_957_a, k1, k2, l1 - 1);
                     int k5 = world.getSavedLightValue(field_957_a, k1, k2, l1 + 1);
                     i3 = i4;
                     if (k4 > i3)
                     {
                         i3 = k4;
                     }
                     if (l4 > i3)
                     {
                         i3 = l4;
                     }
                     if (i5 > i3)
                     {
                         i3 = i5;
                     }
//.........这里部分代码省略.........
开发者ID:riverar,项目名称:Crafty,代码行数:101,代码来源:MetadataChunkBlock.cs

示例10: canPlaceBlockAt

 public override bool canPlaceBlockAt(World world, int i, int j, int k)
 {
     int l = world.getBlockId(i, j, k);
     return (l == 0 || blocksList[l].blockMaterial.getIsLiquid()) && world.isBlockOpaqueCube(i, j - 1, k);
 }
开发者ID:riverar,项目名称:Crafty,代码行数:5,代码来源:BlockPumpkin.cs


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