use of org.bukkit.craftbukkit.v.entity.CraftItem in project Arclight by IzzelAliz.
the class AbstractArrowEntityMixin method onCollideWithPlayer.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public void onCollideWithPlayer(final PlayerEntity entityhuman) {
if (!this.world.isRemote && (this.inGround || this.getNoClip()) && this.arrowShake <= 0) {
ItemStack itemstack = this.getArrowStack();
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !itemstack.isEmpty() && ((PlayerInventoryBridge) entityhuman.inventory).bridge$canHold(itemstack) > 0) {
final ItemEntity item = new ItemEntity(this.world, this.posX, this.posY, this.posZ, itemstack);
final PlayerPickupArrowEvent event = new PlayerPickupArrowEvent(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity(), new CraftItem(((CraftServer) Bukkit.getServer()), (AbstractArrowEntity) (Object) this, item), (AbstractArrow) this.getBukkitEntity());
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
itemstack = item.getItem();
}
boolean flag = this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED || (this.pickupStatus == AbstractArrowEntity.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.isCreativeMode) || (this.getNoClip() && this.getShooter().getUniqueID() == entityhuman.getUniqueID());
if (this.pickupStatus == AbstractArrowEntity.PickupStatus.ALLOWED && !entityhuman.inventory.addItemStackToInventory(itemstack)) {
flag = false;
}
if (flag) {
entityhuman.onItemPickup((AbstractArrowEntity) (Object) this, 1);
this.remove();
}
}
}
Aggregations