Merge pull request #358 from mikroskeem/feature/fix-enderman-iteminhand

Fix getting/setting Enderman's item in hand
This commit is contained in:
libraryaddict 2019-05-10 12:19:14 +12:00 committed by GitHub
commit daf91304b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,10 +20,7 @@ public class EndermanWatcher extends InsentientWatcher {
if (value.isPresent()) { if (value.isPresent()) {
WrappedBlockData pair = value.get(); WrappedBlockData pair = value.get();
Material id = pair.getType(); return new ItemStack(pair.getType(), 1);
int data = pair.getData();
return new ItemStack(id, 1, (short) data);
} else { } else {
return null; return null;
} }
@ -31,24 +28,25 @@ public class EndermanWatcher extends InsentientWatcher {
@Override @Override
public void setItemInMainHand(ItemStack itemstack) { public void setItemInMainHand(ItemStack itemstack) {
setItemInMainHand(itemstack.getType(), itemstack.getDurability()); setItemInMainHand(itemstack.getType());
} }
public void setItemInMainHand(Material type) { public void setItemInMainHand(Material type) {
setItemInMainHand(type, 0);
}
public void setItemInMainHand(Material type, int data) {
Optional<WrappedBlockData> optional; Optional<WrappedBlockData> optional;
if (type == null) if (type == null)
optional = Optional.empty(); optional = Optional.empty();
else else
optional = Optional.of(WrappedBlockData.createData(type, data)); optional = Optional.of(WrappedBlockData.createData(type));
setData(MetaIndex.ENDERMAN_ITEM, optional); setData(MetaIndex.ENDERMAN_ITEM, optional);
} }
@Deprecated
public void setItemInMainHand(Material type, int data) {
setItemInMainHand(type);
}
public boolean isAggressive() { public boolean isAggressive() {
return getData(MetaIndex.ENDERMAN_AGRESSIVE); return getData(MetaIndex.ENDERMAN_AGRESSIVE);
} }