use of net.minecraft.world.CompoundContainer in project SpongeCommon by SpongePowered.
the class InventoryUtil method getDoubleChestInventory.
public static Optional<Inventory> getDoubleChestInventory(final ChestBlockEntity chest) {
final Optional<Chest> connectedChestOptional = ((Chest) chest).connectedChest();
if (!connectedChestOptional.isPresent()) {
return Optional.empty();
}
final ChestType chestType = chest.getBlockState().getValue(ChestBlock.TYPE);
final ChestBlockEntity connectedChest = (ChestBlockEntity) connectedChestOptional.get();
// Logic in the instanceof check of ChestBlock.getChestInventory but with exploded ternary operators.
if (chestType == ChestType.RIGHT) {
return Optional.of((Inventory) new CompoundContainer(chest, connectedChest));
} else {
return Optional.of((Inventory) new CompoundContainer(connectedChest, chest));
}
}
Aggregations