|
9 | 9 | import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
10 | 10 | import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
11 | 11 | import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
| 12 | +import net.minecraft.network.protocol.game.ServerboundClientCommandPacket; |
12 | 13 | import net.minecraft.resources.ResourceKey;
|
13 | 14 | import net.minecraft.server.MinecraftServer;
|
14 | 15 | import net.minecraft.server.TickTask;
|
@@ -104,6 +105,11 @@ public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlay
|
104 | 105 | return playerShadow;
|
105 | 106 | }
|
106 | 107 |
|
| 108 | + public static EntityPlayerMPFake respawnFake(MinecraftServer server, ServerLevel level, GameProfile profile) |
| 109 | + { |
| 110 | + return new EntityPlayerMPFake(server, level, profile, false); |
| 111 | + } |
| 112 | + |
107 | 113 | private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, boolean shadow)
|
108 | 114 | {
|
109 | 115 | super(server, worldIn, profile);
|
@@ -137,7 +143,6 @@ public void tick()
|
137 | 143 | {
|
138 | 144 | this.connection.resetPosition();
|
139 | 145 | this.getLevel().getChunkSource().move(this);
|
140 |
| - hasChangedDimension(); //<- causes hard crash but would need to be done to enable portals // not as of 1.17 |
141 | 146 | }
|
142 | 147 | try
|
143 | 148 | {
|
@@ -182,4 +187,21 @@ public String getIpAddress()
|
182 | 187 | protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) {
|
183 | 188 | doCheckFallDamage(y, onGround);
|
184 | 189 | }
|
| 190 | + |
| 191 | + @Override |
| 192 | + public Entity changeDimension(ServerLevel serverLevel) |
| 193 | + { |
| 194 | + super.changeDimension(serverLevel); |
| 195 | + if (wonGame) { |
| 196 | + ServerboundClientCommandPacket p = new ServerboundClientCommandPacket(ServerboundClientCommandPacket.Action.PERFORM_RESPAWN); |
| 197 | + connection.handleClientCommand(p); |
| 198 | + } |
| 199 | + |
| 200 | + // If above branch was taken, *this* has been removed and replaced, the new instance has been set |
| 201 | + // on 'our' connection (which is now theirs, but we still have a ref). |
| 202 | + if (connection.player.isChangingDimension()) { |
| 203 | + connection.player.hasChangedDimension(); |
| 204 | + } |
| 205 | + return connection.player; |
| 206 | + } |
185 | 207 | }
|
0 commit comments