Java Code Examples for org.bukkit.entity.EntityType#HORSE
The following examples show how to use
org.bukkit.entity.EntityType#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: HorseHealingModule.java From UHC with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void on(EntityRegainHealthEvent event) { if (isEnabled()) return; if (event.getEntityType() != EntityType.HORSE) return; event.setCancelled(true); }
Example 2
Source File: HorseArmourModule.java From UHC with MIT License | 5 votes |
@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 3
Source File: HorseArmourModule.java From UHC with MIT License | 5 votes |
@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 4
Source File: HorsesModule.java From UHC with MIT License | 5 votes |
@EventHandler public void on(EntityMountEvent event) { if (isEnabled() || event.getEntityType() != EntityType.PLAYER) return; if (event.getMount().getType() == EntityType.HORSE) { event.setCancelled(true); event.getEntity().sendMessage(messages.getRaw("disabled message")); } }
Example 5
Source File: CraftHorse.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityType getType() { return EntityType.HORSE; }
Example 6
Source File: SentinelVersionCompat.java From Sentinel with MIT License | 4 votes |
static EntityType[] v1_8_passive() { return new EntityType[]{ EntityType.PIG, EntityType.OCELOT, EntityType.COW, EntityType.RABBIT, EntityType.SHEEP, EntityType.CHICKEN, EntityType.MUSHROOM_COW, EntityType.HORSE, EntityType.IRON_GOLEM, EntityType.SQUID, EntityType.VILLAGER, EntityType.WOLF, EntityType.SNOWMAN }; }
Example 7
Source File: CraftHorse.java From Thermos with GNU General Public License v3.0 | 4 votes |
public EntityType getType() { return EntityType.HORSE; }
Example 8
Source File: SpawnEggMeta.java From ShopChest with MIT License | 4 votes |
/** * @param plugin An instance of the {@link ShopChest} plugin * @param stack {@link ItemStack} (Spawn Egg) of which the Entity should be gotten * @return The {@link EntityType} the Spawn Egg will spawn or <b>null</b> if <i>nbtEntityID</i> is null */ public static EntityType getEntityTypeFromItemStack(ShopChest plugin, ItemStack stack) { if (Utils.getMajorVersion() == 8) { EntityType type = null; for (EntityType entityType : EntityType.values()) { if (entityType.getTypeId() == stack.getDurability()) { type = entityType; break; } } return type; } String nbtEntityID = getNBTEntityID(plugin, stack); if (nbtEntityID == null) return null; if (Utils.getMajorVersion() >= 11) { if (nbtEntityID.contains(":")) nbtEntityID = nbtEntityID.split(":")[1]; return EntityType.fromName(nbtEntityID); } switch (nbtEntityID) { case "PigZombie": return EntityType.valueOf("PIG_ZOMBIE"); case "CaveSpider": return EntityType.CAVE_SPIDER; case "LavaSlime": return EntityType.MAGMA_CUBE; case "MushroomCow": return EntityType.MUSHROOM_COW; case "EntityHorse": return EntityType.HORSE; case "PolarBear": return EntityType.POLAR_BEAR; case "Ozelot": return EntityType.OCELOT; default: return EntityType.valueOf(nbtEntityID.toUpperCase()); } }
Example 9
Source File: EntityNBTBase.java From NBTEditor with GNU General Public License v3.0 | 4 votes |
public static EntityNBT fromEntityData(NBTTagCompound data) { EntityType entityType = EntityTypeMap.getByName(data.getString("id")); EntityType entityTypeNew = entityType; // Backward compatibility with pre-1.11. if (entityType == EntityType.GUARDIAN) { if (data.hasKey("Elder")) { if (data.getByte("Elder") != 0) { entityTypeNew = EntityType.ELDER_GUARDIAN; } data.remove("Elder"); } } else if (entityType == EntityType.SKELETON) { if (data.hasKey("SkeletonType")) { switch (data.getByte("SkeletonType")) { case 1: entityTypeNew = EntityType.WITHER_SKELETON; break; case 2: entityTypeNew = EntityType.STRAY; break; } data.remove("SkeletonType"); } } else if (entityType == EntityType.ZOMBIE) { // pre-1.10 if (data.hasKey("IsVillager")) { if (data.getByte("IsVillager") != 0) { entityTypeNew = EntityType.ZOMBIE_VILLAGER; if (data.hasKey("VillagerProfession")) { data.setInt("Profession", data.getInt("VillagerProfession")); data.remove("VillagerProfession"); } } data.remove("IsVillager"); } // pre-1.11 if (data.hasKey("ZombieType")) { int zombieType = data.getInt("ZombieType"); if (zombieType == 0) { entityTypeNew = EntityType.ZOMBIE; } else if (zombieType >= 1 && zombieType <= 5) { entityTypeNew = EntityType.ZOMBIE_VILLAGER; data.setInt("Profession", zombieType - 1); } else if (zombieType == 6) { entityTypeNew = EntityType.HUSK; } data.remove("ZombieType"); } } else if (entityType == EntityType.HORSE) { if (data.hasKey("Type")) { switch (data.getInt("Type")) { case 1: entityTypeNew = EntityType.DONKEY; break; case 2: entityTypeNew = EntityType.MULE; break; case 3: entityTypeNew = EntityType.ZOMBIE_HORSE; break; case 4: entityTypeNew = EntityType.SKELETON_HORSE; break; } data.remove("Type"); } if (entityTypeNew != EntityType.DONKEY && entityTypeNew != EntityType.MULE) { data.remove("ChestedHorse"); } } data.setString("id", EntityTypeMap.getName(entityTypeNew)); entityType = entityTypeNew; // Convert custom names to JSON (1.13). refreshEntityName(data); if (entityType != null) { return EntityNBT.newInstance(entityType, data); } return null; }