mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
SPIGOT-4271: Fix API error when enderman are not carrying a block
This commit is contained in:
parent
4a24108665
commit
452a173807
1 changed files with 4 additions and 3 deletions
|
@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.entity;
|
||||||
import net.minecraft.server.EntityEnderman;
|
import net.minecraft.server.EntityEnderman;
|
||||||
|
|
||||||
import net.minecraft.server.IBlockData;
|
import net.minecraft.server.IBlockData;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||||
|
@ -18,13 +19,13 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
||||||
|
|
||||||
public MaterialData getCarriedMaterial() {
|
public MaterialData getCarriedMaterial() {
|
||||||
IBlockData blockData = getHandle().getCarried();
|
IBlockData blockData = getHandle().getCarried();
|
||||||
return CraftMagicNumbers.getMaterial(blockData);
|
return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData getCarriedBlock() {
|
public BlockData getCarriedBlock() {
|
||||||
IBlockData blockData = getHandle().getCarried();
|
IBlockData blockData = getHandle().getCarried();
|
||||||
return CraftBlockData.fromData(blockData);
|
return (blockData == null) ? null : CraftBlockData.fromData(blockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCarriedMaterial(MaterialData data) {
|
public void setCarriedMaterial(MaterialData data) {
|
||||||
|
@ -33,7 +34,7 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCarriedBlock(BlockData blockData) {
|
public void setCarriedBlock(BlockData blockData) {
|
||||||
getHandle().setCarried(((CraftBlockData) blockData).getState());
|
getHandle().setCarried(blockData == null ? null : ((CraftBlockData) blockData).getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue