use of org.bukkit.craftbukkit.v.inventory.CraftInventory in project Arclight by IzzelAliz.
the class ContainerMixin method getBukkitView.
// todo check this
public InventoryView getBukkitView() {
if (bukkitView == null) {
PlayerEntity candidate = null;
Set<IInventory> set = new HashSet<>();
for (Slot slot : this.inventorySlots) {
if (slot.inventory != null) {
if (slot.inventory instanceof PlayerInventory) {
if (candidate != null && ((PlayerInventory) slot.inventory).player != candidate) {
ArclightMod.LOGGER.warn("Duplicate PlayerInventory inside {}, previous {}, new {}", this, candidate, slot.inventory);
}
candidate = ((PlayerInventory) slot.inventory).player;
} else {
set.add(slot.inventory);
}
}
}
if (candidate == null) {
if (ArclightCaptures.getContainerOwner() != null) {
candidate = ArclightCaptures.getContainerOwner();
} else {
throw new RuntimeException("candidate cannot be null");
}
}
CraftResultInventory resultCandidate = null;
IInventory mainCandidate = null;
for (IInventory inventory : set) {
if (inventory instanceof CraftResultInventory) {
resultCandidate = (CraftResultInventory) inventory;
} else {
mainCandidate = inventory;
}
}
Inventory inv;
if (mainCandidate == null && resultCandidate != null) {
mainCandidate = resultCandidate;
resultCandidate = null;
}
if (mainCandidate != null) {
if (resultCandidate != null) {
inv = new org.bukkit.craftbukkit.v.inventory.CraftResultInventory(mainCandidate, resultCandidate);
} else {
inv = new CraftInventory(mainCandidate);
}
} else {
// container has no slots
inv = new CraftInventoryCustom(((PlayerEntityBridge) candidate).bridge$getBukkitEntity(), 0);
}
bukkitView = new CraftInventoryView(((PlayerEntityBridge) candidate).bridge$getBukkitEntity(), inv, (Container) (Object) this);
}
return bukkitView;
}
use of org.bukkit.craftbukkit.v.inventory.CraftInventory in project Arclight by IzzelAliz.
the class DispenserContainerMixin method getBukkitView.
@Override
public CraftInventoryView getBukkitView() {
if (bukkitEntity != null) {
return bukkitEntity;
}
CraftInventory inventory = new CraftInventory(this.dispenserInventory);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
return bukkitEntity;
}
use of org.bukkit.craftbukkit.v.inventory.CraftInventory in project Arclight by IzzelAliz.
the class ChestContainerMixin method getBukkitView.
@Override
public CraftInventoryView getBukkitView() {
if (bukkitEntity != null) {
return bukkitEntity;
}
CraftInventory inventory;
if (this.lowerChestInventory instanceof PlayerInventory) {
inventory = new CraftInventoryPlayer((PlayerInventory) this.lowerChestInventory);
} else if (this.lowerChestInventory instanceof DoubleSidedInventory) {
inventory = new CraftInventoryDoubleChest((DoubleSidedInventory) this.lowerChestInventory);
} else {
inventory = new CraftInventory(this.lowerChestInventory);
}
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
return bukkitEntity;
}
use of org.bukkit.craftbukkit.v.inventory.CraftInventory in project Arclight by IzzelAliz.
the class HopperContainerMixin method getBukkitView.
@Override
public CraftInventoryView getBukkitView() {
if (bukkitEntity != null) {
return bukkitEntity;
}
CraftInventory inventory = new CraftInventory(this.hopperInventory);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
return bukkitEntity;
}
use of org.bukkit.craftbukkit.v.inventory.CraftInventory in project Arclight by IzzelAliz.
the class RepairContainerMixin method getBukkitView.
@Override
public CraftInventoryView getBukkitView() {
if (bukkitEntity != null) {
return bukkitEntity;
}
CraftInventory inventory = new CraftInventoryAnvil(((IWorldPosCallableBridge) this.worldPosCallable).bridge$getLocation(), this.inputSlots, this.outputSlot, (RepairContainer) (Object) this);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.player).bridge$getBukkitEntity(), inventory, (Container) (Object) this);
return bukkitEntity;
}
Aggregations