Support end credits

This commit is contained in:
AJ Ferguson 2019-12-30 19:26:11 -09:00
parent 423d02306c
commit cc4cfd020e
3 changed files with 59 additions and 4 deletions

View file

@ -157,6 +157,7 @@ public class TranslatorsInit {
Registry.registerBedrock(InteractPacket.class, new BedrockInteractTranslator()); Registry.registerBedrock(InteractPacket.class, new BedrockInteractTranslator());
Registry.registerBedrock(TextPacket.class, new BedrockTextTranslator()); Registry.registerBedrock(TextPacket.class, new BedrockTextTranslator());
Registry.registerBedrock(RespawnPacket.class, new BedrockRespawnTranslator()); Registry.registerBedrock(RespawnPacket.class, new BedrockRespawnTranslator());
Registry.registerBedrock(ShowCreditsPacket.class, new BedrockShowCreditsTranslator());
itemTranslator = new ItemTranslator(); itemTranslator = new ItemTranslator();
blockTranslator = new BlockTranslator(); blockTranslator = new BlockTranslator();

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2019 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector.network.translators.bedrock;
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
import com.nukkitx.protocol.bedrock.packet.ShowCreditsPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPacket> {
@Override
public void translate(ShowCreditsPacket packet, GeyserSession session) {
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getDownstream().getSession().send(javaRespawnPacket);
}
}
}

View file

@ -25,7 +25,10 @@
package org.geysermc.connector.network.translators.java.world; package org.geysermc.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.world.notify.EnterCreditsValue;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
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.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityDataDictionary; import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
@ -90,10 +93,18 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
session.getUpstream().sendPacket(entityDataPacket); session.getUpstream().sendPacket(entityDataPacket);
break; break;
case ENTER_CREDITS: case ENTER_CREDITS:
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket(); switch ((EnterCreditsValue) packet.getValue()) {
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS); case SEEN_BEFORE:
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId()); ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getUpstream().sendPacket(showCreditsPacket); session.getDownstream().getSession().send(javaRespawnPacket);
break;
case FIRST_TIME:
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
session.getUpstream().sendPacket(showCreditsPacket);
break;
}
break; break;
default: default:
break; break;