From 4d062693f435fcff1a38f64bf89cb1cb3af04b98 Mon Sep 17 00:00:00 2001 From: Jelle De Loecker Date: Thu, 9 Jun 2022 22:35:42 +0200 Subject: [PATCH] Upgrade to 1.19 --- build.gradle | 2 +- .../impl/mixin/EntityMixin_Disguise.java | 25 ++++------ ...rverPlayNetworkHandlerMixin_Disguiser.java | 15 ++---- .../EntitySpawnS2CPacketAccessor.java | 28 +++++++++++ .../accessor/MobSpawnS2CPacketAccessor.java | 50 ------------------- .../disguiselib/impl/packets/FakePackets.java | 19 +++---- .../main/resources/disguiselib.mixins.json | 1 - gradle.properties | 12 ++--- 8 files changed, 56 insertions(+), 96 deletions(-) delete mode 100644 common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/accessor/MobSpawnS2CPacketAccessor.java diff --git a/build.gradle b/build.gradle index 8805042..7137de2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false } repositories { diff --git a/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/EntityMixin_Disguise.java b/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/EntityMixin_Disguise.java index f4ee6f6..5eadf57 100644 --- a/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/EntityMixin_Disguise.java +++ b/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/EntityMixin_Disguise.java @@ -32,10 +32,8 @@ import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ThreadedAnvilChunkStorage; -import net.minecraft.text.LiteralText; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -58,11 +56,7 @@ import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerListS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.mixin.accessor.ThreadedAnvilChunkStorageAccessor; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import static net.minecraft.entity.EntityType.PLAYER; @@ -168,7 +162,7 @@ public void disguiseAs(EntityType entityType) { // Previous type was player, we have to send a player remove packet PlayerListS2CPacket listPacket = new PlayerListS2CPacket(REMOVE_PLAYER); PlayerListS2CPacketAccessor listPacketAccessor = (PlayerListS2CPacketAccessor) listPacket; - listPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, new LiteralText(this.disguiselib$profile.getName())))); + listPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, Text.literal(this.disguiselib$profile.getName()), null))); manager.sendToAll(listPacket); } @@ -347,7 +341,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) { */ @Unique private void disguiselib$constructFakePlayer(@NotNull GameProfile profile) { - this.disguiselib$disguiseEntity = new ServerPlayerEntity(world.getServer(), (ServerWorld) world, profile); + this.disguiselib$disguiseEntity = new ServerPlayerEntity(world.getServer(), (ServerWorld) world, profile, null); this.disguiselib$disguiseEntity.getDataTracker().set(getPLAYER_MODEL_PARTS(), (byte) 0x7f); } @@ -372,7 +366,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) { PlayerListS2CPacket packet = new PlayerListS2CPacket(REMOVE_PLAYER); //noinspection ConstantConditions PlayerListS2CPacketAccessor accessor = (PlayerListS2CPacketAccessor) packet; - accessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, new LiteralText(this.disguiselib$profile.getName())))); + accessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, Text.literal(this.disguiselib$profile.getName()), null))); PlayerManager playerManager = this.world.getServer().getPlayerManager(); playerManager.sendToAll(packet); @@ -390,14 +384,15 @@ public void setGameProfile(@Nullable GameProfile gameProfile) { ServerWorld targetWorld = player.getWorld(); player.networkHandler.sendPacket(new PlayerRespawnS2CPacket( - targetWorld.method_40134(), // getDimension() + targetWorld.getDimensionKey(), // getDimension() targetWorld.getRegistryKey(), BiomeAccess.hashSeed(targetWorld.getSeed()), player.interactionManager.getGameMode(), player.interactionManager.getPreviousGameMode(), targetWorld.isDebugWorld(), targetWorld.isFlat(), - true + true, + Optional.empty() )); player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch()); @@ -451,8 +446,8 @@ private void postTick(CallbackInfo ci) { this.world.getServer().getPlayerManager().sendToDimension(new EntityPositionS2CPacket(this.disguiselib$entity), this.world.getRegistryKey()); else if(this.disguiselib$entity instanceof ServerPlayerEntity && ++this.disguiselib$ticks % 40 == 0 && this.disguiselib$disguiseEntity != null) { // "Disguised as" message - MutableText msg = new LiteralText("You are disguised as ") - .append(new TranslatableText(this.disguiselib$disguiseEntity.getType().getTranslationKey())) + MutableText msg = Text.literal("You are disguised as ") + .append(Text.translatable(this.disguiselib$disguiseEntity.getType().getTranslationKey())) .formatted(Formatting.GREEN); ((ServerPlayerEntity) this.disguiselib$entity).sendMessage(msg, true); @@ -479,7 +474,7 @@ private void onRemove(CallbackInfo ci) { GameProfile profile = new GameProfile(this.disguiselib$entity.getUuid(), this.getName().getString()); // Arrays.asList is needed as we PlayerList needs mutable list - listS2CPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(profile, 0, GameMode.SURVIVAL, this.getName()))); + listS2CPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(profile, 0, GameMode.SURVIVAL, this.getName(), null))); PlayerManager manager = this.world.getServer().getPlayerManager(); manager.sendToAll(packet); diff --git a/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/ServerPlayNetworkHandlerMixin_Disguiser.java b/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/ServerPlayNetworkHandlerMixin_Disguiser.java index 9f84a2a..73b1adb 100644 --- a/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/ServerPlayNetworkHandlerMixin_Disguiser.java +++ b/common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/ServerPlayNetworkHandlerMixin_Disguiser.java @@ -17,14 +17,13 @@ import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.MobSpawnS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.Entry; import net.minecraft.network.packet.s2c.play.PlayerSpawnS2CPacket; import net.minecraft.network.packet.s2c.play.TeamS2CPacket; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.world.GameMode; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -42,7 +41,6 @@ import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntitySetHeadYawS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntitySpawnS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntityTrackerUpdateS2CPacketAccessor; -import xyz.nucleoid.disguiselib.impl.mixin.accessor.MobSpawnS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerListS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerSpawnS2CPacketAccessor; import xyz.nucleoid.disguiselib.impl.packets.FakePackets; @@ -98,8 +96,6 @@ private void disguiseEntity(Packet packet, GenericFutureListener packet, GenericFutureListener packet, GenericFutureListener packet, GenericFutureListener universalSpawnPacket(Entity entity) { Packet packet = disguise.createSpawnPacket(); - if(packet instanceof MobSpawnS2CPacket) { + if(packet instanceof EntitySpawnS2CPacket) { packet = fakeMobSpawnS2CPacket(entity); - } else if(packet instanceof EntitySpawnS2CPacket) { - packet = fakeEntitySpawnS2CPacket(entity); } else if(packet instanceof PlayerSpawnS2CPacket) { packet = fakePlayerSpawnS2CPacket(entity); } @@ -47,21 +42,21 @@ public static Packet universalSpawnPacket(Entity entity) { } /** - * Constructs a fake {@link MobSpawnS2CPacket} for the given entity. + * Constructs a fake {@link EntitySpawnS2CPacket} for the given entity. * * @param entity entity that requires fake packet * - * @return fake {@link MobSpawnS2CPacket} + * @return fake {@link EntitySpawnS2CPacket} */ - public static MobSpawnS2CPacket fakeMobSpawnS2CPacket(Entity entity) { + public static EntitySpawnS2CPacket fakeMobSpawnS2CPacket(Entity entity) { EntityDisguise disguise = (EntityDisguise) entity; - MobSpawnS2CPacket packet = new MobSpawnS2CPacket((LivingEntity) disguise.getDisguiseEntity()); + EntitySpawnS2CPacket packet = new EntitySpawnS2CPacket((LivingEntity) disguise.getDisguiseEntity()); - MobSpawnS2CPacketAccessor accessor = (MobSpawnS2CPacketAccessor) packet; + EntitySpawnS2CPacketAccessor accessor = (EntitySpawnS2CPacketAccessor) packet; accessor.setEntityId(entity.getId()); accessor.setUuid(entity.getUuid()); - accessor.setEntityType(Registry.ENTITY_TYPE.getRawId(disguise.getDisguiseType())); + accessor.setEntityType(disguise.getDisguiseType()); accessor.setX(entity.getX()); accessor.setY(entity.getY()); accessor.setZ(entity.getZ()); diff --git a/common/src/main/resources/disguiselib.mixins.json b/common/src/main/resources/disguiselib.mixins.json index 3ba2fde..7fb3857 100644 --- a/common/src/main/resources/disguiselib.mixins.json +++ b/common/src/main/resources/disguiselib.mixins.json @@ -15,7 +15,6 @@ "accessor.EntitySpawnS2CPacketAccessor", "accessor.EntityTrackerEntryAccessor", "accessor.EntityTrackerUpdateS2CPacketAccessor", - "accessor.MobSpawnS2CPacketAccessor", "accessor.PlayerEntityAccessor", "accessor.PlayerListS2CPacketAccessor", "accessor.PlayerSpawnS2CPacketAccessor", diff --git a/gradle.properties b/gradle.properties index 8ef2a36..8cc03b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,18 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.2 -loader_version=0.13.3 +minecraft_version=1.19 +yarn_mappings=1.19+build.1 +loader_version=0.14.6 #Fabric api -fabric_version=0.48.0+1.18.2 +fabric_version=0.55.3+1.19 #Forge forge_version=40.0.19 -forge_enabled=true +forge_enabled=false # Mod Properties -mod_version = 1.2.2 +mod_version = 1.3.0 maven_group = xyz.nucleoid archives_base_name = disguiselib