Java Code Examples for net.minecraft.entity.item.EntityMinecart#getEntityData()

The following examples show how to use net.minecraft.entity.item.EntityMinecart#getEntityData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CartTools.java    From NEI-Integration with MIT License 5 votes vote down vote up
/**
 * Sets a carts owner.
 * <p/>
 * The is really only needed by the bukkit ports.
 *
 * @param cart
 * @param owner
 */
public static void setCartOwner(EntityMinecart cart, GameProfile owner) {
    if (!cart.worldObj.isRemote) {
        NBTTagCompound data = cart.getEntityData();
        if (owner.getName() != null)
            data.setString("owner", owner.getName());
        if (owner.getId() != null)
            data.setString("ownerId", owner.getId().toString());
    }
}
 
Example 2
Source File: CartTools.java    From NEI-Integration with MIT License 5 votes vote down vote up
/**
 * Gets a carts owner. (player.username)
 * <p/>
 * The is really only needed by the bukkit ports.
 *
 * @param cart
 * @return
 */
public static GameProfile getCartOwner(EntityMinecart cart) {
    NBTTagCompound data = cart.getEntityData();
    String ownerName = "[Unknown]";
    if (data.hasKey("owner"))
        ownerName = data.getString("owner");

    UUID ownerId = null;
    if (data.hasKey("ownerId"))
        ownerId = UUID.fromString(data.getString("ownerId"));
    return new GameProfile(ownerId, ownerName);
}
 
Example 3
Source File: CartTools.java    From NEI-Integration with MIT License 2 votes vote down vote up
/**
 * Does the cart have a owner?
 * <p/>
 * The is really only needed by the bukkit ports.
 *
 * @param cart
 * @return
 */
public static boolean doesCartHaveOwner(EntityMinecart cart) {
    NBTTagCompound data = cart.getEntityData();
    return data.hasKey("owner");
}