forked from GeyserMC/Geyser
Support end credits
This commit is contained in:
parent
423d02306c
commit
cc4cfd020e
3 changed files with 59 additions and 4 deletions
|
@ -157,6 +157,7 @@ public class TranslatorsInit {
|
|||
Registry.registerBedrock(InteractPacket.class, new BedrockInteractTranslator());
|
||||
Registry.registerBedrock(TextPacket.class, new BedrockTextTranslator());
|
||||
Registry.registerBedrock(RespawnPacket.class, new BedrockRespawnTranslator());
|
||||
Registry.registerBedrock(ShowCreditsPacket.class, new BedrockShowCreditsTranslator());
|
||||
|
||||
itemTranslator = new ItemTranslator();
|
||||
blockTranslator = new BlockTranslator();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,7 +25,10 @@
|
|||
|
||||
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.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.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
|
||||
|
@ -90,10 +93,18 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
|||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
break;
|
||||
case ENTER_CREDITS:
|
||||
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
|
||||
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
|
||||
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
session.getUpstream().sendPacket(showCreditsPacket);
|
||||
switch ((EnterCreditsValue) packet.getValue()) {
|
||||
case SEEN_BEFORE:
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue