org.bukkit.entity.Horse Java Examples

The following examples show how to use org.bukkit.entity.Horse. 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: HorseArmourModule.java    From UHC with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void on(EntityMountEvent event) {
    if (isEnabled()) return;

    if (event.getEntityType() != EntityType.PLAYER || event.getMount().getType() != EntityType.HORSE) return;

    if (removeHorseArmour((Horse) event.getMount())) {
        event.getEntity().sendMessage(messages.getRaw("dropped armour"));
    }
}
 
Example #2
Source File: HorseArmourModule.java    From UHC with MIT License 5 votes vote down vote up
protected boolean removeHorseArmour(Horse horse) {
    final ItemStack armour = horse.getInventory().getArmor();

    if (armour != null && armour.getType() != Material.AIR) {
        // remove the armour and drop it into the world
        horse.getInventory().setArmor(null);
        horse.getWorld().dropItemNaturally(horse.getLocation(), armour);
        return true;
    }

    return false;
}
 
Example #3
Source File: HorseArmourModule.java    From UHC with MIT License 5 votes vote down vote up
@Override
public void onDisable() {
    for (final Player player : Bukkit.getOnlinePlayers()) {
        if (player.isInsideVehicle()) {
            final Entity vehicle = player.getVehicle();

            if (vehicle.getType() == EntityType.HORSE && removeHorseArmour((Horse) vehicle)) {
                player.sendMessage(messages.getRaw("dropped armour"));
            }
        }
    }
}
 
Example #4
Source File: HorseTrait.java    From StackMob-3 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean checkTrait(Entity original, Entity nearby) {
    if(original instanceof Horse){
        return (((Horse) original).getColor() != ((Horse) nearby).getColor());
    }
    return false;
}
 
Example #5
Source File: HorseTrait.java    From StackMob-3 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyTrait(Entity original, Entity spawned) {
    if(original instanceof Horse){
        ((Horse) spawned).setColor(((Horse) original).getColor());
        // another trait?
    }
}
 
Example #6
Source File: HorseData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean init(final @Nullable Class<? extends Horse> c, final @Nullable Horse e) {
	if (e != null) {
		variant = e.getVariant();
		color = e.getColor();
		style = e.getStyle();
	}
	return true;
}
 
Example #7
Source File: HorseData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void set(final Horse entity) {
	if (variant != null)
		entity.setVariant(variant);
	if (color != null)
		entity.setColor(color);
	if (style != null)
		entity.setStyle(style);
}
 
Example #8
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    getBukkitEntity().setColor(color);
}
 
Example #9
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    getBukkitEntity().setColor(color);
}
 
Example #10
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Horse getBukkitEntity() {
    return (Horse) super.getBukkitEntity();
}
 
Example #11
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    if (getBukkitEntity() instanceof Horse) {
        ((Horse) getBukkitEntity()).setStyle(bukkitStyle);
    }
}
 
Example #12
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    if (getBukkitEntity() instanceof Horse) {
        ((Horse) getBukkitEntity()).setColor(color);
    }
}
 
Example #13
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    if (getBukkitEntity() instanceof Horse) {
        ((Horse) getBukkitEntity()).setStyle(bukkitStyle);
    }
}
 
Example #14
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    if (getBukkitEntity() instanceof Horse) {
        ((Horse) getBukkitEntity()).setColor(color);
    }
}
 
Example #15
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    getBukkitEntity().setStyle(bukkitStyle);
}
 
Example #16
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    getBukkitEntity().setColor(color);
}
 
Example #17
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Horse getBukkitEntity() {
    return (Horse) super.getBukkitEntity();
}
 
Example #18
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static HorseJumpEvent callHorseJumpEvent(net.minecraft.entity.Entity horse, float power) {
    HorseJumpEvent event = new HorseJumpEvent((Horse) horse.getBukkitEntity(), power);
    horse.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #19
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    getBukkitEntity().setStyle(bukkitStyle);
}
 
Example #20
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Horse getBukkitEntity() {
    return (Horse) super.getBukkitEntity();
}
 
Example #21
Source File: CraftAbstractHorse.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void setVariant(Horse.Variant variant) {
    throw new UnsupportedOperationException("Not supported.");
}
 
Example #22
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    getBukkitEntity().setStyle(bukkitStyle);
}
 
Example #23
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Horse getBukkitEntity() {
    return (Horse) super.getBukkitEntity();
}
 
Example #24
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setColor(Horse.Color color) {
    getBukkitEntity().setColor(color);
}
 
Example #25
Source File: NMSEntityHorseImpl.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setStyle(Horse.Style bukkitStyle) {
    getBukkitEntity().setStyle(bukkitStyle);
}
 
Example #26
Source File: HorseData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends Horse> getType() {
	return Horse.class;
}
 
Example #27
Source File: HorseData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean match(final Horse entity) {
	return (variant == null || variant == entity.getVariant())
			&& (color == null || color == entity.getColor())
			&& (style == null || style == entity.getStyle());
}
 
Example #28
Source File: BukkitCompat.java    From StackMob-3 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean checkFood(Entity entity, ItemStack food) {
    Material type = food.getType();
    switch (entity.getType()) {
        case COW:
        case SHEEP:
        case MUSHROOM_COW:
            return type == Material.WHEAT;
        case PIG:
            return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO);
        case CHICKEN:
            return type == Material.WHEAT_SEEDS
                    || type == Material.MELON_SEEDS
                    || type == Material.BEETROOT_SEEDS
                    || type == Material.PUMPKIN_SEEDS;
        case HORSE:
            return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed();
        case WOLF:
            return (type == Material.BEEF
                    || type == Material.CHICKEN
                    || type == Material.COD
                    || type == Material.MUTTON
                    || type == Material.PORKCHOP
                    || type == Material.RABBIT
                    || type == Material.SALMON
                    || type == Material.COOKED_BEEF
                    || type == Material.COOKED_CHICKEN
                    || type == Material.COOKED_COD
                    || type == Material.COOKED_MUTTON
                    || type == Material.COOKED_PORKCHOP
                    || type == Material.COOKED_RABBIT
                    || type == Material.COOKED_SALMON)
                    && ((Wolf) entity).isTamed();
        case OCELOT:
            return (type == Material.SALMON
                    || type == Material.COD
                    || type == Material.PUFFERFISH
                    || type == Material.TROPICAL_FISH);
        case RABBIT:
            return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION;
        case LLAMA:
            return type == Material.HAY_BLOCK;
        case TURTLE:
            return type == Material.SEAGRASS;
        case PANDA:
            return type == Material.BAMBOO;
        case FOX:
            return type == Material.SWEET_BERRIES;
        case CAT:
            return (type == Material.COD || type == Material.SALMON) && ((Cat) entity).isTamed();
    }
    return false;
}
 
Example #29
Source File: BukkitCompat.java    From StackMob-3 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean checkFood(Entity entity, ItemStack food) {
    Material type = food.getType();
    switch (entity.getType()) {
        case COW:
        case SHEEP:
        case MUSHROOM_COW:
            return type == Material.WHEAT;
        case PIG:
            return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO);
        case CHICKEN:
            return type == Material.WHEAT_SEEDS
                    || type == Material.MELON_SEEDS
                    || type == Material.BEETROOT_SEEDS
                    || type == Material.PUMPKIN_SEEDS;
        case HORSE:
            return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed();
        case WOLF:
            return (type == Material.BEEF
                    || type == Material.CHICKEN
                    || type == Material.COD
                    || type == Material.MUTTON
                    || type == Material.PORKCHOP
                    || type == Material.RABBIT
                    || type == Material.SALMON
                    || type == Material.COOKED_BEEF
                    || type == Material.COOKED_CHICKEN
                    || type == Material.COOKED_COD
                    || type == Material.COOKED_MUTTON
                    || type == Material.COOKED_PORKCHOP
                    || type == Material.COOKED_RABBIT
                    || type == Material.COOKED_SALMON)
                    && ((Wolf) entity).isTamed();
        case OCELOT:
            return (type == Material.SALMON
                    || type == Material.COD
                    || type == Material.PUFFERFISH
                    || type == Material.TROPICAL_FISH)
                    && ((Ocelot) entity).isTamed();
        case RABBIT:
            return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION;
        case LLAMA:
            return type == Material.HAY_BLOCK;
        case TURTLE:
            return type == Material.SEAGRASS;
    }
    return false;
}
 
Example #30
Source File: CraftLlama.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Horse.Variant getVariant() {
    return Horse.Variant.LLAMA;
}