3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Implemented inventory handling for SpoutAPI

Dieser Commit ist enthalten in:
zml2008 2012-01-14 17:29:55 -08:00
Ursprung b4a170b265
Commit e719508698
2 geänderte Dateien mit 10 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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;
} }
} }