forked from GeyserMC/Geyser
Merge pull request #123 from AJ-Ferguson/master
Fix compass and end credits
This commit is contained in:
commit
a4ad4a96bb
4 changed files with 60 additions and 5 deletions
|
@ -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();
|
||||||
|
|
|
@ -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;
|
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;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class JavaSpawnPositionTranslator extends PacketTranslator<ServerSpawnPos
|
||||||
SetSpawnPositionPacket spawnPositionPacket = new SetSpawnPositionPacket();
|
SetSpawnPositionPacket spawnPositionPacket = new SetSpawnPositionPacket();
|
||||||
spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||||
spawnPositionPacket.setSpawnForced(true);
|
spawnPositionPacket.setSpawnForced(true);
|
||||||
spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.PLAYER_SPAWN);
|
spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.WORLD_SPAWN);
|
||||||
session.getUpstream().sendPacket(spawnPositionPacket);
|
session.getUpstream().sendPacket(spawnPositionPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue