Solved Determine if a Minecart is a Chest Minecart

Discussion in 'Plugin Development' started by Quidam, Jan 21, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Quidam

    So, I get a Minecart on a VehicleMoveEvent. How do I check to see if it's a chest minecart? Thanks :)
     
  2. Offline

    xGhOsTkiLLeRx

    You get a vehicle at the event not a Minecart ;)

    This code works

    Code:
    	@EventHandler
    	public void test (VehicleMoveEvent event) {
    		Vehicle vec = event.getVehicle();
    		if (vec instanceof Minecart) {
    			Minecart cart = (Minecart) vec;
    			if (cart instanceof StorageMinecart) {
    				StorageMinecart storageCart = (StorageMinecart) cart;
    				System.out.println("yes");
    			}
    		}
    	}
     
  3. Offline

    Quidam

    Ah. I didn't know what to put the cart as an instanceof. Thanks! ;)

    EDIT: And when I said Minecart, I meant I got it as a Vehicle :3
    I have the Minecart registered as an Entity and a Vehicle.
     
Thread Status:
Not open for further replies.

Share This Page