Update to 1.16

This commit is contained in:
libraryaddict 2020-06-25 15:33:28 +12:00
parent cd64d17a01
commit 1f847e5ad6
19 changed files with 398 additions and 73 deletions

View File

@ -83,17 +83,12 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
</dependency>
<!-- testing -->
<dependency>

View File

@ -60,6 +60,14 @@ public class LibsDisguises extends JavaPlugin {
return;
}
try {
Class cl = Class.forName("org.bukkit.Server$Spigot");
}
catch (ClassNotFoundException e) {
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
"plugin will continue to load, but it will look like a mugging victim");
}
WatcherSanitizer.init();
}

View File

@ -7,6 +7,7 @@ import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.omg.CORBA.UNKNOWN;
public enum DisguiseType {
AREA_EFFECT_CLOUD(3, 0),
@ -83,6 +84,8 @@ public enum DisguiseType {
GUARDIAN,
@NmsAddedIn(val = NmsVersion.v1_16) HOGLIN,
HORSE,
HUSK,
@ -135,7 +138,9 @@ public enum DisguiseType {
PIG,
PIG_ZOMBIE,
@NmsRemovedIn(val = NmsVersion.v1_16) PIG_ZOMBIE,
@NmsAddedIn(val = NmsVersion.v1_16) PIGLIN,
@NmsAddedIn(val = NmsVersion.v1_14) PILLAGER,
@ -183,6 +188,8 @@ public enum DisguiseType {
STRAY,
@NmsAddedIn(val = NmsVersion.v1_16) STRIDER,
THROWN_EXP_BOTTLE(75),
@NmsRemovedIn(val = NmsVersion.v1_14) TIPPED_ARROW(60),
@ -215,11 +222,15 @@ public enum DisguiseType {
WOLF,
@NmsAddedIn(val = NmsVersion.v1_16) ZOGLIN,
ZOMBIE,
ZOMBIE_HORSE,
ZOMBIE_VILLAGER;
ZOMBIE_VILLAGER,
@NmsAddedIn(val = NmsVersion.v1_16) ZOMBIFIED_PIGLIN;
public static DisguiseType getType(Entity entity) {
DisguiseType disguiseType = getType(entity.getType());

View File

@ -115,6 +115,7 @@ public class MetaIndex<Y> {
* The shooter of the arrow, no visible effect if set
*/
@NmsAddedIn(val = NmsVersion.v1_13)
@NmsRemovedIn(val = NmsVersion.v1_16)
public static MetaIndex<Optional<UUID>> ARROW_UUID = new MetaIndex<>(ArrowWatcher.class, 1, Optional.empty());
@NmsAddedIn(val = NmsVersion.v1_14)
@ -296,7 +297,10 @@ public class MetaIndex<Y> {
@NmsAddedIn(val = NmsVersion.v1_14)
public static MetaIndex<Boolean> FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false);
public static MetaIndex<Integer> FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 0, 0);
public static MetaIndex<Integer> FISHING_HOOK_HOOKED_ID = new MetaIndex<>(FishingHookWatcher.class, 0, 0);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 1, false);
/**
* The type of fox, its coloring
@ -328,6 +332,9 @@ public class MetaIndex<Y> {
*/
public static MetaIndex<Integer> GUARDIAN_TARGET = new MetaIndex<>(GuardianWatcher.class, 1, 0);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> HOGLIN_SHAKING = new MetaIndex<>(HoglinWatcher.class, 0, false);
/**
* If horse has chest, set for donkey
*/
@ -495,6 +502,18 @@ public class MetaIndex<Y> {
*/
public static MetaIndex<Integer> PIG_BOOST = new MetaIndex<>(PigWatcher.class, 1, 0);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> PIGLIN_BABY = new MetaIndex<>(PiglinWatcher.class, 0, false);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> PIGLIN_SHAKING = new MetaIndex<>(PiglinWatcher.class, 1, false);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> PIGLIN_CROSSBOW = new MetaIndex<>(PiglinWatcher.class, 2, false);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> PIGLIN_DANCING = new MetaIndex<>(PiglinWatcher.class, 3, false);
@NmsAddedIn(val = NmsVersion.v1_14)
public static MetaIndex<Boolean> PILLAGER_AIMING_BOW = new MetaIndex<>(PillagerWatcher.class, 0, false);
@ -539,6 +558,15 @@ public class MetaIndex<Y> {
public static MetaIndex<Byte> SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Integer> STRIDER_SADDLE_UNKNOWN = new MetaIndex<>(StriderWatcher.class, 0, 0);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> STRIDER_WARM = new MetaIndex<>(StriderWatcher.class, 1, false);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> STRIDER_SADDLED = new MetaIndex<>(StriderWatcher.class, 2, false);
public static MetaIndex<Byte> SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0);
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0,
@ -610,6 +638,12 @@ public class MetaIndex<Y> {
public static MetaIndex<Integer> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Integer> WOLF_ANGER = new MetaIndex<>(WolfWatcher.class, 3, 0);
@NmsAddedIn(val = NmsVersion.v1_16)
public static MetaIndex<Boolean> ZOGLIN_BABY = new MetaIndex<>(ZoglinWatcher.class, 0, false);
@NmsRemovedIn(val = NmsVersion.v1_14)
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);

View File

@ -4,26 +4,31 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
public class FishingHookWatcher extends FlagWatcher
{
public FishingHookWatcher(Disguise disguise)
{
public class FishingHookWatcher extends FlagWatcher {
public FishingHookWatcher(Disguise disguise) {
super(disguise);
}
public void setHooked(int hookedId)
{
setData(MetaIndex.FISHING_HOOK_HOOKED, hookedId + 1);
sendData(MetaIndex.FISHING_HOOK_HOOKED);
}
public int getHooked()
{
int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED);
public int getHookedId() {
int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED_ID);
if (hooked > 0)
hooked--;
return hooked;
}
public void setHookedId(int hookedId) {
setData(MetaIndex.FISHING_HOOK_HOOKED_ID, hookedId + 1);
sendData(MetaIndex.FISHING_HOOK_HOOKED_ID);
}
public boolean isHooked() {
return getData(MetaIndex.FISHING_HOOK_HOOKED);
}
public void setHooked(boolean hooked) {
setData(MetaIndex.FISHING_HOOK_HOOKED, hooked);
sendData(MetaIndex.FISHING_HOOK_HOOKED);
}
}

View File

@ -0,0 +1,24 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
/**
* Created by libraryaddict on 25/06/2020.
*/
public class HoglinWatcher extends AgeableWatcher {
public HoglinWatcher(Disguise disguise) {
super(disguise);
setShaking(false);
}
public boolean isShaking() {
return !getData(MetaIndex.HOGLIN_SHAKING);
}
public void setShaking(boolean shaking) {
setData(MetaIndex.HOGLIN_SHAKING, !shaking);
sendData(MetaIndex.HOGLIN_SHAKING);
}
}

View File

@ -0,0 +1,51 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
/**
* Created by libraryaddict on 25/06/2020.
*/
public class PiglinWatcher extends InsentientWatcher {
public PiglinWatcher(Disguise disguise) {
super(disguise);
setShaking(false);
}
public boolean isBaby() {
return getData(MetaIndex.PIGLIN_BABY);
}
public void setBaby(boolean baby) {
setData(MetaIndex.PIGLIN_BABY, baby);
sendData(MetaIndex.PIGLIN_BABY);
}
public boolean isDancing() {
return getData(MetaIndex.PIGLIN_DANCING);
}
public void setDancing(boolean dancing) {
setData(MetaIndex.PIGLIN_DANCING, dancing);
sendData(MetaIndex.PIGLIN_DANCING);
}
public boolean isUsingCrossbow() {
return getData(MetaIndex.PIGLIN_CROSSBOW);
}
public void setUsingCrossbow(boolean crossbow) {
setData(MetaIndex.PIGLIN_CROSSBOW, crossbow);
sendData(MetaIndex.PIGLIN_CROSSBOW);
}
public boolean isShaking() {
return !getData(MetaIndex.PIGLIN_SHAKING);
}
public void setShaking(boolean shaking) {
setData(MetaIndex.PIGLIN_SHAKING, !shaking);
sendData(MetaIndex.PIGLIN_SHAKING);
}
}

View File

@ -0,0 +1,22 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
/**
* Created by libraryaddict on 25/06/2020.
*/
public class StriderWatcher extends AgeableWatcher {
public StriderWatcher(Disguise disguise) {
super(disguise);
}
public boolean isSaddled() {
return getData(MetaIndex.STRIDER_SADDLED);
}
public void setSaddled(boolean saddled) {
setData(MetaIndex.STRIDER_SADDLED, saddled);
sendData(MetaIndex.STRIDER_SADDLED);
}
}

View File

@ -52,6 +52,15 @@ public class WolfWatcher extends TameableWatcher {
setTameableFlag(2, angry);
}
public int getAnger() {
return getData(MetaIndex.WOLF_ANGER);
}
public void setAnger(int anger) {
setData(MetaIndex.WOLF_ANGER, anger);
sendData(MetaIndex.WOLF_ANGER);
}
/**
* Used for tail rotation.
*

View File

@ -0,0 +1,22 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
/**
* Created by libraryaddict on 25/06/2020.
*/
public class ZoglinWatcher extends InsentientWatcher {
public ZoglinWatcher(Disguise disguise) {
super(disguise);
}
public boolean isBaby() {
return getData(MetaIndex.ZOGLIN_BABY);
}
public void setBaby(boolean baby) {
setData(MetaIndex.ZOGLIN_BABY, baby);
sendData(MetaIndex.ZOGLIN_BABY);
}
}

View File

@ -13,6 +13,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.datafixers.util.Pair;
import lombok.Getter;
import lombok.Setter;
import me.libraryaddict.disguise.DisguiseAPI;
@ -1988,36 +1989,25 @@ public class DisguiseUtilities {
.createPacket(0, player.getPassenger(), player));
}
if (NmsVersion.v1_16.isSupported()) {
List<Pair<Object, Object>> list = new ArrayList<>();
for (EquipmentSlot slot : EquipmentSlot.values()) {
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot),
ReflectionManager.getNmsItem(player.getInventory().getItem(slot))));
}
sendSelfPacket(player,
manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, list).createPacket(0, list));
} else {
for (EquipmentSlot slot : EquipmentSlot.values()) {
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(player.getInventory().getHelmet())));
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.CHEST),
ReflectionManager.getNmsItem(player.getInventory().getChestplate())));
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.LEGS),
ReflectionManager.getNmsItem(player.getInventory().getLeggings())));
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.FEET),
ReflectionManager.getNmsItem(player.getInventory().getBoots())));
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.HAND),
ReflectionManager.getNmsItem(player.getInventory().getItemInMainHand())));
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
ReflectionManager.createEnumItemSlot(EquipmentSlot.HEAD),
ReflectionManager.getNmsItem(new ItemStack(Material.STONE)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(EquipmentSlot.OFF_HAND),
ReflectionManager.getNmsItem(player.getInventory().getItemInOffHand())));
ReflectionManager.createEnumItemSlot(slot),
ReflectionManager.getNmsItem(player.getInventory().getItem(slot)))
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(slot),
ReflectionManager.getNmsItem(player.getInventory().getItem(slot))));
}
}
Location loc = player.getLocation();

View File

@ -50,7 +50,8 @@ public class PacketHandlerAttributes implements IPacketHandler {
return;
}
if (disguise.isMiscDisguise()) {
// Skip if its 1.16, PL can't handle it atm
if (disguise.isMiscDisguise() || NmsVersion.v1_16.isSupported()) {
return;
}

View File

@ -4,12 +4,14 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import com.mojang.datafixers.util.Pair;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
import me.libraryaddict.disguise.utilities.packets.PacketsHandler;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
@ -38,6 +40,107 @@ public class PacketHandlerEquipment implements IPacketHandler {
@Override
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
if (NmsVersion.v1_16.isSupported()) {
handleNew(disguise, sentPacket, packets, observer, entity);
} else {
handleOld(disguise, sentPacket, packets, observer, entity);
}
}
public void handleNew(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
// Else if the disguise is updating equipment
List<Pair<Object, Object>> slots = (List<Pair<Object, Object>>) packets.getPackets().get(0).getModifier()
.read(1);
List<Pair<Object, Object>> newSlots = new ArrayList<>();
boolean constructed = false;
for (Pair<Object, Object> pair : slots) {
EquipmentSlot slot = ReflectionManager.createEquipmentSlot(pair.getFirst());
org.bukkit.inventory.ItemStack itemStack = disguise.getWatcher().getItemStack(slot);
if (itemStack != null) {
if (!constructed) {
constructed = true;
if (packets.getPackets().size() > 1) {
packets.getPackets().remove(1);
} else {
packets.clear();
}
PacketContainer equipPacket = sentPacket.shallowClone();
packets.getPackets().add(1, equipPacket);
equipPacket.getModifier().write(1, newSlots);
}
newSlots.add(Pair.of(pair.getFirst(),
ReflectionManager.getNmsItem(itemStack.getType() == Material.AIR ? null : itemStack)));
} else {
newSlots.add(pair);
}
if (disguise.getWatcher().isRightClicking() && slot == EquipmentSlot.HAND) {
ItemStack heldItem = packets.getPackets().get(0).getItemModifier().read(0);
if (heldItem != null && heldItem.getType() != Material.AIR) {
// Convert the datawatcher
List<WrappedWatchableObject> list = new ArrayList<>();
if (DisguiseConfig.isMetaPacketsEnabled()) {
WrappedWatchableObject watch = ReflectionManager.createWatchable(MetaIndex.ENTITY_META,
WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
if (watch != null)
list.add(watch);
list = disguise.getWatcher().convert(list);
} else {
for (WrappedWatchableObject obj : disguise.getWatcher().getWatchableObjects()) {
if (obj.getIndex() == 0) {
list.add(obj);
break;
}
}
}
// Construct the packets to return
PacketContainer packetBlock = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packetBlock.getModifier().write(0, entity.getEntityId());
packetBlock.getWatchableCollectionModifier().write(0, list);
PacketContainer packetUnblock = packetBlock.deepClone();
// Make a packet to send the 'unblock'
for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) {
watcher.setValue((byte) ((byte) watcher.getValue() & ~(1 << 4)));
}
// Send the unblock before the itemstack change so that the 2nd metadata packet works. Why?
// Scheduler
// delay.
PacketContainer packet1 = packets.getPackets().get(0);
packets.clear();
packets.addPacket(packetUnblock);
packets.addPacket(packet1);
packets.addPacket(packetBlock);
// Silly mojang made the right clicking datawatcher value only valid for one use. So I have
// to reset
// it.
}
}
}
}
public void handleOld(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
// Else if the disguise is updating equipment
EquipmentSlot slot = ReflectionManager.createEquipmentSlot(packets.getPackets().get(0).getModifier().read(1));

View File

@ -74,8 +74,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
Disguise disguise = packets.getDisguise();
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
if (disguise.getWatcher() instanceof LivingWatcher) {
if (disguise.getWatcher() instanceof LivingWatcher && !NmsVersion.v1_16.isSupported()) {
ArrayList<WrappedAttribute> attributes = new ArrayList<>();
WrappedAttribute.Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");

View File

@ -14,7 +14,6 @@ import io.netty.buffer.Unpooled;
import io.netty.handler.codec.DecoderException;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
import net.minecraft.server.v1_15_R1.PacketDataSerializer;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
@ -141,15 +140,16 @@ public class PacketListenerModdedClient extends PacketAdapter {
PacketContainer packet1 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD);
packet1.getIntegers().write(0, packetId1);
packet1.getMinecraftKeys().write(0, new com.comphenix.protocol.wrappers.MinecraftKey("fml", "handshake"));
packet1.getModifier()
.write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake())));
// packet1.getModifier()
// .write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake())));
PacketContainer packet2 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD);
packet2.getIntegers().write(0, packetId2);
packet2.getMinecraftKeys().write(0, new MinecraftKey("fml", "handshake"));
packet2.getModifier()
.write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries())));
// packet2.getModifier()
// .write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries())));
//TODO
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet1);
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet2);

View File

@ -7,7 +7,8 @@ public enum NmsVersion {
v1_12,
v1_13,
v1_14,
v1_15;
v1_15,
v1_16;
/**
* If this nms version isn't newer than the running version

View File

@ -100,10 +100,15 @@ public class ReflectionManager {
pingField = getNmsField("EntityPlayer", "ping");
if (NmsVersion.v1_14.isSupported()) {
chunkProviderField = getNmsField("World", "chunkProvider");
chunkMapField = getNmsField("ChunkProviderServer", "playerChunkMap");
trackedEntitiesField = getNmsField("PlayerChunkMap", "trackedEntities");
entityTrackerField = getNmsField("PlayerChunkMap$EntityTracker", "trackerEntry");
if (NmsVersion.v1_16.isSupported()) {
chunkProviderField = getNmsField("WorldServer", "chunkProvider");
} else {
chunkProviderField = getNmsField("World", "chunkProvider");
}
} else {
trackerField = getNmsField("WorldServer", "tracker");
entitiesField = getNmsField("EntityTracker", "trackedEntities");
@ -1348,8 +1353,14 @@ public class ReflectionManager {
Constructor c = getNmsClass("EntityTypes").getConstructors()[0];
Object entityType;
// UGLY :D
Object entityType = c.newInstance(null, null, false, false, false, false, null);
if (NmsVersion.v1_16.isSupported()) {
entityType = c.newInstance(null, null, false, false, false, false, null, null, 0, 0);
} else {
entityType = c.newInstance(null, null, false, false, false, false, null);
}
for (Field f : entityType.getClass().getDeclaredFields()) {
if (f.getType() != String.class) {
@ -1564,6 +1575,7 @@ public class ReflectionManager {
case PIG_ZOMBIE:
case HUSK:
case DROWNED:
case ZOMBIFIED_PIGLIN:
watcherClass = ZombieWatcher.class;
break;
case MAGMA_CUBE:
@ -1735,6 +1747,9 @@ public class ReflectionManager {
case TRADER_LLAMA:
nmsEntityName = "LLamaTrader"; // Interesting capitalization
break;
case ZOMBIFIED_PIGLIN:
nmsEntityName = "PigZombie";
break;
default:
break;
}

View File

@ -91,6 +91,9 @@ public enum DisguiseSoundEnums {
new Sound[]{Sound.ENTITY_GUARDIAN_DEATH, Sound.ENTITY_GUARDIAN_DEATH_LAND},
new Sound[]{Sound.ENTITY_GUARDIAN_AMBIENT, Sound.ENTITY_GUARDIAN_AMBIENT_LAND}, Sound.ENTITY_GUARDIAN_FLOP),
HOGLIN(Sound.ENTITY_HOGLIN_HURT, Sound.ENTITY_HOGLIN_STEP, Sound.ENTITY_HOGLIN_DEATH, Sound.ENTITY_HOGLIN_AMBIENT,
Sound.ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED, Sound.ENTITY_HOGLIN_ANGRY, Sound.ENTITY_HOGLIN_RETREAT),
HORSE(Sound.ENTITY_HORSE_HURT, new Sound[]{Sound.ENTITY_HORSE_STEP, Sound.ENTITY_HORSE_STEP_WOOD},
Sound.ENTITY_HORSE_DEATH, Sound.ENTITY_HORSE_AMBIENT, Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE,
Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP,
@ -129,8 +132,12 @@ public enum DisguiseSoundEnums {
PIG(Sound.ENTITY_PIG_HURT, Sound.ENTITY_PIG_STEP, Sound.ENTITY_PIG_DEATH, Sound.ENTITY_PIG_AMBIENT),
PIG_ZOMBIE(Sound.ENTITY_ZOMBIE_PIGMAN_HURT, null, Sound.ENTITY_ZOMBIE_PIGMAN_DEATH,
Sound.ENTITY_ZOMBIE_PIGMAN_AMBIENT, Sound.ENTITY_ZOMBIE_PIGMAN_ANGRY),
PIGLIN(Sound.ENTITY_PIGLIN_HURT, Sound.ENTITY_PIGLIN_STEP, Sound.ENTITY_PIGLIN_DEATH, Sound.ENTITY_PIGLIN_AMBIENT,
Sound.ENTITY_PIGLIN_RETREAT, Sound.ENTITY_PIGLIN_JEALOUS, Sound.ENTITY_PIGLIN_ADMIRING_ITEM,
Sound.ENTITY_PIGLIN_CELEBRATE),
PIG_ZOMBIE("ENTITY_ZOMBIE_PIGMAN_HURT", null, "ENTITY_ZOMBIE_PIGMAN_DEATH", "ENTITY_ZOMBIE_PIGMAN_AMBIENT",
"ENTITY_ZOMBIE_PIGMAN_ANGRY"),
PLAYER(Sound.ENTITY_PLAYER_HURT, Arrays.stream(Sound.values())
.filter(sound -> sound.name().startsWith("BLOCK_") && sound.name().endsWith("_STEP")).toArray(Sound[]::new),
@ -185,15 +192,21 @@ public enum DisguiseSoundEnums {
STRAY(Sound.ENTITY_STRAY_HURT, Sound.ENTITY_STRAY_STEP, Sound.ENTITY_STRAY_DEATH, Sound.ENTITY_STRAY_AMBIENT),
STRIDER(Sound.ENTITY_STRIDER_HURT, new Sound[]{Sound.ENTITY_STRIDER_STEP, Sound.ENTITY_STRIDER_STEP_LAVA},
Sound.ENTITY_STRIDER_DEATH, Sound.ENTITY_STRIDER_AMBIENT, Sound.ENTITY_STRIDER_EAT,
Sound.ENTITY_STRIDER_HAPPY, Sound.ENTITY_STRIDER_RETREAT, Sound.ENTITY_STRIDER_SADDLE),
SQUID(Sound.ENTITY_SQUID_HURT, null, Sound.ENTITY_SQUID_DEATH, Sound.ENTITY_SQUID_AMBIENT,
Sound.ENTITY_SQUID_SQUIRT, Sound.ENTITY_FISH_SWIM),
TROPICAL_FISH(Sound.ENTITY_TROPICAL_FISH_HURT, null, Sound.ENTITY_TROPICAL_FISH_DEATH,
Sound.ENTITY_TROPICAL_FISH_AMBIENT, Sound.ENTITY_TROPICAL_FISH_FLOP, Sound.ENTITY_FISH_SWIM),
TURTLE(new Sound[]{Sound.ENTITY_TURTLE_HURT, Sound.ENTITY_TURTLE_HURT_BABY},
new Sound[]{Sound.ENTITY_TURTLE_SHAMBLE, Sound.ENTITY_TURTLE_SHAMBLE_BABY},
new Sound[]{Sound.ENTITY_TURTLE_DEATH, Sound.ENTITY_TURTLE_DEATH_BABY}, Sound.ENTITY_TURTLE_AMBIENT_LAND,
TURTLE(new Sound[]{Sound.ENTITY_TURTLE_HURT, Sound.ENTITY_TURTLE_HURT_BABY}, new Sound[]
{Sound.ENTITY_TURTLE_SHAMBLE, Sound.ENTITY_TURTLE_SHAMBLE_BABY}, new Sound[]
{Sound.ENTITY_TURTLE_DEATH, Sound.ENTITY_TURTLE_DEATH_BABY}, Sound.ENTITY_TURTLE_AMBIENT_LAND,
Sound.ENTITY_TURTLE_LAY_EGG),
VEX(Sound.ENTITY_VEX_HURT, null, Sound.ENTITY_VEX_DEATH, Sound.ENTITY_VEX_AMBIENT, Sound.ENTITY_VEX_CHARGE),
@ -216,6 +229,9 @@ public enum DisguiseSoundEnums {
Sound.ENTITY_WOLF_GROWL, Sound.ENTITY_WOLF_PANT, Sound.ENTITY_WOLF_HOWL, Sound.ENTITY_WOLF_SHAKE,
Sound.ENTITY_WOLF_WHINE),
ZOGLIN(Sound.ENTITY_ZOGLIN_HURT, Sound.ENTITY_ZOGLIN_STEP, Sound.ENTITY_ZOGLIN_DEATH, Sound.ENTITY_ZOGLIN_AMBIENT,
Sound.ENTITY_ZOGLIN_ANGRY, Sound.ENTITY_ZOGLIN_ATTACK),
ZOMBIE(Sound.ENTITY_ZOMBIE_HURT, Sound.ENTITY_ZOMBIE_STEP, Sound.ENTITY_ZOMBIE_DEATH, Sound.ENTITY_ZOMBIE_AMBIENT,
Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR, Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR,
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR),
@ -228,9 +244,14 @@ public enum DisguiseSoundEnums {
ZOMBIE_VILLAGER(Sound.ENTITY_ZOMBIE_VILLAGER_HURT, Sound.ENTITY_ZOMBIE_VILLAGER_STEP,
Sound.ENTITY_ZOMBIE_VILLAGER_DEATH, Sound.ENTITY_ZOMBIE_VILLAGER_AMBIENT, Sound.ENTITY_ZOMBIE_INFECT,
Sound.ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR, Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR,
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR);
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR),
ZOMBIIFIED_PIGLIN(Sound.ENTITY_ZOMBIFIED_PIGLIN_HURT, null, Sound.ENTITY_ZOMBIFIED_PIGLIN_DEATH,
Sound.ENTITY_ZOMBIFIED_PIGLIN_AMBIENT, Sound.ENTITY_ZOMBIFIED_PIGLIN_ANGRY,
Sound.ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED);
@Getter
private HashMap<Sound, SoundType> sounds = new HashMap<>();
private HashMap<String, SoundType> sounds = new HashMap<>();
DisguiseSoundEnums(Object hurt, Object step, Object death, Object idle, Object... sounds) {
if (LibsDisguises.getInstance() != null) {
@ -262,12 +283,26 @@ public enum DisguiseSoundEnums {
}
} else if (sound instanceof Sound) {
addSound((Sound) sound, type);
} else if (sound instanceof String[]) {
for (String s : (String[]) sound) {
if (s == null) {
continue;
}
addSound(s, type);
}
} else if (sound instanceof String) {
addSound((String) sound, type);
} else {
throw new IllegalArgumentException("Was given an unknown object " + sound);
}
}
private void addSound(Sound sound, SoundType type) {
addSound(sound.name(), type);
}
private void addSound(String sound, SoundType type) {
sounds.put(sound, type);
}
}

View File

@ -46,7 +46,7 @@ public class CompileMethods {
int i = 0;
for (Map.Entry<Sound, SoundGroup.SoundType> entry : e.getSounds().entrySet()) {
for (Map.Entry<String, SoundGroup.SoundType> entry : e.getSounds().entrySet()) {
if (entry.getValue() != type) {
continue;
}
@ -55,7 +55,7 @@ public class CompileMethods {
sound.append(",");
}
sound.append(entry.getKey().name());
sound.append(entry.getKey());
}
}