mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 15:29:20 -04:00
player inventory support
This commit is contained in:
parent
9e23b13a31
commit
338eb8ff4a
@ -14,10 +14,13 @@
|
||||
package de.bixilon.minosoft.objects;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.GameMode;
|
||||
import de.bixilon.minosoft.game.datatypes.Slot;
|
||||
import de.bixilon.minosoft.game.datatypes.Slots;
|
||||
import de.bixilon.minosoft.game.datatypes.World;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.meta.HumanMetaData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Player {
|
||||
@ -33,6 +36,7 @@ public class Player {
|
||||
short level;
|
||||
short totalExperience;
|
||||
HumanMetaData metaData;
|
||||
HashMap<Slots.Inventory, Slot> inventory = new HashMap<>();
|
||||
|
||||
public Player(Account acc) {
|
||||
this.acc = acc;
|
||||
@ -134,4 +138,26 @@ public class Player {
|
||||
public void setMetaData(HumanMetaData metaData) {
|
||||
this.metaData = metaData;
|
||||
}
|
||||
|
||||
public HashMap<Slots.Inventory, Slot> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setInventory(HashMap<Slots.Inventory, Slot> inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public void setInventory(Slot[] data) {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
setSlot(Slots.Inventory.byId(i), data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public Slot getSlot(Slots.Inventory slot) {
|
||||
return inventory.get(slot);
|
||||
}
|
||||
|
||||
public void setSlot(Slots.Inventory slot, Slot data) {
|
||||
inventory.replace(slot, data);
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +190,11 @@ public class PacketHandler {
|
||||
}
|
||||
|
||||
public void handle(PacketWindowItems pkg) {
|
||||
switch (pkg.getWindowId()) {
|
||||
case 0: //Inventory
|
||||
connection.getPlayer().setInventory(pkg.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handle(PacketEntityMetadata pkg) {
|
||||
@ -198,7 +203,6 @@ public class PacketHandler {
|
||||
connection.getPlayer().setMetaData((HumanMetaData) pkg.getEntityData(HumanMetaData.class));
|
||||
} else {
|
||||
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).setMetaData(pkg.getEntityData(connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).getMetaData().getClass()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user