Implement events and helpers needed by Simple RPC

This commit is contained in:
2023-05-29 18:26:20 +02:00
parent bb49e8052b
commit 5a1492a25a
15 changed files with 273 additions and 8 deletions

View File

@@ -0,0 +1,22 @@
package com.hypherionmc.craterlib.api.event.client;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import net.minecraft.client.multiplayer.ClientLevel;
public class CraterClientTickEvent extends CraterEvent {
private final ClientLevel level;
public CraterClientTickEvent(ClientLevel level) {
this.level = level;
}
public ClientLevel getLevel() {
return level;
}
@Override
public boolean canCancel() {
return false;
}
}

View File

@@ -0,0 +1,31 @@
package com.hypherionmc.craterlib.api.event.client;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import com.mojang.realmsclient.dto.RealmsServer;
import net.minecraft.world.entity.player.Player;
public class CraterSinglePlayerEvent extends CraterEvent {
private final Player player;
public CraterSinglePlayerEvent(Player player) {
this.player = player;
}
public Player getPlayer() {
return player;
}
@Override
public boolean canCancel() {
return false;
}
public static class PlayerLogin extends CraterSinglePlayerEvent {
public PlayerLogin(Player player) {
super(player);
}
}
}

View File

@@ -0,0 +1,29 @@
package com.hypherionmc.craterlib.api.event.client;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
public class EarlyInitEvent extends CraterEvent {
private final Minecraft minecraft;
private final Options options;
public EarlyInitEvent(Minecraft minecraft, Options options) {
this.minecraft = minecraft;
this.options = options;
}
public Minecraft getMinecraft() {
return minecraft;
}
public Options getOptions() {
return options;
}
@Override
public boolean canCancel() {
return false;
}
}

View File

@@ -0,0 +1,22 @@
package com.hypherionmc.craterlib.api.event.client;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import com.mojang.realmsclient.dto.RealmsServer;
public class PlayerJoinRealmEvent extends CraterEvent {
private final RealmsServer server;
public PlayerJoinRealmEvent(RealmsServer server) {
this.server = server;
}
public RealmsServer getServer() {
return server;
}
@Override
public boolean canCancel() {
return false;
}
}

View File

@@ -0,0 +1,49 @@
package com.hypherionmc.craterlib.api.event.client;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import net.minecraft.client.gui.screens.Screen;
import java.util.Objects;
public class ScreenEvent extends CraterEvent {
private final Screen screen;
protected ScreenEvent(Screen screen) {
this.screen = Objects.requireNonNull(screen);
}
public Screen getScreen() {
return screen;
}
@Override
public boolean canCancel() {
return false;
}
public static class Opening extends ScreenEvent {
private final Screen currentScreen;
private Screen newScreen;
public Opening(Screen currentScreen, Screen newScreen) {
super(newScreen);
this.currentScreen = currentScreen;
this.newScreen = newScreen;
}
public Screen getCurrentScreen() {
return currentScreen;
}
public Screen getNewScreen() {
return newScreen;
}
public void setNewScreen(Screen newScreen) {
this.newScreen = newScreen;
}
}
}

View File

@@ -1,17 +1,17 @@
package com.hypherionmc.craterlib.api.event.server;
import com.hypherionmc.craterlib.core.event.CraterEvent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.server.level.ServerPlayer;
public class CraterPlayerEvent extends CraterEvent {
private final Player player;
private final ServerPlayer player;
public CraterPlayerEvent(Player player) {
public CraterPlayerEvent(ServerPlayer player) {
this.player = player;
}
public Player getPlayer() {
public ServerPlayer getPlayer() {
return player;
}
@@ -22,7 +22,7 @@ public class CraterPlayerEvent extends CraterEvent {
public static class PlayerLoggedIn extends CraterPlayerEvent {
public PlayerLoggedIn(Player player) {
public PlayerLoggedIn(ServerPlayer player) {
super(player);
}
@@ -30,7 +30,7 @@ public class CraterPlayerEvent extends CraterEvent {
public static class PlayerLoggedOut extends CraterPlayerEvent {
public PlayerLoggedOut(Player player) {
public PlayerLoggedOut(ServerPlayer player) {
super(player);
}