Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #524 from Nukepowered/fakeplayer_fix
Browse files Browse the repository at this point in the history
Resolved FakePlayer NPE
  • Loading branch information
Hexeption authored Mar 22, 2022
2 parents 97900ca + 6c165e3 commit 38a5824
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1212,13 +1212,12 @@ public static boolean handleBlockFormEvent(World world, BlockPos pos, IBlockStat
}

// Cauldron start
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, BlockPos pos, IBlockState iBlockState, net.minecraft.entity.player.EntityPlayerMP player) {
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, BlockPos pos, IBlockState iBlockState, EntityPlayerMP player) {
org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
org.bukkit.event.block.BlockBreakEvent blockBreakEvent = new org.bukkit.event.block.BlockBreakEvent(bukkitBlock, Bukkit.getPlayer(player.getUniqueID()));
EntityPlayerMP playermp = (EntityPlayerMP) player;
org.bukkit.event.block.BlockBreakEvent blockBreakEvent = new org.bukkit.event.block.BlockBreakEvent(bukkitBlock, player.getBukkitEntity());
net.minecraft.block.Block block = iBlockState.getBlock();
if (!(playermp instanceof FakePlayer)) {
boolean isSwordNoBreak = playermp.interactionManager.getGameType().isCreative() && !playermp.getHeldItemMainhand().isEmpty() && playermp.getHeldItemMainhand().getItem() instanceof ItemSword;
if (!(player instanceof FakePlayer)) {
boolean isSwordNoBreak = player.interactionManager.getGameType().isCreative() && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ItemSword;
if (!isSwordNoBreak) {
int exp = 0;
if (!(block == null || !player.canHarvestBlock(block.getDefaultState()) || block.canSilkHarvest(world, pos, block.getBlockState().getBaseState(), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0)) {
Expand Down

0 comments on commit 38a5824

Please sign in to comment.