Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ [email protected]
# TASmod properties
group=com.minecrafttas
artifact=TASmod-1.12.2
version=Beta1.0
version=Beta1.1
release=false
10 changes: 4 additions & 6 deletions src/main/java/com/minecrafttas/mctcommon/events/EventClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,20 @@ public static interface EventDoneLoadingWorld extends EventBase {
}

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import static com.minecrafttas.tasmod.TASmod.LOGGER;

import com.minecrafttas.mctcommon.events.EventClient.EventClientGameLoop;
import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingPlayer;
import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingWorld;
import com.minecrafttas.mctcommon.events.EventClient.EventLaunchIntegratedServer;
import com.minecrafttas.mctcommon.events.EventClient.EventPlayerJoinedClientSide;
import com.minecrafttas.mctcommon.events.EventClient.EventPlayerLeaveClientSide;
import com.minecrafttas.mctcommon.events.EventClient.EventSetCameraAngle;
import com.minecrafttas.tasmod.TASmod;
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
Expand All @@ -22,7 +22,7 @@
*
* @author Scribble
*/
public class LoadingScreenHandler implements EventLaunchIntegratedServer, EventClientGameLoop, EventDoneLoadingWorld, EventDoneLoadingPlayer, EventPlayerJoinedClientSide, EventPlayerLeaveClientSide {
public class LoadingScreenHandler implements EventLaunchIntegratedServer, EventClientGameLoop, EventDoneLoadingWorld, EventSetCameraAngle, EventPlayerJoinedClientSide, EventPlayerLeaveClientSide {

private boolean waszero;
private boolean isLoading;
Expand Down Expand Up @@ -80,15 +80,12 @@ public boolean isLoading() {
* <p>Initializes the virtual camera to be in line with the vanilla camera.
*/
@Override
public void onDoneLoadingPlayer() {
LOGGER.debug(LoggerMarkers.Event, "Finished loading the player position on the client");
public void onSetCameraAngle() {
LOGGER.debug(LoggerMarkers.Event, "Setting the camera angle");
VirtualCameraAngleInput cameraAngle = TASmodClient.virtual.CAMERA_ANGLE;
if (cameraAngle.getCurrentPitch() == null || cameraAngle.getCurrentYaw() == null) {
LOGGER.debug("Setting the initial pitch and yaw");
Minecraft mc = Minecraft.getMinecraft();
EntityPlayerSP player = mc.player;
cameraAngle.setCamera(player.rotationPitch, player.rotationYaw);
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayerSP player = mc.player;
cameraAngle.setCamera(player.rotationPitch, player.rotationYaw);
}

/**
Expand All @@ -105,7 +102,7 @@ public void onPlayerJoinedClientSide(EntityPlayerSP player) {
* {@inheritDoc}
*
* <p>Resets the camera angle when leaving the world.
* <p>If you later rejoin the world {@link #onDoneLoadingPlayer()} will re-initialise the camera angle
* <p>If you later rejoin the world {@link #onSetCameraAngle()} will re-initialise the camera angle
*/
@Override
public void onPlayerLeaveClientSide(EntityPlayerSP player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.minecrafttas.mctcommon.events.EventClient.EventDoneLoadingPlayer;
import com.minecrafttas.mctcommon.events.EventClient.EventSetCameraAngle;
import com.minecrafttas.mctcommon.events.EventListenerRegistry;

import net.minecraft.client.network.NetHandlerPlayClient;

@Mixin(NetHandlerPlayClient.class)
public class MixinNetHandlerPlayClient {

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