mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-19 10:25:00 +00:00
Implemented inventory handling for SpoutAPI
This commit is contained in:
parent
b4a170b265
commit
e719508698
@ -27,9 +27,11 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.bags.BlockBag;
|
||||||
import com.sk89q.worldedit.cui.CUIEvent;
|
import com.sk89q.worldedit.cui.CUIEvent;
|
||||||
|
import org.hibernate.type.MaterializedClobType;
|
||||||
import org.spout.api.geo.discrete.Point;
|
import org.spout.api.geo.discrete.Point;
|
||||||
import org.spout.api.geo.discrete.Transform;
|
import org.spout.api.geo.discrete.Transform;
|
||||||
import org.spout.api.inventory.ItemStack;
|
import org.spout.api.inventory.ItemStack;
|
||||||
|
import org.spout.api.material.MaterialData;
|
||||||
import org.spout.api.math.Quaternion;
|
import org.spout.api.math.Quaternion;
|
||||||
import org.spout.api.math.Vector3;
|
import org.spout.api.math.Vector3;
|
||||||
import org.spout.api.player.Player;
|
import org.spout.api.player.Player;
|
||||||
@ -47,7 +49,7 @@ public class SpoutPlayer extends LocalPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemInHand() {
|
public int getItemInHand() {
|
||||||
ItemStack itemStack = null;//player.getItemInHand();
|
ItemStack itemStack = player.getEntity().getInventory().getCurrentItem();
|
||||||
return itemStack != null ? itemStack.getMaterial().getId() : 0;
|
return itemStack != null ? itemStack.getMaterial().getId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,7 @@ public class SpoutPlayer extends LocalPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveItem(int type, int amt) {
|
public void giveItem(int type, int amt) {
|
||||||
//player.getInventory().addItem(new ItemStack(type, amt));
|
player.getEntity().getInventory().addItem(new ItemStack(MaterialData.getMaterial((short)type), amt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.blocks.BaseItem;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
|
import org.spout.api.inventory.Inventory;
|
||||||
import org.spout.api.inventory.ItemStack;
|
import org.spout.api.inventory.ItemStack;
|
||||||
import org.spout.api.material.MaterialData;
|
import org.spout.api.material.MaterialData;
|
||||||
import org.spout.api.player.Player;
|
import org.spout.api.player.Player;
|
||||||
@ -56,8 +57,7 @@ public class SpoutPlayerBlockBag extends BlockBag {
|
|||||||
*/
|
*/
|
||||||
private void loadInventory() {
|
private void loadInventory() {
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
items = new ItemStack[0];
|
items = player.getEntity().getInventory().getContents();
|
||||||
//items = player.getInventory().getContents();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,10 @@ public class SpoutPlayerBlockBag extends BlockBag {
|
|||||||
@Override
|
@Override
|
||||||
public void flushChanges() {
|
public void flushChanges() {
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
//player.getInventory().setContents(items);
|
Inventory inv = player.getEntity().getInventory();
|
||||||
|
for (int i = 0; i < items.length && i < player.getEntity().getInventorySize(); ++i) {
|
||||||
|
inv.setItem(items[i], i);
|
||||||
|
}
|
||||||
items = null;
|
items = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user