use of org.spongepowered.common.bridge.world.entity.player.PlayerInventoryBridge in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin_Inventory method impl$getSpongeSlot.
// -- small bridge-like methods
@SuppressWarnings("ConstantConditions")
@Override
protected Slot impl$getSpongeSlot(final EquipmentSlot equipmentSlot) {
final EquipmentType equipmentType = (EquipmentType) (Object) equipmentSlot;
final PlayerInventoryBridge inventory = (PlayerInventoryBridge) ((net.minecraft.server.level.ServerPlayer) (Object) this).inventory;
final Lens lens = ((InventoryAdapter) inventory).inventoryAdapter$getRootLens();
final Fabric fabric = ((InventoryAdapter) inventory).inventoryAdapter$getFabric();
if (lens instanceof PlayerInventoryLens) {
final SlotLens slotLens = ((PlayerInventoryLens) lens).getEquipmentLens().getSlotLens(equipmentType);
return slotLens.getAdapter(fabric, (Inventory) inventory);
}
throw new IllegalStateException("Unknown Lens for Player Inventory: " + lens.getClass().getName());
}
use of org.spongepowered.common.bridge.world.entity.player.PlayerInventoryBridge in project SpongeCommon by SpongePowered.
the class ServerScheduler method tick.
@Override
public void tick() {
super.tick();
for (final Player player : Sponge.server().onlinePlayers()) {
try (final EntityTickContext context = TickPhase.Tick.ENTITY.createPhaseContext(PhaseTracker.SERVER).source(player)) {
context.buildAndSwitch();
// Detect Changes on PlayerInventories marked as dirty.
((PlayerInventoryBridge) ((net.minecraft.world.entity.player.Player) player).inventory).bridge$cleanupDirty();
}
}
}
Aggregations