mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
ecdda0bdbc
commit
5a47beb9cd
1 changed files with 17 additions and 0 deletions
|
@ -1,10 +1,13 @@
|
||||||
package org.bukkit.craftbukkit.inventory;
|
package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.server.EntityInsentient;
|
import net.minecraft.server.EntityInsentient;
|
||||||
import net.minecraft.server.EnumItemSlot;
|
import net.minecraft.server.EnumItemSlot;
|
||||||
|
import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CraftEntityEquipment implements EntityEquipment {
|
public class CraftEntityEquipment implements EntityEquipment {
|
||||||
|
@ -15,6 +18,20 @@ public class CraftEntityEquipment implements EntityEquipment {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem(EquipmentSlot slot, ItemStack item) {
|
||||||
|
Preconditions.checkArgument(slot != null, "slot must not be null");
|
||||||
|
EnumItemSlot nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
||||||
|
setEquipment(nmsSlot, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItem(EquipmentSlot slot) {
|
||||||
|
Preconditions.checkArgument(slot != null, "slot must not be null");
|
||||||
|
EnumItemSlot nmsSlot = CraftEquipmentSlot.getNMS(slot);
|
||||||
|
return getEquipment(nmsSlot);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand() {
|
public ItemStack getItemInMainHand() {
|
||||||
return getEquipment(EnumItemSlot.MAINHAND);
|
return getEquipment(EnumItemSlot.MAINHAND);
|
||||||
|
|
Loading…
Reference in a new issue