Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Start work on 1.19
Dieser Commit ist enthalten in:
Ursprung
38625312a1
Commit
5339127105
@ -153,9 +153,9 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>MCProtocolLib</artifactId>
|
<artifactId>mcprotocollib</artifactId>
|
||||||
<version>0771504</version>
|
<version>1.19-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -43,7 +43,7 @@ public class FloodgateKeyLoader {
|
|||||||
if (floodgateDataFolder != null) {
|
if (floodgateDataFolder != null) {
|
||||||
Path autoKey = floodgateDataFolder.resolve("key.pem");
|
Path autoKey = floodgateDataFolder.resolve("key.pem");
|
||||||
if (Files.exists(autoKey)) {
|
if (Files.exists(autoKey)) {
|
||||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.auto_loaded"));
|
logger.debug(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.auto_loaded"));
|
||||||
return autoKey;
|
return autoKey;
|
||||||
} else {
|
} else {
|
||||||
logger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.missing_key"));
|
logger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.missing_key"));
|
||||||
@ -52,7 +52,7 @@ public class FloodgateKeyLoader {
|
|||||||
|
|
||||||
Path floodgateKey;
|
Path floodgateKey;
|
||||||
if (config.getFloodgateKeyFile().equals("public-key.pem")) {
|
if (config.getFloodgateKeyFile().equals("public-key.pem")) {
|
||||||
logger.info("Floodgate 2.0 doesn't use a public/private key system anymore. We'll search for key.pem instead");
|
logger.debug("Floodgate 2.0 doesn't use a public/private key system anymore. We'll search for key.pem instead");
|
||||||
floodgateKey = geyserDataFolder.resolve("key.pem");
|
floodgateKey = geyserDataFolder.resolve("key.pem");
|
||||||
} else {
|
} else {
|
||||||
floodgateKey = geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
floodgateKey = geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
||||||
|
@ -66,6 +66,7 @@ import org.geysermc.geyser.session.SessionManager;
|
|||||||
import org.geysermc.geyser.session.auth.AuthType;
|
import org.geysermc.geyser.session.auth.AuthType;
|
||||||
import org.geysermc.geyser.skin.FloodgateSkinUploader;
|
import org.geysermc.geyser.skin.FloodgateSkinUploader;
|
||||||
import org.geysermc.geyser.skin.SkinProvider;
|
import org.geysermc.geyser.skin.SkinProvider;
|
||||||
|
import org.geysermc.geyser.text.ChatColor;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.text.MinecraftLocale;
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
|
import org.geysermc.geyser.translator.inventory.item.ItemTranslator;
|
||||||
@ -249,18 +250,6 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
// Ensure that PacketLib does not create an event loop for handling packets; we'll do that ourselves
|
// Ensure that PacketLib does not create an event loop for handling packets; we'll do that ourselves
|
||||||
TcpSession.USE_EVENT_LOOP_FOR_PACKETS = false;
|
TcpSession.USE_EVENT_LOOP_FOR_PACKETS = false;
|
||||||
|
|
||||||
if (config.getRemote().getAuthType() == AuthType.FLOODGATE) {
|
|
||||||
try {
|
|
||||||
Key key = new AesKeyProducer().produceFrom(config.getFloodgateKeyPath());
|
|
||||||
cipher = new AesCipher(new Base64Topping());
|
|
||||||
cipher.init(key);
|
|
||||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.loaded_key"));
|
|
||||||
skinUploader = new FloodgateSkinUploader(this).start();
|
|
||||||
} catch (Exception exception) {
|
|
||||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.bad_key"), exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String branch = "unknown";
|
String branch = "unknown";
|
||||||
int buildNumber = -1;
|
int buildNumber = -1;
|
||||||
if (this.productionEnvironment()) {
|
if (this.productionEnvironment()) {
|
||||||
@ -321,14 +310,34 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
if (shouldStartListener) {
|
if (shouldStartListener) {
|
||||||
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
||||||
if (throwable == null) {
|
if (throwable == null) {
|
||||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().getAddress(), String.valueOf(config.getBedrock().getPort())));
|
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().getAddress(),
|
||||||
|
String.valueOf(config.getBedrock().getPort())));
|
||||||
} else {
|
} else {
|
||||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", config.getBedrock().getAddress(), String.valueOf(config.getBedrock().getPort())));
|
String address = config.getBedrock().getAddress();
|
||||||
throwable.printStackTrace();
|
int port = config.getBedrock().getPort();
|
||||||
|
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
|
||||||
|
if (!"0.0.0.0".equals(address)) {
|
||||||
|
logger.info(ChatColor.GREEN + "Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0");
|
||||||
|
logger.info(ChatColor.GREEN + "Then, restart this server.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).join();
|
}).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.getRemote().getAuthType() == AuthType.FLOODGATE) {
|
||||||
|
try {
|
||||||
|
Key key = new AesKeyProducer().produceFrom(config.getFloodgateKeyPath());
|
||||||
|
cipher = new AesCipher(new Base64Topping());
|
||||||
|
cipher.init(key);
|
||||||
|
logger.debug(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.loaded_key"));
|
||||||
|
// Note: this is positioned after the bind so the skin uploader doesn't try to run if Geyser fails
|
||||||
|
// to load successfully. Spigot complains about class loader if the plugin is disabled.
|
||||||
|
skinUploader = new FloodgateSkinUploader(this).start();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.severe(GeyserLocale.getLocaleStringLog("geyser.auth.floodgate.bad_key"), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config.getMetrics().isEnabled()) {
|
if (config.getMetrics().isEnabled()) {
|
||||||
metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
|
metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
|
||||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", sessionManager::size));
|
metrics.addCustomChart(new Metrics.SingleLineChart("players", sessionManager::size));
|
||||||
|
@ -36,8 +36,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class FallingBlockEntity extends Entity {
|
public class FallingBlockEntity extends Entity {
|
||||||
|
|
||||||
public FallingBlockEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, int javaId) {
|
public FallingBlockEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw, int javaId) {
|
||||||
super(session, entityId, geyserId, uuid, EntityDefinitions.FALLING_BLOCK, position, motion, yaw, pitch, 0f);
|
super(session, entityId, geyserId, uuid, EntityDefinitions.FALLING_BLOCK, position, motion, yaw, pitch, headYaw);
|
||||||
|
|
||||||
this.dirtyMetadata.put(EntityData.VARIANT, session.getBlockMappings().getBedrockBlockId(javaId));
|
this.dirtyMetadata.put(EntityData.VARIANT, session.getBlockMappings().getBedrockBlockId(javaId));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||||||
|
|
||||||
private final BoundingBox boundingBox;
|
private final BoundingBox boundingBox;
|
||||||
|
|
||||||
public FishingHookEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, PlayerEntity owner) {
|
public FishingHookEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw, PlayerEntity owner) {
|
||||||
super(session, entityId, geyserId, uuid, EntityDefinitions.FISHING_BOBBER, position, motion, yaw, pitch, 0f);
|
super(session, entityId, geyserId, uuid, EntityDefinitions.FISHING_BOBBER, position, motion, yaw, pitch, 0f);
|
||||||
|
|
||||||
this.boundingBox = new BoundingBox(0.125, 0.125, 0.125, 0.25, 0.25, 0.25);
|
this.boundingBox = new BoundingBox(0.125, 0.125, 0.125, 0.25, 0.25, 0.25);
|
||||||
|
@ -79,8 +79,8 @@ public class ItemFrameEntity extends Entity {
|
|||||||
*/
|
*/
|
||||||
private boolean changed = true;
|
private boolean changed = true;
|
||||||
|
|
||||||
public ItemFrameEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, Direction direction) {
|
public ItemFrameEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw, Direction direction) {
|
||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, 0f);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
|
||||||
NbtMapBuilder blockBuilder = NbtMap.builder()
|
NbtMapBuilder blockBuilder = NbtMap.builder()
|
||||||
.putString("name", this.definition.entityType() == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_frame" : "minecraft:frame")
|
.putString("name", this.definition.entityType() == EntityType.GLOW_ITEM_FRAME ? "minecraft:glow_frame" : "minecraft:frame")
|
||||||
|
@ -33,6 +33,7 @@ import org.geysermc.geyser.level.PaintingType;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
// TODO 1.19
|
||||||
public class PaintingEntity extends Entity {
|
public class PaintingEntity extends Entity {
|
||||||
private static final double OFFSET = -0.46875;
|
private static final double OFFSET = -0.46875;
|
||||||
private final PaintingType paintingName;
|
private final PaintingType paintingName;
|
||||||
|
42
core/src/main/java/org/geysermc/geyser/level/JavaDimension.java
Normale Datei
42
core/src/main/java/org/geysermc/geyser/level/JavaDimension.java
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2022 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.geyser.level;
|
||||||
|
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the information we store from the current Java dimension
|
||||||
|
* @param piglinSafe Whether piglins and hoglins are safe from conversion in this dimension.
|
||||||
|
* This controls if they have the shaking effect applied in the dimension.
|
||||||
|
*/
|
||||||
|
public record JavaDimension(int minY, int maxY, boolean piglinSafe) {
|
||||||
|
|
||||||
|
public static JavaDimension load(CompoundTag tag) {
|
||||||
|
// int minY = ((IntTag) dimensionTag.get("min_y")).getValue();
|
||||||
|
// int maxY = ((IntTag) dimensionTag.get("height")).getValue();
|
||||||
|
return new JavaDimension(0, 0, false);
|
||||||
|
}
|
||||||
|
}
|
@ -101,6 +101,7 @@ import org.geysermc.geyser.inventory.Inventory;
|
|||||||
import org.geysermc.geyser.inventory.PlayerInventory;
|
import org.geysermc.geyser.inventory.PlayerInventory;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
|
||||||
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
|
import org.geysermc.geyser.inventory.recipe.GeyserStonecutterData;
|
||||||
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.level.WorldManager;
|
import org.geysermc.geyser.level.WorldManager;
|
||||||
import org.geysermc.geyser.level.physics.CollisionManager;
|
import org.geysermc.geyser.level.physics.CollisionManager;
|
||||||
import org.geysermc.geyser.network.netty.LocalSession;
|
import org.geysermc.geyser.network.netty.LocalSession;
|
||||||
@ -319,11 +320,9 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
@Setter
|
@Setter
|
||||||
private String dimension = DimensionUtils.OVERWORLD;
|
private String dimension = DimensionUtils.OVERWORLD;
|
||||||
/**
|
/**
|
||||||
* Whether piglins and hoglins are safe from conversion in this dimension.
|
* All dimensions that the client could possibly connect to.
|
||||||
* This controls if they have the shaking effect applied in the dimension.
|
|
||||||
*/
|
*/
|
||||||
@Setter
|
private final Map<String, JavaDimension> dimensions = new Object2ObjectOpenHashMap<>(3);
|
||||||
private boolean dimensionPiglinSafe;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private int breakingBlock;
|
private int breakingBlock;
|
||||||
@ -1261,9 +1260,9 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
|
|
||||||
ServerboundUseItemPacket useItemPacket;
|
ServerboundUseItemPacket useItemPacket;
|
||||||
if (playerInventory.getItemInHand().getJavaId() == shield.getJavaId()) {
|
if (playerInventory.getItemInHand().getJavaId() == shield.getJavaId()) {
|
||||||
useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND, 0); //TODO
|
||||||
} else if (playerInventory.getOffhand().getJavaId() == shield.getJavaId()) {
|
} else if (playerInventory.getOffhand().getJavaId() == shield.getJavaId()) {
|
||||||
useItemPacket = new ServerboundUseItemPacket(Hand.OFF_HAND);
|
useItemPacket = new ServerboundUseItemPacket(Hand.OFF_HAND, 0);
|
||||||
} else {
|
} else {
|
||||||
// No blocking
|
// No blocking
|
||||||
return false;
|
return false;
|
||||||
@ -1292,7 +1291,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
private boolean disableBlocking() {
|
private boolean disableBlocking() {
|
||||||
if (playerEntity.getFlag(EntityFlag.BLOCKING)) {
|
if (playerEntity.getFlag(EntityFlag.BLOCKING)) {
|
||||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM,
|
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM,
|
||||||
BlockUtils.POSITION_ZERO, Direction.DOWN);
|
BlockUtils.POSITION_ZERO, Direction.DOWN, 0); //TODO
|
||||||
sendDownstreamPacket(releaseItemPacket);
|
sendDownstreamPacket(releaseItemPacket);
|
||||||
playerEntity.setFlag(EntityFlag.BLOCKING, false);
|
playerEntity.setFlag(EntityFlag.BLOCKING, false);
|
||||||
return true;
|
return true;
|
||||||
|
@ -34,15 +34,16 @@ import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||||
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.auth.AuthType;
|
import org.geysermc.geyser.session.auth.AuthType;
|
||||||
import org.geysermc.geyser.translator.level.BiomeTranslator;
|
import org.geysermc.geyser.translator.level.BiomeTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.geyser.util.ChunkUtils;
|
|
||||||
import org.geysermc.geyser.util.DimensionUtils;
|
|
||||||
import org.geysermc.geyser.util.PluginMessageUtils;
|
import org.geysermc.geyser.util.PluginMessageUtils;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Translator(packet = ClientboundLoginPacket.class)
|
@Translator(packet = ClientboundLoginPacket.class)
|
||||||
public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket> {
|
public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket> {
|
||||||
|
|
||||||
@ -51,12 +52,15 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
PlayerEntity entity = session.getPlayerEntity();
|
PlayerEntity entity = session.getPlayerEntity();
|
||||||
entity.setEntityId(packet.getEntityId());
|
entity.setEntityId(packet.getEntityId());
|
||||||
|
|
||||||
|
Map<String, JavaDimension> dimensions = session.getDimensions();
|
||||||
|
dimensions.clear();
|
||||||
|
|
||||||
// If the player is already initialized and a join game packet is sent, they
|
// If the player is already initialized and a join game packet is sent, they
|
||||||
// are swapping servers
|
// are swapping servers
|
||||||
String newDimension = DimensionUtils.getNewDimension(packet.getDimension());
|
//String newDimension = DimensionUtils.getNewDimension(packet.getDimension());
|
||||||
if (session.isSpawned()) {
|
if (session.isSpawned()) {
|
||||||
String fakeDim = DimensionUtils.getTemporaryDimension(session.getDimension(), newDimension);
|
//String fakeDim = DimensionUtils.getTemporaryDimension(session.getDimension(), newDimension);
|
||||||
DimensionUtils.switchDimension(session, fakeDim);
|
//DimensionUtils.switchDimension(session, fakeDim);
|
||||||
|
|
||||||
session.getWorldCache().removeScoreboard();
|
session.getWorldCache().removeScoreboard();
|
||||||
}
|
}
|
||||||
@ -70,7 +74,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
boolean needsSpawnPacket = !session.isSentSpawnPacket();
|
||||||
if (needsSpawnPacket) {
|
if (needsSpawnPacket) {
|
||||||
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
||||||
session.setDimension(newDimension);
|
//session.setDimension(newDimension);
|
||||||
session.connect();
|
session.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +110,13 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageChannels.getFloodgateRegisterData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newDimension.equals(session.getDimension())) {
|
// if (!newDimension.equals(session.getDimension())) {
|
||||||
DimensionUtils.switchDimension(session, newDimension);
|
// DimensionUtils.switchDimension(session, newDimension);
|
||||||
} else if (DimensionUtils.isCustomBedrockNetherId() && newDimension.equalsIgnoreCase(DimensionUtils.NETHER)) {
|
// } else if (DimensionUtils.isCustomBedrockNetherId() && newDimension.equalsIgnoreCase(DimensionUtils.NETHER)) {
|
||||||
// If the player is spawning into the "fake" nether, send them some fog
|
// // If the player is spawning into the "fake" nether, send them some fog
|
||||||
session.sendFog("minecraft:fog_hell");
|
// session.sendFog("minecraft:fog_hell");
|
||||||
}
|
// }
|
||||||
|
|
||||||
ChunkUtils.loadDimensionTag(session, packet.getDimension());
|
//ChunkUtils.loadDimensionTag(session, packet.getDimension());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,31 +25,32 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java;
|
package org.geysermc.geyser.translator.protocol.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
|
|
||||||
@Translator(packet = ClientboundChatPacket.class)
|
@Translator(packet = ClientboundSystemChatPacket.class)
|
||||||
public class JavaChatTranslator extends PacketTranslator<ClientboundChatPacket> {
|
public class JavaSystemChatTranslator extends PacketTranslator<ClientboundSystemChatPacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundChatPacket packet) {
|
public void translate(GeyserSession session, ClientboundSystemChatPacket packet) {
|
||||||
TextPacket textPacket = new TextPacket();
|
TextPacket textPacket = new TextPacket();
|
||||||
textPacket.setPlatformChatId("");
|
textPacket.setPlatformChatId("");
|
||||||
textPacket.setSourceName("");
|
textPacket.setSourceName("");
|
||||||
textPacket.setXuid(session.getAuthData().xuid());
|
textPacket.setXuid(session.getAuthData().xuid());
|
||||||
|
// TODO new types
|
||||||
textPacket.setType(switch (packet.getType()) {
|
textPacket.setType(switch (packet.getType()) {
|
||||||
case CHAT -> TextPacket.Type.CHAT;
|
case CHAT -> TextPacket.Type.CHAT;
|
||||||
case SYSTEM -> TextPacket.Type.SYSTEM;
|
case SYSTEM -> TextPacket.Type.SYSTEM;
|
||||||
case NOTIFICATION -> TextPacket.Type.TIP;
|
case GAME_INFO -> TextPacket.Type.TIP;
|
||||||
default -> TextPacket.Type.RAW;
|
default -> TextPacket.Type.RAW;
|
||||||
});
|
});
|
||||||
|
|
||||||
textPacket.setNeedsTranslation(false);
|
textPacket.setNeedsTranslation(false);
|
||||||
textPacket.setMessage(MessageTranslator.convertMessage(packet.getMessage(), session.getLocale()));
|
textPacket.setMessage(MessageTranslator.convertMessage(packet.getContent(), session.getLocale()));
|
||||||
|
|
||||||
session.sendUpstreamPacket(textPacket);
|
session.sendUpstreamPacket(textPacket);
|
||||||
}
|
}
|
@ -25,30 +25,16 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java.entity.player;
|
package org.geysermc.geyser.translator.protocol.java.entity.player;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundBlockChangedAckPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundBlockBreakAckPacket;
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.geyser.level.block.BlockStateValues;
|
|
||||||
import org.geysermc.geyser.util.ChunkUtils;
|
|
||||||
|
|
||||||
@Translator(packet = ClientboundBlockBreakAckPacket.class)
|
@Translator(packet = ClientboundBlockChangedAckPacket.class)
|
||||||
public class JavaBlockBreakAckTranslator extends PacketTranslator<ClientboundBlockBreakAckPacket> {
|
public class JavaBlockBreakAckTranslator extends PacketTranslator<ClientboundBlockChangedAckPacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundBlockBreakAckPacket packet) {
|
public void translate(GeyserSession session, ClientboundBlockChangedAckPacket packet) {
|
||||||
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
// TODO
|
||||||
if (packet.getAction() == PlayerAction.START_DIGGING && !packet.isSuccessful()) {
|
|
||||||
LevelEventPacket stopBreak = new LevelEventPacket();
|
|
||||||
stopBreak.setType(LevelEventType.BLOCK_STOP_BREAK);
|
|
||||||
stopBreak.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
|
||||||
stopBreak.setData(0);
|
|
||||||
session.setBreakingBlock(BlockStateValues.JAVA_AIR_ID);
|
|
||||||
session.sendUpstreamPacket(stopBreak);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ public class JavaAddEntityTranslator extends PacketTranslator<ClientboundAddEnti
|
|||||||
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
|
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
|
||||||
float yaw = packet.getYaw();
|
float yaw = packet.getYaw();
|
||||||
float pitch = packet.getPitch();
|
float pitch = packet.getPitch();
|
||||||
|
float headYaw = packet.getHeadYaw();
|
||||||
|
|
||||||
EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
|
EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
@ -62,11 +63,11 @@ public class JavaAddEntityTranslator extends PacketTranslator<ClientboundAddEnti
|
|||||||
Entity entity;
|
Entity entity;
|
||||||
if (packet.getType() == EntityType.FALLING_BLOCK) {
|
if (packet.getType() == EntityType.FALLING_BLOCK) {
|
||||||
entity = new FallingBlockEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
entity = new FallingBlockEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
||||||
position, motion, yaw, pitch, ((FallingBlockData) packet.getData()).getId());
|
position, motion, yaw, pitch, headYaw, ((FallingBlockData) packet.getData()).getId());
|
||||||
} else if (packet.getType() == EntityType.ITEM_FRAME || packet.getType() == EntityType.GLOW_ITEM_FRAME) {
|
} else if (packet.getType() == EntityType.ITEM_FRAME || packet.getType() == EntityType.GLOW_ITEM_FRAME) {
|
||||||
// Item frames need the hanging direction
|
// Item frames need the hanging direction
|
||||||
entity = new ItemFrameEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
entity = new ItemFrameEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
||||||
definition, position, motion, yaw, pitch, (Direction) packet.getData());
|
definition, position, motion, yaw, pitch, headYaw, (Direction) packet.getData());
|
||||||
} else if (packet.getType() == EntityType.FISHING_BOBBER) {
|
} else if (packet.getType() == EntityType.FISHING_BOBBER) {
|
||||||
// Fishing bobbers need the owner for the line
|
// Fishing bobbers need the owner for the line
|
||||||
int ownerEntityId = ((ProjectileData) packet.getData()).getOwnerId();
|
int ownerEntityId = ((ProjectileData) packet.getData()).getOwnerId();
|
||||||
@ -74,13 +75,13 @@ public class JavaAddEntityTranslator extends PacketTranslator<ClientboundAddEnti
|
|||||||
// Java clients only spawn fishing hooks with a player as its owner
|
// Java clients only spawn fishing hooks with a player as its owner
|
||||||
if (owner instanceof PlayerEntity) {
|
if (owner instanceof PlayerEntity) {
|
||||||
entity = new FishingHookEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
entity = new FishingHookEntity(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
||||||
position, motion, yaw, pitch, (PlayerEntity) owner);
|
position, motion, yaw, pitch, headYaw, (PlayerEntity) owner);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
||||||
packet.getUuid(), definition, position, motion, yaw, pitch, 0f);
|
packet.getUuid(), definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
session.getEntityCache().spawnEntity(entity);
|
session.getEntityCache().spawnEntity(entity);
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 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.geyser.translator.protocol.java.entity.spawn;
|
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddMobPacket;
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
|
||||||
import org.geysermc.geyser.registry.Registries;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
|
||||||
|
|
||||||
@Translator(packet = ClientboundAddMobPacket.class)
|
|
||||||
public class JavaAddMobTranslator extends PacketTranslator<ClientboundAddMobPacket> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void translate(GeyserSession session, ClientboundAddMobPacket packet) {
|
|
||||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
|
||||||
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
|
|
||||||
|
|
||||||
EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
|
|
||||||
if (definition == null) {
|
|
||||||
session.getGeyser().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.entity.type_null", packet.getType()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
|
||||||
packet.getUuid(), definition, position, motion, packet.getYaw(), packet.getPitch(), packet.getHeadYaw()
|
|
||||||
);
|
|
||||||
session.getEntityCache().spawnEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 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.geyser.translator.protocol.java.entity.spawn;
|
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPaintingPacket;
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
|
||||||
import org.geysermc.geyser.entity.type.PaintingEntity;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
|
||||||
import org.geysermc.geyser.level.PaintingType;
|
|
||||||
|
|
||||||
@Translator(packet = ClientboundAddPaintingPacket.class)
|
|
||||||
public class JavaAddPaintingTranslator extends PacketTranslator<ClientboundAddPaintingPacket> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void translate(GeyserSession session, ClientboundAddPaintingPacket packet) {
|
|
||||||
Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
|
||||||
|
|
||||||
PaintingEntity entity = new PaintingEntity(session, packet.getEntityId(),
|
|
||||||
session.getEntityCache().getNextEntityId().incrementAndGet(), packet.getUuid(),
|
|
||||||
position, PaintingType.getByPaintingType(packet.getPaintingType()), packet.getDirection().getHorizontalIndex());
|
|
||||||
|
|
||||||
session.getEntityCache().spawnEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren