/// <summary> /// Like set block, but makes a dropped item appear. Note, this calls World.setBlock to actually set the block to air. /// DropChance is 0 1, with high values making drops more likely. /// </summary> public void breakBlock(BlockPos pos, ItemTool brokenWith, float dropChance = 1) { Block block = this.getBlock(pos); ItemStack[] dropList = block.getDrops(this, pos, this.getMeta(pos), brokenWith); float f = 0.5f; if (dropList != null) { for (int i = 0; i < dropList.Length; i++) { if (dropChance != 1 || !(block is BlockTileEntity)) { if (UnityEngine.Random.Range(0f, 1f) > dropChance) { continue; } } Vector3 offset = new Vector3(UnityEngine.Random.Range(-f, f), UnityEngine.Random.Range(-f, f), UnityEngine.Random.Range(-f, f)); this.spawnItem(dropList[i], pos.toVector() + offset, EntityItem.randomRotation(), new Vector3(0, 0, 0)); } } this.setBlock(pos, Block.air); }