Updated for latest SpoutAPI/Vanilla version.

This commit is contained in:
TomyLobo 2012-05-28 03:20:10 +02:00
parent 30515a65f5
commit 50b7ef02c7
3 changed files with 11 additions and 5 deletions

View File

@ -93,7 +93,7 @@
<dependency>
<groupId>org.spout</groupId>
<artifactId>vanilla</artifactId>
<version>dev-SNAPSHOT</version>
<version>1.2.5-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -35,6 +35,7 @@ import org.spout.api.geo.discrete.Point;
import org.spout.api.inventory.ItemStack;
import org.spout.api.material.MaterialRegistry;
import org.spout.api.player.Player;
import org.spout.vanilla.controller.living.player.VanillaPlayer;
public class SpoutPlayer extends LocalPlayer {
private Player player;
@ -49,7 +50,8 @@ public class SpoutPlayer extends LocalPlayer {
@Override
public int getItemInHand() {
ItemStack itemStack = player.getEntity().getInventory().getCurrentItem();
VanillaPlayer vanillaPlayer = (VanillaPlayer) player.getEntity().getController();
ItemStack itemStack = vanillaPlayer.getInventory().getCurrentItem();
return itemStack != null ? itemStack.getMaterial().getId() : 0;
}
@ -77,7 +79,8 @@ public class SpoutPlayer extends LocalPlayer {
@Override
public void giveItem(int type, int amt) {
player.getEntity().getInventory().addItem(new ItemStack(MaterialRegistry.get((short) type), amt), false);
VanillaPlayer vanillaPlayer = (VanillaPlayer) player.getEntity().getController();
vanillaPlayer.getInventory().addItem(new ItemStack(MaterialRegistry.get((short) type), amt), false);
}
@Override

View File

@ -34,6 +34,7 @@ import org.spout.api.inventory.ItemStack;
import org.spout.api.material.Material;
import org.spout.api.material.MaterialRegistry;
import org.spout.api.player.Player;
import org.spout.vanilla.controller.living.player.VanillaPlayer;
public class SpoutPlayerBlockBag extends BlockBag {
/**
@ -59,7 +60,8 @@ public class SpoutPlayerBlockBag extends BlockBag {
*/
private void loadInventory() {
if (items == null) {
items = player.getEntity().getInventory().getContents();
VanillaPlayer vanillaPlayer = (VanillaPlayer) player.getEntity().getController();
items = vanillaPlayer.getInventory().getContents();
}
}
@ -206,7 +208,8 @@ public class SpoutPlayerBlockBag extends BlockBag {
@Override
public void flushChanges() {
if (items != null) {
Inventory inv = player.getEntity().getInventory();
VanillaPlayer vanillaPlayer = (VanillaPlayer) player.getEntity().getController();
Inventory inv = vanillaPlayer.getInventory();
for (int i = 0; i < items.length && i < inv.getSize(); ++i) {
inv.setItem(i, items[i]);
}