Skip to content

Commit f31363e

Browse files
authored
Merge pull request #29 from skerit/1.19
Upgrade to 1.19
2 parents e854ba6 + 4d06269 commit f31363e

File tree

8 files changed

+56
-96
lines changed

8 files changed

+56
-96
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
44
}
55

66
repositories {

common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/EntityMixin_Disguise.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@
3232
import net.minecraft.server.world.ServerChunkManager;
3333
import net.minecraft.server.world.ServerWorld;
3434
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
35-
import net.minecraft.text.LiteralText;
3635
import net.minecraft.text.MutableText;
3736
import net.minecraft.text.Text;
38-
import net.minecraft.text.TranslatableText;
3937
import net.minecraft.util.Formatting;
4038
import net.minecraft.util.Identifier;
4139
import net.minecraft.util.registry.Registry;
@@ -58,11 +56,7 @@
5856
import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerListS2CPacketAccessor;
5957
import xyz.nucleoid.disguiselib.impl.mixin.accessor.ThreadedAnvilChunkStorageAccessor;
6058

61-
import java.util.Arrays;
62-
import java.util.Collection;
63-
import java.util.Collections;
64-
import java.util.List;
65-
import java.util.UUID;
59+
import java.util.*;
6660
import java.util.stream.Collectors;
6761

6862
import static net.minecraft.entity.EntityType.PLAYER;
@@ -168,7 +162,7 @@ public void disguiseAs(EntityType<?> entityType) {
168162
// Previous type was player, we have to send a player remove packet
169163
PlayerListS2CPacket listPacket = new PlayerListS2CPacket(REMOVE_PLAYER);
170164
PlayerListS2CPacketAccessor listPacketAccessor = (PlayerListS2CPacketAccessor) listPacket;
171-
listPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, new LiteralText(this.disguiselib$profile.getName()))));
165+
listPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, Text.literal(this.disguiselib$profile.getName()), null)));
172166
manager.sendToAll(listPacket);
173167
}
174168

@@ -347,7 +341,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
347341
*/
348342
@Unique
349343
private void disguiselib$constructFakePlayer(@NotNull GameProfile profile) {
350-
this.disguiselib$disguiseEntity = new ServerPlayerEntity(world.getServer(), (ServerWorld) world, profile);
344+
this.disguiselib$disguiseEntity = new ServerPlayerEntity(world.getServer(), (ServerWorld) world, profile, null);
351345
this.disguiselib$disguiseEntity.getDataTracker().set(getPLAYER_MODEL_PARTS(), (byte) 0x7f);
352346
}
353347

@@ -372,7 +366,7 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
372366
PlayerListS2CPacket packet = new PlayerListS2CPacket(REMOVE_PLAYER);
373367
//noinspection ConstantConditions
374368
PlayerListS2CPacketAccessor accessor = (PlayerListS2CPacketAccessor) packet;
375-
accessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, new LiteralText(this.disguiselib$profile.getName()))));
369+
accessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(this.disguiselib$profile, 0, GameMode.SURVIVAL, Text.literal(this.disguiselib$profile.getName()), null)));
376370

377371
PlayerManager playerManager = this.world.getServer().getPlayerManager();
378372
playerManager.sendToAll(packet);
@@ -390,14 +384,15 @@ public void setGameProfile(@Nullable GameProfile gameProfile) {
390384
ServerWorld targetWorld = player.getWorld();
391385

392386
player.networkHandler.sendPacket(new PlayerRespawnS2CPacket(
393-
targetWorld.method_40134(), // getDimension()
387+
targetWorld.getDimensionKey(), // getDimension()
394388
targetWorld.getRegistryKey(),
395389
BiomeAccess.hashSeed(targetWorld.getSeed()),
396390
player.interactionManager.getGameMode(),
397391
player.interactionManager.getPreviousGameMode(),
398392
targetWorld.isDebugWorld(),
399393
targetWorld.isFlat(),
400-
true
394+
true,
395+
Optional.empty()
401396
));
402397
player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch());
403398

@@ -451,8 +446,8 @@ private void postTick(CallbackInfo ci) {
451446
this.world.getServer().getPlayerManager().sendToDimension(new EntityPositionS2CPacket(this.disguiselib$entity), this.world.getRegistryKey());
452447
else if(this.disguiselib$entity instanceof ServerPlayerEntity && ++this.disguiselib$ticks % 40 == 0 && this.disguiselib$disguiseEntity != null) {
453448
// "Disguised as" message
454-
MutableText msg = new LiteralText("You are disguised as ")
455-
.append(new TranslatableText(this.disguiselib$disguiseEntity.getType().getTranslationKey()))
449+
MutableText msg = Text.literal("You are disguised as ")
450+
.append(Text.translatable(this.disguiselib$disguiseEntity.getType().getTranslationKey()))
456451
.formatted(Formatting.GREEN);
457452

458453
((ServerPlayerEntity) this.disguiselib$entity).sendMessage(msg, true);
@@ -479,7 +474,7 @@ private void onRemove(CallbackInfo ci) {
479474

480475
GameProfile profile = new GameProfile(this.disguiselib$entity.getUuid(), this.getName().getString());
481476
// Arrays.asList is needed as we PlayerList needs mutable list
482-
listS2CPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(profile, 0, GameMode.SURVIVAL, this.getName())));
477+
listS2CPacketAccessor.setEntries(Arrays.asList(new PlayerListS2CPacket.Entry(profile, 0, GameMode.SURVIVAL, this.getName(), null)));
483478

484479
PlayerManager manager = this.world.getServer().getPlayerManager();
485480
manager.sendToAll(packet);

common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/ServerPlayNetworkHandlerMixin_Disguiser.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
1818
import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket;
1919
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
20-
import net.minecraft.network.packet.s2c.play.MobSpawnS2CPacket;
2120
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
2221
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.Entry;
2322
import net.minecraft.network.packet.s2c.play.PlayerSpawnS2CPacket;
2423
import net.minecraft.network.packet.s2c.play.TeamS2CPacket;
2524
import net.minecraft.server.network.ServerPlayNetworkHandler;
2625
import net.minecraft.server.network.ServerPlayerEntity;
27-
import net.minecraft.text.LiteralText;
26+
import net.minecraft.text.Text;
2827
import net.minecraft.world.GameMode;
2928
import net.minecraft.world.World;
3029
import org.spongepowered.asm.mixin.Mixin;
@@ -42,7 +41,6 @@
4241
import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntitySetHeadYawS2CPacketAccessor;
4342
import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntitySpawnS2CPacketAccessor;
4443
import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntityTrackerUpdateS2CPacketAccessor;
45-
import xyz.nucleoid.disguiselib.impl.mixin.accessor.MobSpawnS2CPacketAccessor;
4644
import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerListS2CPacketAccessor;
4745
import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerSpawnS2CPacketAccessor;
4846
import xyz.nucleoid.disguiselib.impl.packets.FakePackets;
@@ -98,8 +96,6 @@ private void disguiseEntity(Packet<?> packet, GenericFutureListener<? extends Fu
9896
}
9997
} else if(packet instanceof PlayerSpawnS2CPacket) {
10098
entity = world.getEntityById(((PlayerSpawnS2CPacketAccessor) packet).getId());
101-
} else if(packet instanceof MobSpawnS2CPacket) {
102-
entity = world.getEntityById(((MobSpawnS2CPacketAccessor) packet).getEntityId());
10399
} else if(packet instanceof EntitySpawnS2CPacket) {
104100
entity = world.getEntityById(((EntitySpawnS2CPacketAccessor) packet).getEntityId());
105101
} else if(packet instanceof EntitiesDestroyS2CPacket && ((EntitiesDestroyS2CPacketAccessor) packet).getEntityIds().getInt(0) == this.player.getId()) {
@@ -190,15 +186,15 @@ private void disguiseEntity(Packet<?> packet, GenericFutureListener<? extends Fu
190186

191187
// Arrays.asList is used as it returns mutable map, otherwise
192188
// this packet can cause some issues with other mods.
193-
listS2CPacketAccessor.setEntries(Arrays.asList(new Entry(profile, 0, GameMode.SURVIVAL, new LiteralText(profile.getName()))));
189+
listS2CPacketAccessor.setEntries(Arrays.asList(new Entry(profile, 0, GameMode.SURVIVAL, Text.literal(profile.getName()), null)));
194190

195191
this.sendPacket(packet);
196192

197193
if(!(entity instanceof PlayerEntity)) {
198194
packet = new PlayerListS2CPacket(PlayerListS2CPacket.Action.REMOVE_PLAYER);
199195
//noinspection ConstantConditions
200196
listS2CPacketAccessor = (PlayerListS2CPacketAccessor) packet;
201-
listS2CPacketAccessor.setEntries(Arrays.asList(new Entry(profile, 0, GameMode.SURVIVAL, new LiteralText(profile.getName()))));
197+
listS2CPacketAccessor.setEntries(Arrays.asList(new Entry(profile, 0, GameMode.SURVIVAL, Text.literal(profile.getName()), null)));
202198

203199
this.disguiselib$q.add(packet);
204200
this.disguiselib$qTimer = 50;
@@ -210,10 +206,7 @@ private void disguiseEntity(Packet<?> packet, GenericFutureListener<? extends Fu
210206
// Well, sending spawn packet of the new entity makes the player not being able to move :(
211207
if(disguise.getDisguiseType() != EntityType.PLAYER && disguise.isDisguised()) {
212208
if(disguiseEntity != null) {
213-
if(spawnPacket instanceof MobSpawnS2CPacket) {
214-
((MobSpawnS2CPacketAccessor) spawnPacket).setEntityId(disguiseEntity.getId());
215-
((MobSpawnS2CPacketAccessor) spawnPacket).setUuid(disguiseEntity.getUuid());
216-
} else if(spawnPacket instanceof EntitySpawnS2CPacket) {
209+
if(spawnPacket instanceof EntitySpawnS2CPacket) {
217210
((EntitySpawnS2CPacketAccessor) spawnPacket).setEntityId(disguiseEntity.getId());
218211
((EntitySpawnS2CPacketAccessor) spawnPacket).setUuid(disguiseEntity.getUuid());
219212
}

common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/accessor/EntitySpawnS2CPacketAccessor.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,32 @@ public interface EntitySpawnS2CPacketAccessor {
2727
@Mutable
2828
@Accessor("uuid")
2929
void setUuid(UUID uuid);
30+
31+
@Mutable
32+
@Accessor("x")
33+
void setX(double x);
34+
@Mutable
35+
@Accessor("y")
36+
void setY(double y);
37+
@Mutable
38+
@Accessor("z")
39+
void setZ(double z);
40+
@Mutable
41+
@Accessor("velocityX")
42+
void setVelocityX(int velocityX);
43+
@Mutable
44+
@Accessor("velocityY")
45+
void setVelocityY(int velocityY);
46+
@Mutable
47+
@Accessor("velocityZ")
48+
void setVelocityZ(int velocityZ);
49+
@Mutable
50+
@Accessor("yaw")
51+
void setYaw(byte yaw);
52+
@Mutable
53+
@Accessor("pitch")
54+
void setPitch(byte pitch);
55+
@Mutable
56+
@Accessor("headYaw")
57+
void setHeadYaw(byte headYaw);
3058
}

common/src/main/java/xyz/nucleoid/disguiselib/impl/mixin/accessor/MobSpawnS2CPacketAccessor.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

common/src/main/java/xyz/nucleoid/disguiselib/impl/packets/FakePackets.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
import net.minecraft.entity.player.PlayerEntity;
99
import net.minecraft.network.Packet;
1010
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
11-
import net.minecraft.network.packet.s2c.play.MobSpawnS2CPacket;
1211
import net.minecraft.network.packet.s2c.play.PlayerSpawnS2CPacket;
1312
import net.minecraft.util.math.MathHelper;
1413
import net.minecraft.util.math.Vec3d;
15-
import net.minecraft.util.registry.Registry;
1614
import xyz.nucleoid.disguiselib.api.EntityDisguise;
1715
import xyz.nucleoid.disguiselib.impl.mixin.accessor.EntitySpawnS2CPacketAccessor;
18-
import xyz.nucleoid.disguiselib.impl.mixin.accessor.MobSpawnS2CPacketAccessor;
1916
import xyz.nucleoid.disguiselib.impl.mixin.accessor.PlayerSpawnS2CPacketAccessor;
2017

2118
public class FakePackets {
@@ -35,10 +32,8 @@ public static Packet<?> universalSpawnPacket(Entity entity) {
3532

3633
Packet<?> packet = disguise.createSpawnPacket();
3734

38-
if(packet instanceof MobSpawnS2CPacket) {
35+
if(packet instanceof EntitySpawnS2CPacket) {
3936
packet = fakeMobSpawnS2CPacket(entity);
40-
} else if(packet instanceof EntitySpawnS2CPacket) {
41-
packet = fakeEntitySpawnS2CPacket(entity);
4237
} else if(packet instanceof PlayerSpawnS2CPacket) {
4338
packet = fakePlayerSpawnS2CPacket(entity);
4439
}
@@ -47,21 +42,21 @@ public static Packet<?> universalSpawnPacket(Entity entity) {
4742
}
4843

4944
/**
50-
* Constructs a fake {@link MobSpawnS2CPacket} for the given entity.
45+
* Constructs a fake {@link EntitySpawnS2CPacket} for the given entity.
5146
*
5247
* @param entity entity that requires fake packet
5348
*
54-
* @return fake {@link MobSpawnS2CPacket}
49+
* @return fake {@link EntitySpawnS2CPacket}
5550
*/
56-
public static MobSpawnS2CPacket fakeMobSpawnS2CPacket(Entity entity) {
51+
public static EntitySpawnS2CPacket fakeMobSpawnS2CPacket(Entity entity) {
5752
EntityDisguise disguise = (EntityDisguise) entity;
58-
MobSpawnS2CPacket packet = new MobSpawnS2CPacket((LivingEntity) disguise.getDisguiseEntity());
53+
EntitySpawnS2CPacket packet = new EntitySpawnS2CPacket((LivingEntity) disguise.getDisguiseEntity());
5954

60-
MobSpawnS2CPacketAccessor accessor = (MobSpawnS2CPacketAccessor) packet;
55+
EntitySpawnS2CPacketAccessor accessor = (EntitySpawnS2CPacketAccessor) packet;
6156
accessor.setEntityId(entity.getId());
6257
accessor.setUuid(entity.getUuid());
6358

64-
accessor.setEntityType(Registry.ENTITY_TYPE.getRawId(disguise.getDisguiseType()));
59+
accessor.setEntityType(disguise.getDisguiseType());
6560
accessor.setX(entity.getX());
6661
accessor.setY(entity.getY());
6762
accessor.setZ(entity.getZ());

common/src/main/resources/disguiselib.mixins.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"accessor.EntitySpawnS2CPacketAccessor",
1616
"accessor.EntityTrackerEntryAccessor",
1717
"accessor.EntityTrackerUpdateS2CPacketAccessor",
18-
"accessor.MobSpawnS2CPacketAccessor",
1918
"accessor.PlayerEntityAccessor",
2019
"accessor.PlayerListS2CPacketAccessor",
2120
"accessor.PlayerSpawnS2CPacketAccessor",

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
org.gradle.jvmargs=-Xmx2G
33

44
# Fabric Properties
5-
minecraft_version=1.18.2
6-
yarn_mappings=1.18.2+build.2
7-
loader_version=0.13.3
5+
minecraft_version=1.19
6+
yarn_mappings=1.19+build.1
7+
loader_version=0.14.6
88

99
#Fabric api
10-
fabric_version=0.48.0+1.18.2
10+
fabric_version=0.55.3+1.19
1111

1212
#Forge
1313
forge_version=40.0.19
14-
forge_enabled=true
14+
forge_enabled=false
1515

1616
# Mod Properties
17-
mod_version = 1.2.2
17+
mod_version = 1.3.0
1818
maven_group = xyz.nucleoid
1919
archives_base_name = disguiselib

0 commit comments

Comments
 (0)