Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 11:00:05 +01:00
Implemented inventory handling for SpoutAPI
Dieser Commit ist enthalten in:
Ursprung
b4a170b265
Commit
e719508698
@ -27,9 +27,11 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.cui.CUIEvent;
|
||||
import org.hibernate.type.MaterializedClobType;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.geo.discrete.Transform;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.MaterialData;
|
||||
import org.spout.api.math.Quaternion;
|
||||
import org.spout.api.math.Vector3;
|
||||
import org.spout.api.player.Player;
|
||||
@ -47,7 +49,7 @@ public class SpoutPlayer extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
ItemStack itemStack = null;//player.getItemInHand();
|
||||
ItemStack itemStack = player.getEntity().getInventory().getCurrentItem();
|
||||
return itemStack != null ? itemStack.getMaterial().getId() : 0;
|
||||
}
|
||||
|
||||
@ -75,7 +77,7 @@ public class SpoutPlayer extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.MaterialData;
|
||||
import org.spout.api.player.Player;
|
||||
@ -56,8 +57,7 @@ public class SpoutPlayerBlockBag extends BlockBag {
|
||||
*/
|
||||
private void loadInventory() {
|
||||
if (items == null) {
|
||||
items = new ItemStack[0];
|
||||
//items = player.getInventory().getContents();
|
||||
items = player.getEntity().getInventory().getContents();
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +208,10 @@ public class SpoutPlayerBlockBag extends BlockBag {
|
||||
@Override
|
||||
public void flushChanges() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren