mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Add support for 1.20.6 Mobs
This commit is contained in:
parent
bef1e57712
commit
d4a3f5a9e6
@ -42,9 +42,9 @@ public enum Mob {
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, MobCompat.MOOSHROOM),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", MobCompat.SNOW_GOLEM),
|
||||
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM),
|
||||
WITHER("Wither", Enemies.ENEMY, EntityType.WITHER),
|
||||
@ -52,12 +52,12 @@ public enum Mob {
|
||||
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
|
||||
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
|
||||
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
|
||||
MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, EntityType.MINECART_CHEST),
|
||||
MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, EntityType.MINECART_FURNACE),
|
||||
MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, EntityType.MINECART_TNT),
|
||||
MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, EntityType.MINECART_HOPPER),
|
||||
MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, EntityType.MINECART_MOB_SPAWNER),
|
||||
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL),
|
||||
MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, MobCompat.CHEST_MINECART),
|
||||
MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, MobCompat.FURNACE_MINECART),
|
||||
MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, MobCompat.TNT_MINECART),
|
||||
MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, MobCompat.HOPPER_MINECART),
|
||||
MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, MobCompat.SPAWNER_MINECART),
|
||||
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, MobCompat.END_CRYSTAL),
|
||||
EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, "EXPERIENCE_ORB"),
|
||||
ARMOR_STAND("ArmorStand", Enemies.NEUTRAL, "ARMOR_STAND"),
|
||||
ENDERMITE("Endermite", Enemies.ENEMY, "ENDERMITE"),
|
||||
@ -112,6 +112,7 @@ public enum Mob {
|
||||
CHEST_BOAT("ChestBoat", Enemies.NEUTRAL, "CHEST_BOAT"),
|
||||
CAMEL("Camel", Enemies.FRIENDLY, "CAMEL"),
|
||||
SNIFFER("Sniffer", Enemies.FRIENDLY, "SNIFFER"),
|
||||
ARMADILLO("Armadillo", Enemies.FRIENDLY, "ARMADILLO"),
|
||||
;
|
||||
|
||||
private static final Map<String, Mob> hashMap = new HashMap<>();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.RegistryUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
import org.bukkit.Material;
|
||||
@ -20,6 +21,7 @@ import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@ -50,6 +52,15 @@ public final class MobCompat {
|
||||
// Constants for mobs that have changed since earlier versions
|
||||
public static final EntityType CAT = getEntityType("CAT", "OCELOT");
|
||||
public static final EntityType ZOMBIFIED_PIGLIN = getEntityType("ZOMBIFIED_PIGLIN", "PIG_ZOMBIE");
|
||||
public static final EntityType MOOSHROOM = getEntityType("MOOSHROOM", "MUSHROOM_COW");
|
||||
public static final EntityType SNOW_GOLEM = getEntityType("SNOW_GOLEM", "SNOWMAN");
|
||||
public static final EntityType CHEST_MINECART = getEntityType("CHEST_MINECART", "MINECART_CHEST");
|
||||
public static final EntityType FURNACE_MINECART = getEntityType("FURNACE_MINECART", "MINECART_FURNACE");
|
||||
public static final EntityType TNT_MINECART = getEntityType("TNT_MINECART", "MINECART_TNT");
|
||||
public static final EntityType HOPPER_MINECART = getEntityType("HOPPER_MINECART", "MINECART_HOPPER");
|
||||
public static final EntityType SPAWNER_MINECART = getEntityType("SPAWNER_MINECART", "MINECART_MOB_SPAWNER");
|
||||
public static final EntityType END_CRYSTAL = getEntityType("END_CRYSTAL", "ENDER_CRYSTAL");
|
||||
public static final EntityType FIREWORK_ROCKET = getEntityType("FIREWORK_ROCKET", "FIREWORK");
|
||||
|
||||
private MobCompat() {
|
||||
}
|
||||
@ -213,6 +224,18 @@ public final class MobCompat {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setWolfVariant(final Entity entity, final String variant) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_20_6_R01)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity instanceof Wolf) {
|
||||
final Wolf wolf = (Wolf) entity;
|
||||
//noinspection DataFlowIssue
|
||||
wolf.setVariant(RegistryUtil.valueOf(Wolf.Variant.class, variant));
|
||||
}
|
||||
}
|
||||
|
||||
public enum CatType {
|
||||
// These are (loosely) Mojang names for the cats
|
||||
SIAMESE("SIAMESE", "SIAMESE_CAT"),
|
||||
|
@ -157,8 +157,8 @@ public enum MobData {
|
||||
BLOCKFISH_TROPICAL_FISH("blockfish", MobCompat.TROPICAL_FISH, "tropicalfish:BLOCKFISH", true),
|
||||
BETTY_TROPICAL_FISH("betty", MobCompat.TROPICAL_FISH, "tropicalfish:BETTY", true),
|
||||
CLAYFISH_TROPICAL_FISH("clayfish", MobCompat.TROPICAL_FISH, "tropicalfish:CLAYFISH", true),
|
||||
BROWN_MUSHROOM_COW("brown", EntityType.MUSHROOM_COW, "mooshroom:BROWN", true),
|
||||
RED_MUSHROOM_COW("red", EntityType.MUSHROOM_COW, "mooshroom:RED", true),
|
||||
BROWN_MUSHROOM_COW("brown", MobCompat.MOOSHROOM, "mooshroom:BROWN", true),
|
||||
RED_MUSHROOM_COW("red", MobCompat.MOOSHROOM, "mooshroom:RED", true),
|
||||
AGGRESSIVE_PANDA_MAIN("aggressive", MobCompat.PANDA, "pandamain:AGGRESSIVE", true),
|
||||
LAZY_PANDA_MAIN("lazy", MobCompat.PANDA, "pandamain:LAZY", true),
|
||||
WORRIED_PANDA_MAIN("worried", MobCompat.PANDA, "pandamain:WORRIED", true),
|
||||
@ -209,6 +209,15 @@ public enum MobData {
|
||||
OAK_BOAT("oak", Boat.class, MobCompat.BoatVariant.OAK, true),
|
||||
SPRUCE_BOAT("spruce", Boat.class, MobCompat.BoatVariant.SPRUCE, true),
|
||||
SADDLE_CAMEL("saddle", MobCompat.CAMEL, Data.CAMELSADDLE, true),
|
||||
PALE_WOLF("pale", EntityType.WOLF, "wolf:PALE", true),
|
||||
SPOTTED_WOLF("spotted", EntityType.WOLF, "wolf:PALE", true),
|
||||
SNOWY_WOLF("snowy", EntityType.WOLF, "wolf:PALE", true),
|
||||
BLACK_WOLF("black", EntityType.WOLF, "wolf:BLACK", true),
|
||||
ASHEN_WOLF("ashen", EntityType.WOLF, "wolf:ASHEN", true),
|
||||
RUSTY_WOLF("rusty", EntityType.WOLF, "wolf:RUSTY", true),
|
||||
WOODS_WOLF("woods", EntityType.WOLF, "wolf:WOODS", true),
|
||||
CHESTNUT_WOLF("chestnut", EntityType.WOLF, "wolf:CHESTNUT", true),
|
||||
STRIPED_WOLF("striped", EntityType.WOLF, "wolf:STRIPED", true),
|
||||
;
|
||||
|
||||
final private String nickname;
|
||||
@ -424,6 +433,9 @@ public enum MobData {
|
||||
case "frog":
|
||||
MobCompat.setFrogVariant(spawned, split[1]);
|
||||
break;
|
||||
case "wolf":
|
||||
MobCompat.setWolfVariant(spawned, split[1]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Essentials.getWrappedLogger().warning("Unknown mob data type: " + this.toString());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.MobCompat;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
@ -9,7 +10,6 @@ import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
@ -81,7 +81,7 @@ public class Commandfirework extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < amount; i++) {
|
||||
final Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
|
||||
final Firework firework = (Firework) user.getWorld().spawnEntity(user.getLocation(), MobCompat.FIREWORK_ROCKET);
|
||||
final FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
||||
if (direction) {
|
||||
final Vector vector = user.getBase().getEyeLocation().getDirection().multiply(0.070);
|
||||
|
Loading…
Reference in New Issue
Block a user