Permalink
Browse files

Clear inventory of Storage and Hopper carts before teleporting.

  • Loading branch information...
me4502 committed Apr 8, 2017
1 parent 2df5616 commit 41a6b62d4caaec1e7b378837142cea48605bb758
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/main/java/com/sk89q/craftbook/util/CartUtil.java
@@ -37,20 +37,22 @@ public static void teleport(final Minecart cart, Location destination) {
if(type == EntityType.MINECART_CHEST) {
toCart = cart.getWorld().spawn(destination, StorageMinecart.class);
- ((StorageMinecart)toCart).getInventory().setContents(((StorageMinecart) cart).getInventory().getContents());
+ ((StorageMinecart) toCart).getInventory().setContents(((StorageMinecart) cart).getInventory().getContents());
+ ((StorageMinecart) cart).getInventory().clear();
} else if(type == EntityType.MINECART_FURNACE) {
toCart = cart.getWorld().spawn(destination, PoweredMinecart.class);
} else if(type == EntityType.MINECART_HOPPER) {
toCart = cart.getWorld().spawn(destination, HopperMinecart.class);
- ((HopperMinecart)toCart).getInventory().setContents(((HopperMinecart) cart).getInventory().getContents());
+ ((HopperMinecart) toCart).getInventory().setContents(((HopperMinecart) cart).getInventory().getContents());
+ ((HopperMinecart) cart).getInventory().clear();
} else if(type == EntityType.MINECART_MOB_SPAWNER) {
toCart = cart.getWorld().spawn(destination, SpawnerMinecart.class);
} else if(type == EntityType.MINECART_TNT)
toCart = cart.getWorld().spawn(destination, ExplosiveMinecart.class);
else if(type == EntityType.MINECART_COMMAND) {
toCart = cart.getWorld().spawn(destination, CommandMinecart.class);
- ((CommandMinecart)toCart).setCommand(((CommandMinecart)toCart).getCommand());
- ((CommandMinecart)toCart).setName(toCart.getName());
+ ((CommandMinecart) toCart).setCommand(((CommandMinecart)toCart).getCommand());
+ ((CommandMinecart) toCart).setName(toCart.getName());
} else
toCart = cart.getWorld().spawn(destination, RideableMinecart.class);
@@ -62,7 +64,6 @@ else if(type == EntityType.MINECART_COMMAND) {
@Override
public void run() {
-
toCart.setPassenger(passenger);
passenger.setVelocity(cart.getVelocity());
}

0 comments on commit 41a6b62

Please sign in to comment.