A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

[Sponge]インベントリを扱う

インベントリの中を参照する

ClickInventoryEventでevent.getTargetInventory().slots()で参照できますので、先ずはその内容から。 ※注意:この内容で作業台をクリックするとエラーになります。

@Listener public void onEvent( ClickInventoryEvent event ){ int i = 0; for ( Inventory slot:event.getTargetInventory().slots() ){ if (slot.peek().isPresent()){ ItemStack itema = slot.peek().get(); this.ginou.info( i + “: ” + itema.getItem().getId() ); }else{ this.ginou.info( i + “: null” ); } i++; } }

slot.peek()ですが、peek(のぞき見る)で参照できます。slot.poll()でもほぼ同じ事ができますが、pollを実行するとそのスロットは空になるので注意。slot.set(<ItemStack>)で格納もできます。

[…]