Merge pull request #1045 from TheBv/mc1.15/dev

Fixed issues with the blockzapper and FTBChunks
This commit is contained in:
simibubi 2021-02-19 14:46:48 +01:00 committed by GitHub
commit 37434f3933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,7 +109,7 @@ public class BlockzapperItem extends ZapperItem {
continue;
if (!selectedState.isValidPosition(world, placed))
continue;
if (!player.isCreative() && !canBreak(stack, world.getBlockState(placed), world, placed))
if (!player.isCreative() && !canBreak(stack, world.getBlockState(placed), world, placed,player))
continue;
if (!player.isCreative() && BlockHelper.findAndRemoveInInventory(selectedState, player, 1) == 0) {
player.getCooldownTracker()
@ -278,10 +278,13 @@ public class BlockzapperItem extends ZapperItem {
return list;
}
public static boolean canBreak(ItemStack stack, BlockState state, World world, BlockPos pos) {
public static boolean canBreak(ItemStack stack, BlockState state, World world, BlockPos pos,PlayerEntity player) {
ComponentTier tier = getTier(Components.Body, stack);
float blockHardness = state.getBlockHardness(world, pos);
//If we can't change the block (e.g chunk protection)
if (!isAllowedToPlace(world,pos,player)){
return false;
}
if (blockHardness == -1)
return false;
if (tier == ComponentTier.None)
@ -294,6 +297,14 @@ public class BlockzapperItem extends ZapperItem {
return false;
}
public static boolean isAllowedToPlace(World world, BlockPos pos,PlayerEntity player){
BlockSnapshot blocksnapshot = BlockSnapshot.getBlockSnapshot(world, pos);
if (ForgeEventFactory.onBlockPlace(player, blocksnapshot, Direction.UP)) {
return false;
}
return true;
}
public static int getMaxAoe(ItemStack stack) {
ComponentTier tier = getTier(Components.Amplifier, stack);
if (tier == ComponentTier.None)