Skip to content

Commit a382517

Browse files
committed
[VirtualInput] Fix respawn and /tp not applying camera angle
Reported by PoyoSquared - Bump version
1 parent 38cfefd commit a382517

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ [email protected]
1616
# TASmod properties
1717
group=com.minecrafttas
1818
artifact=TASmod-1.12.2
19-
version=Beta1.0
19+
version=Beta1.1
2020
release=false

src/main/java/com/minecrafttas/mctcommon/events/EventClient.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,20 @@ public static interface EventDoneLoadingWorld extends EventBase {
6262
}
6363

6464
/**
65-
* Fired when the player is done loading, after the position has been loaded from the server side.<br>
66-
* This also fires every time the player switches dimensions.
65+
* Fired when the server sends a packet to the client telling him to set the position
6766
*
6867
* @author Scribble
6968
* @see NetHandlerPlayClient#handlePlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook)
7069
*/
7170
@FunctionalInterface
72-
public static interface EventDoneLoadingPlayer extends EventBase {
71+
public static interface EventSetCameraAngle extends EventBase {
7372

7473
/**
75-
* Fired when the player is done loading, after the position has been loaded from the server side.<br>
76-
* This also fires every time the player switches dimensions.
74+
* Fired when the server sends a packet to the client telling him to set the position
7775
*
7876
* @see NetHandlerPlayClient#handlePlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook)
7977
*/
80-
public void onDoneLoadingPlayer();
78+
public void onSetCameraAngle();
8179
}
8280

8381
/**

src/main/java/com/minecrafttas/tasmod/handlers/LoadingScreenHandler.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import static com.minecrafttas.tasmod.TASmod.LOGGER;
44

55
import com.minecrafttas.mctcommon.events.EventClient.EventClientGameLoop;
6-
import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingPlayer;
76
import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingWorld;
87
import com.minecrafttas.mctcommon.events.EventClient.EventLaunchIntegratedServer;
98
import com.minecrafttas.mctcommon.events.EventClient.EventPlayerJoinedClientSide;
109
import com.minecrafttas.mctcommon.events.EventClient.EventPlayerLeaveClientSide;
10+
import com.minecrafttas.mctcommon.events.EventClient.EventSetCameraAngle;
1111
import com.minecrafttas.tasmod.TASmod;
1212
import com.minecrafttas.tasmod.TASmodClient;
1313
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
@@ -22,7 +22,7 @@
2222
*
2323
* @author Scribble
2424
*/
25-
public class LoadingScreenHandler implements EventLaunchIntegratedServer, EventClientGameLoop, EventDoneLoadingWorld, EventDoneLoadingPlayer, EventPlayerJoinedClientSide, EventPlayerLeaveClientSide {
25+
public class LoadingScreenHandler implements EventLaunchIntegratedServer, EventClientGameLoop, EventDoneLoadingWorld, EventSetCameraAngle, EventPlayerJoinedClientSide, EventPlayerLeaveClientSide {
2626

2727
private boolean waszero;
2828
private boolean isLoading;
@@ -80,15 +80,12 @@ public boolean isLoading() {
8080
* <p>Initializes the virtual camera to be in line with the vanilla camera.
8181
*/
8282
@Override
83-
public void onDoneLoadingPlayer() {
84-
LOGGER.debug(LoggerMarkers.Event, "Finished loading the player position on the client");
83+
public void onSetCameraAngle() {
84+
LOGGER.debug(LoggerMarkers.Event, "Setting the camera angle");
8585
VirtualCameraAngleInput cameraAngle = TASmodClient.virtual.CAMERA_ANGLE;
86-
if (cameraAngle.getCurrentPitch() == null || cameraAngle.getCurrentYaw() == null) {
87-
LOGGER.debug("Setting the initial pitch and yaw");
88-
Minecraft mc = Minecraft.getMinecraft();
89-
EntityPlayerSP player = mc.player;
90-
cameraAngle.setCamera(player.rotationPitch, player.rotationYaw);
91-
}
86+
Minecraft mc = Minecraft.getMinecraft();
87+
EntityPlayerSP player = mc.player;
88+
cameraAngle.setCamera(player.rotationPitch, player.rotationYaw);
9289
}
9390

9491
/**
@@ -105,7 +102,7 @@ public void onPlayerJoinedClientSide(EntityPlayerSP player) {
105102
* {@inheritDoc}
106103
*
107104
* <p>Resets the camera angle when leaving the world.
108-
* <p>If you later rejoin the world {@link #onDoneLoadingPlayer()} will re-initialise the camera angle
105+
* <p>If you later rejoin the world {@link #onSetCameraAngle()} will re-initialise the camera angle
109106
*/
110107
@Override
111108
public void onPlayerLeaveClientSide(EntityPlayerSP player) {

src/main/java/com/minecrafttas/tasmod/mixin/events/MixinNetHandlerPlayClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import org.spongepowered.asm.mixin.injection.Inject;
66
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
77

8-
import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingPlayer;
8+
import com.minecrafttas.mctcommon.events.EventClient.EventSetCameraAngle;
99
import com.minecrafttas.mctcommon.events.EventListenerRegistry;
1010

1111
import net.minecraft.client.network.NetHandlerPlayClient;
1212

1313
@Mixin(NetHandlerPlayClient.class)
1414
public class MixinNetHandlerPlayClient {
1515

16-
@Inject(method = "handlePlayerPosLook", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"))
16+
@Inject(method = "handlePlayerPosLook", at = @At(value = "RETURN"))
1717
public void event_handlePlayerPosLook(CallbackInfo ci) {
18-
EventListenerRegistry.fireEvent(EventDoneLoadingPlayer.class);
18+
EventListenerRegistry.fireEvent(EventSetCameraAngle.class);
1919
}
2020
}

0 commit comments

Comments
 (0)