|
12 | 12 | import net.minecraft.creativetab.CreativeTabs; |
13 | 13 | import net.minecraft.enchantment.EnchantmentHelper; |
14 | 14 | import net.minecraft.entity.Entity; |
15 | | -import net.minecraft.entity.SharedMonsterAttributes; |
16 | 15 | import net.minecraft.entity.ai.attributes.AttributeModifier; |
17 | 16 | import net.minecraft.entity.player.EntityPlayer; |
18 | 17 | import net.minecraft.init.Blocks; |
|
21 | 20 | import net.minecraft.item.EnumRarity; |
22 | 21 | import net.minecraft.item.ItemPickaxe; |
23 | 22 | import net.minecraft.item.ItemStack; |
24 | | -import net.minecraft.nbt.NBTTagCompound; |
25 | 23 | import net.minecraft.tileentity.TileEntity; |
26 | 24 | import net.minecraft.util.ActionResult; |
27 | 25 | import net.minecraft.util.EnumActionResult; |
28 | 26 | import net.minecraft.util.EnumHand; |
29 | 27 | import net.minecraft.util.math.BlockPos; |
| 28 | +import net.minecraft.util.text.TextComponentString; |
| 29 | +import net.minecraft.util.text.translation.I18n; |
30 | 30 | import net.minecraft.world.World; |
31 | 31 | import net.minecraftforge.fml.common.Mod; |
32 | 32 |
|
| 33 | +import java.util.Random; |
33 | 34 | import java.util.UUID; |
34 | 35 |
|
35 | 36 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID) |
@@ -65,15 +66,42 @@ public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player |
65 | 66 | public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { |
66 | 67 | World world = player.world; |
67 | 68 | IBlockState state = world.getBlockState(pos); |
68 | | - Block block = state.getBlock(); |
69 | | - TileEntity tile = world.getTileEntity(pos); |
| 69 | + BlockPos blockpos1 = pos.add(1,-1,0); |
| 70 | + BlockPos blockpos2 = pos.add(0,-1,1); |
| 71 | + BlockPos blockpos3 = pos.add(-1,-1,0); |
| 72 | + BlockPos blockpos4 = pos.add(0,-1,-1); |
| 73 | + BlockPos blockPos = pos.add(0, -1, 0); |
| 74 | + int yi = 0; |
70 | 75 | if (!world.isRemote) { |
71 | | - if (state.getBlock() == Blocks.EMERALD_BLOCK && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.BREAK_BEDROCK_TOOL) { |
72 | | - BlockPos blockPos = pos.add(0, -1, 0); |
73 | | - IBlockState bedrockore = world.getBlockState(blockPos); |
74 | | - bedrockore.getBlock().dropBlockAsItem(world, blockPos, bedrockore, 0); |
75 | | - world.setBlockToAir(blockPos); |
76 | | - world.setBlockToAir(pos); |
| 76 | + if (state.getBlock() == ModBlock.NETHER_STAR_BLOCK && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.BREAK_BEDROCK_TOOL) { |
| 77 | + if (world.getBlockState(blockpos1).getBlock() == Blocks.DRAGON_EGG) { |
| 78 | + world.setBlockToAir(blockpos1); |
| 79 | + yi++; |
| 80 | + } |
| 81 | + if (world.getBlockState(blockpos2).getBlock() == Blocks.PURPUR_PILLAR) { |
| 82 | + world.setBlockToAir(blockpos2); |
| 83 | + yi++; |
| 84 | + } |
| 85 | + if (world.getBlockState(blockpos3).getBlock() == Blocks.REDSTONE_BLOCK) { |
| 86 | + world.setBlockToAir(blockpos3); |
| 87 | + yi++; |
| 88 | + } |
| 89 | + if (world.getBlockState(blockpos4).getBlock() == Blocks.EMERALD_BLOCK) { |
| 90 | + world.setBlockToAir(blockpos4); |
| 91 | + yi++; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + if(yi>=2) { |
| 96 | + Random ran = world.rand; |
| 97 | + double wa = yi*0.25f; |
| 98 | + if(wa >= ran.nextDouble()) { |
| 99 | + IBlockState bedrockore = world.getBlockState(blockPos); |
| 100 | + bedrockore.getBlock().dropBlockAsItem(world, blockPos, bedrockore, 0); |
| 101 | + world.setBlockToAir(blockPos); |
| 102 | + } else { |
| 103 | + player.sendMessage(new TextComponentString(I18n.translateToLocal("message.bedrock_ore_failed"))); |
| 104 | + } |
77 | 105 | } |
78 | 106 | } |
79 | 107 | return false; |
|
0 commit comments