Bound tools now follow the BreakEvent (#79)
This commit is contained in:
parent
effc378498
commit
faf4562df9
src/main/java/WayofTime/bloodmagic/item
|
@ -17,6 +17,9 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -60,6 +63,13 @@ public class ItemBoundAxe extends ItemBoundTool
|
|||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
if (blockStack.getBlock().isAir(world, blockPos))
|
||||
break;
|
||||
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
break;
|
||||
|
||||
if (blockStack.getBlock().getBlockHardness(world, blockPos) != -1)
|
||||
{
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock());
|
||||
|
|
|
@ -20,6 +20,9 @@ import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class ItemBoundPickaxe extends ItemBoundTool
|
||||
{
|
||||
|
@ -66,6 +69,13 @@ public class ItemBoundPickaxe extends ItemBoundTool
|
|||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
if (blockStack.getBlock().isAir(world, blockPos))
|
||||
break;
|
||||
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
break;
|
||||
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(world, blockPos) != -1)
|
||||
{
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock());
|
||||
|
|
|
@ -17,6 +17,10 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -60,6 +64,13 @@ public class ItemBoundShovel extends ItemBoundTool
|
|||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
if (blockStack.getBlock().isAir(world, blockPos))
|
||||
break;
|
||||
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
break;
|
||||
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(world, blockPos) != -1)
|
||||
{
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock());
|
||||
|
|
Loading…
Reference in a new issue