mirror of
https://github.com/array-in-a-matrix/brainwine.git
synced 2025-04-02 11:11:58 -04:00
Resources are now added to/removed from inventory
This commit is contained in:
parent
8e05ed062e
commit
779462a8fa
3 changed files with 17 additions and 0 deletions
|
@ -44,6 +44,9 @@ public class Item {
|
|||
@JsonProperty("invulnerable")
|
||||
private boolean invulnerable;
|
||||
|
||||
@JsonProperty("inventory")
|
||||
private String inventoryItem;
|
||||
|
||||
@JsonProperty("use")
|
||||
private Map<ItemUseType, Object> useConfigs = new HashMap<>();
|
||||
|
||||
|
@ -130,6 +133,14 @@ public class Item {
|
|||
return invulnerable || !isPlacable();
|
||||
}
|
||||
|
||||
public Item getInventoryItem() {
|
||||
if(inventoryItem == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return ItemRegistry.getItem(inventoryItem);
|
||||
}
|
||||
|
||||
public boolean hasUse(ItemUseType... types) {
|
||||
for(ItemUseType type : types) {
|
||||
if(useConfigs.containsKey(type)) {
|
||||
|
|
|
@ -50,6 +50,11 @@ public class BlockMineRequest extends PlayerRequest {
|
|||
}
|
||||
|
||||
zone.updateBlock(x, y, layer, 0, 0, player);
|
||||
Item inventoryItem = item.getInventoryItem();
|
||||
|
||||
if(!inventoryItem.isAir()) {
|
||||
player.getInventory().addItem(inventoryItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void fail(Player player, String reason) {
|
||||
|
|
|
@ -67,6 +67,7 @@ public class BlockPlaceRequest extends PlayerRequest {
|
|||
}
|
||||
|
||||
zone.updateBlock(x, y, layer, item, mod, player);
|
||||
player.getInventory().removeItem(item);
|
||||
}
|
||||
|
||||
private void fail(Player player, String reason) {
|
||||
|
|
Loading…
Add table
Reference in a new issue