Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Add Gamemode Change and Titles Times Translator w/ Scoreboard Registry
Dieser Commit ist enthalten in:
Ursprung
02fc6c2427
Commit
ebd1e502f2
@ -35,6 +35,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit
|
|||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket;
|
||||||
@ -62,6 +65,9 @@ import org.geysermc.connector.network.translators.java.entity.JavaEntityPosition
|
|||||||
import org.geysermc.connector.network.translators.java.entity.JavaEntityTeleportTranslator;
|
import org.geysermc.connector.network.translators.java.entity.JavaEntityTeleportTranslator;
|
||||||
import org.geysermc.connector.network.translators.java.entity.JavaEntityVelocityTranslator;
|
import org.geysermc.connector.network.translators.java.entity.JavaEntityVelocityTranslator;
|
||||||
import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnExpOrbTranslator;
|
import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnExpOrbTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardDisplayTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardObjectiveTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.java.scoreboard.JavaUpdateScoreTranslator;
|
||||||
import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator;
|
import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator;
|
||||||
import org.geysermc.connector.network.translators.java.window.JavaOpenWindowTranslator;
|
import org.geysermc.connector.network.translators.java.window.JavaOpenWindowTranslator;
|
||||||
import org.geysermc.connector.network.translators.java.window.JavaSetSlotTranslator;
|
import org.geysermc.connector.network.translators.java.window.JavaSetSlotTranslator;
|
||||||
@ -114,6 +120,9 @@ public class TranslatorsInit {
|
|||||||
Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator());
|
Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator());
|
||||||
Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator());
|
Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator());
|
||||||
Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator());
|
Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator());
|
||||||
|
Registry.registerJava(ServerScoreboardObjectivePacket.class, new JavaScoreboardObjectiveTranslator());
|
||||||
|
Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaScoreboardDisplayTranslator());
|
||||||
|
Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator());
|
||||||
|
|
||||||
Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator());
|
Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator());
|
||||||
Registry.registerBedrock(CommandRequestPacket.class, new BedrockCommandRequestTranslator());
|
Registry.registerBedrock(CommandRequestPacket.class, new BedrockCommandRequestTranslator());
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
package org.geysermc.connector.network.translators.java;
|
package org.geysermc.connector.network.translators.java;
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3f;
|
import com.flowpowered.math.vector.Vector3f;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
@ -41,6 +43,17 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
|||||||
bedrockPacket.setUniqueEntityId(packet.getEntityId());
|
bedrockPacket.setUniqueEntityId(packet.getEntityId());
|
||||||
session.getUpstream().sendPacketImmediately(bedrockPacket);
|
session.getUpstream().sendPacketImmediately(bedrockPacket);
|
||||||
|
|
||||||
|
int gamemode = 0;
|
||||||
|
if (packet.getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
|
gamemode = 1;
|
||||||
|
} else if (packet.getGameMode().equals(GameMode.ADVENTURE)) {
|
||||||
|
gamemode = 2;
|
||||||
|
} else if (packet.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||||
|
gamemode = 3;
|
||||||
|
}
|
||||||
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
|
playerGameTypePacket.setGamemode(gamemode);
|
||||||
|
|
||||||
Vector3f pos = new Vector3f(0, 0, 0);
|
Vector3f pos = new Vector3f(0, 0, 0);
|
||||||
int chunkX = pos.getFloorX() >> 4;
|
int chunkX = pos.getFloorX() >> 4;
|
||||||
int chunkZ = pos.getFloorZ() >> 4;
|
int chunkZ = pos.getFloorZ() >> 4;
|
||||||
|
@ -54,12 +54,13 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
|
|||||||
titlePacket.setType(SetTitlePacket.Type.SET_ACTIONBAR_MESSAGE);
|
titlePacket.setType(SetTitlePacket.Type.SET_ACTIONBAR_MESSAGE);
|
||||||
titlePacket.setText(packet.getActionBar().getFullText());
|
titlePacket.setText(packet.getActionBar().getFullText());
|
||||||
break;
|
break;
|
||||||
|
case TIMES:
|
||||||
|
titlePacket.setFadeInTime(packet.getFadeIn());
|
||||||
|
titlePacket.setFadeOutTime(packet.getFadeOut());
|
||||||
|
titlePacket.setStayTime(packet.getStay());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
titlePacket.setFadeInTime(packet.getFadeIn());
|
|
||||||
titlePacket.setFadeOutTime(packet.getFadeOut());
|
|
||||||
titlePacket.setStayTime(packet.getStay());
|
|
||||||
|
|
||||||
session.getUpstream().sendPacket(titlePacket);
|
session.getUpstream().sendPacket(titlePacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
package org.geysermc.connector.network.translators.java.world;
|
package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3f;
|
import com.flowpowered.math.vector.Vector3f;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
|
||||||
@ -54,6 +56,18 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
|||||||
|
|
||||||
session.getUpstream().sendPacket(stopRainPacket);
|
session.getUpstream().sendPacket(stopRainPacket);
|
||||||
break;
|
break;
|
||||||
|
case CHANGE_GAMEMODE:
|
||||||
|
int gamemode = 0;
|
||||||
|
if (packet.getValue().equals(GameMode.CREATIVE)) {
|
||||||
|
gamemode = 1;
|
||||||
|
} else if (packet.getValue().equals(GameMode.ADVENTURE)) {
|
||||||
|
gamemode = 2;
|
||||||
|
} else if (packet.getValue().equals(GameMode.SPECTATOR)) {
|
||||||
|
gamemode = 3;
|
||||||
|
}
|
||||||
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
|
playerGameTypePacket.setGamemode(gamemode);
|
||||||
|
break;
|
||||||
case ENTER_CREDITS:
|
case ENTER_CREDITS:
|
||||||
// ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
|
// ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
|
||||||
// showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
|
// showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
|
||||||
|
@ -106,7 +106,7 @@ public class Scoreboard {
|
|||||||
displayObjectivePacket.setDisplayName(objective.getDisplayName());
|
displayObjectivePacket.setDisplayName(objective.getDisplayName());
|
||||||
displayObjectivePacket.setCriteria("dummy");
|
displayObjectivePacket.setCriteria("dummy");
|
||||||
displayObjectivePacket.setDisplaySlot("sidebar");
|
displayObjectivePacket.setDisplaySlot("sidebar");
|
||||||
displayObjectivePacket.setSortOrder(2);
|
displayObjectivePacket.setSortOrder(1);
|
||||||
session.getUpstream().sendPacket(displayObjectivePacket);
|
session.getUpstream().sendPacket(displayObjectivePacket);
|
||||||
|
|
||||||
Map<String, Score> fakeMap = new HashMap<String, Score>();
|
Map<String, Score> fakeMap = new HashMap<String, Score>();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren