Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Merge remote-tracking branch 'origin/master' into floodgate-2.0
Dieser Commit ist enthalten in:
Commit
085c122d30
@ -169,12 +169,13 @@ public class GeyserConnector {
|
|||||||
if (config.isDebugMode()) {
|
if (config.isDebugMode()) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
config.getRemote().setAddress(InetAddress.getLoopbackAddress().getHostAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String remoteAddress = config.getRemote().getAddress();
|
String remoteAddress = config.getRemote().getAddress();
|
||||||
int remotePort = config.getRemote().getPort();
|
|
||||||
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
|
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
|
||||||
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
|
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
|
||||||
|
int remotePort;
|
||||||
try {
|
try {
|
||||||
// Searches for a server address and a port from a SRV record of the specified host name
|
// Searches for a server address and a port from a SRV record of the specified host name
|
||||||
InitialDirContext ctx = new InitialDirContext();
|
InitialDirContext ctx = new InitialDirContext();
|
||||||
|
@ -111,6 +111,8 @@ public interface GeyserConfiguration {
|
|||||||
|
|
||||||
String getServerName();
|
String getServerName();
|
||||||
|
|
||||||
|
int getCompressionLevel();
|
||||||
|
|
||||||
boolean isEnableProxyProtocol();
|
boolean isEnableProxyProtocol();
|
||||||
|
|
||||||
List<String> getProxyProtocolWhitelistedIPs();
|
List<String> getProxyProtocolWhitelistedIPs();
|
||||||
|
@ -147,6 +147,13 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||||||
@JsonProperty("server-name")
|
@JsonProperty("server-name")
|
||||||
private String serverName = GeyserConnector.NAME;
|
private String serverName = GeyserConnector.NAME;
|
||||||
|
|
||||||
|
@JsonProperty("compression-level")
|
||||||
|
private int compressionLevel = 6;
|
||||||
|
|
||||||
|
public int getCompressionLevel() {
|
||||||
|
return Math.max(-1, Math.min(compressionLevel, 9));
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("enable-proxy-protocol")
|
@JsonProperty("enable-proxy-protocol")
|
||||||
private boolean enableProxyProtocol = false;
|
private boolean enableProxyProtocol = false;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
|||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||||
|
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||||
import org.geysermc.connector.entity.living.animal.AnimalEntity;
|
import org.geysermc.connector.entity.living.animal.AnimalEntity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -44,6 +45,10 @@ public class AbstractHorseEntity extends AnimalEntity {
|
|||||||
|
|
||||||
// Specifies the size of the entity's inventory. Required to place slots in the entity.
|
// Specifies the size of the entity's inventory. Required to place slots in the entity.
|
||||||
metadata.put(EntityData.CONTAINER_BASE_SIZE, 2);
|
metadata.put(EntityData.CONTAINER_BASE_SIZE, 2);
|
||||||
|
// Add dummy health attribute since LivingEntity updates the attribute for us
|
||||||
|
attributes.put(AttributeType.HEALTH, AttributeType.HEALTH.getAttribute(20, 20));
|
||||||
|
// Add horse jump strength attribute to allow donkeys and mules to jump
|
||||||
|
attributes.put(AttributeType.HORSE_JUMP_STRENGTH, AttributeType.HORSE_JUMP_STRENGTH.getAttribute(0.5f, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,9 +90,15 @@ public class AbstractHorseEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Needed to control horses
|
// Needed to control horses
|
||||||
metadata.getFlags().setFlag(EntityFlag.CAN_POWER_JUMP, true);
|
boolean canPowerJump = entityType != EntityType.LLAMA && entityType != EntityType.TRADER_LLAMA;
|
||||||
|
metadata.getFlags().setFlag(EntityFlag.CAN_POWER_JUMP, canPowerJump);
|
||||||
metadata.getFlags().setFlag(EntityFlag.WASD_CONTROLLED, true);
|
metadata.getFlags().setFlag(EntityFlag.WASD_CONTROLLED, true);
|
||||||
|
|
||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
|
|
||||||
|
if (entityMetadata.getId() == 8) {
|
||||||
|
// Update the health attribute
|
||||||
|
updateBedrockAttributes(session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
import com.nukkitx.protocol.bedrock.packet.MobArmorEquipmentPacket;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
||||||
|
|
||||||
public class LlamaEntity extends ChestedHorseEntity {
|
public class LlamaEntity extends ChestedHorseEntity {
|
||||||
|
|
||||||
@ -52,16 +52,13 @@ public class LlamaEntity extends ChestedHorseEntity {
|
|||||||
if (entityMetadata.getId() == 20) {
|
if (entityMetadata.getId() == 20) {
|
||||||
// Bedrock treats llama decoration as armor
|
// Bedrock treats llama decoration as armor
|
||||||
MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket();
|
MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket();
|
||||||
equipmentPacket.setRuntimeEntityId(getGeyserId());
|
equipmentPacket.setRuntimeEntityId(geyserId);
|
||||||
// -1 means no armor
|
// -1 means no armor
|
||||||
if ((int) entityMetadata.getValue() != -1) {
|
int carpetIndex = (int) entityMetadata.getValue();
|
||||||
// The damage value is the dye color that Java sends us
|
if (carpetIndex > -1 && carpetIndex <= 15) {
|
||||||
|
// The damage value is the dye color that Java sends us, for pre-1.16.220
|
||||||
// The item is always going to be a carpet
|
// The item is always going to be a carpet
|
||||||
equipmentPacket.setChestplate(ItemData.builder()
|
equipmentPacket.setChestplate(ItemRegistry.CARPETS.get(carpetIndex));
|
||||||
.id(BlockTranslator.CARPET)
|
|
||||||
.damage((int) entityMetadata.getValue())
|
|
||||||
.count(1)
|
|
||||||
.build());
|
|
||||||
} else {
|
} else {
|
||||||
equipmentPacket.setChestplate(ItemData.AIR);
|
equipmentPacket.setChestplate(ItemData.AIR);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ package org.geysermc.connector.inventory;
|
|||||||
import com.nukkitx.protocol.bedrock.data.inventory.EnchantData;
|
import com.nukkitx.protocol.bedrock.data.inventory.EnchantData;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.EnchantOptionData;
|
import com.nukkitx.protocol.bedrock.data.inventory.EnchantOptionData;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -38,7 +37,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* A mutable "wrapper" around {@link EnchantOptionData}
|
* A mutable "wrapper" around {@link EnchantOptionData}
|
||||||
*/
|
*/
|
||||||
@Setter
|
|
||||||
public class GeyserEnchantOption {
|
public class GeyserEnchantOption {
|
||||||
private static final List<EnchantData> EMPTY = Collections.emptyList();
|
private static final List<EnchantData> EMPTY = Collections.emptyList();
|
||||||
/**
|
/**
|
||||||
@ -57,6 +55,12 @@ public class GeyserEnchantOption {
|
|||||||
@Getter
|
@Getter
|
||||||
private final int javaIndex;
|
private final int javaIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the enchantment details have actually changed.
|
||||||
|
* Used to mitigate weird packet spamming pre-1.14, causing the net ID to always update.
|
||||||
|
*/
|
||||||
|
private boolean hasChanged;
|
||||||
|
|
||||||
private int xpCost = 0;
|
private int xpCost = 0;
|
||||||
private int javaEnchantIndex = -1;
|
private int javaEnchantIndex = -1;
|
||||||
private int bedrockEnchantIndex = -1;
|
private int bedrockEnchantIndex = -1;
|
||||||
@ -67,8 +71,35 @@ public class GeyserEnchantOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EnchantOptionData build(GeyserSession session) {
|
public EnchantOptionData build(GeyserSession session) {
|
||||||
|
this.hasChanged = false;
|
||||||
return new EnchantOptionData(xpCost, javaIndex + 16, EMPTY,
|
return new EnchantOptionData(xpCost, javaIndex + 16, EMPTY,
|
||||||
enchantLevel == -1 ? EMPTY : Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY,
|
enchantLevel == -1 ? EMPTY : Collections.singletonList(new EnchantData(bedrockEnchantIndex, enchantLevel)), EMPTY,
|
||||||
javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), enchantLevel == -1 ? 0 : session.getNextItemNetId());
|
javaEnchantIndex == -1 ? "unknown" : ENCHANT_NAMES.get(javaEnchantIndex), enchantLevel == -1 ? 0 : session.getNextItemNetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasChanged() {
|
||||||
|
return hasChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXpCost(int xpCost) {
|
||||||
|
if (this.xpCost != xpCost) {
|
||||||
|
hasChanged = true;
|
||||||
|
this.xpCost = xpCost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnchantIndex(int javaEnchantIndex, int bedrockEnchantIndex) {
|
||||||
|
if (this.javaEnchantIndex != javaEnchantIndex) {
|
||||||
|
hasChanged = true;
|
||||||
|
this.javaEnchantIndex = javaEnchantIndex;
|
||||||
|
this.bedrockEnchantIndex = bedrockEnchantIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnchantLevel(int enchantLevel) {
|
||||||
|
if (this.enchantLevel != enchantLevel) {
|
||||||
|
hasChanged = true;
|
||||||
|
this.enchantLevel = enchantLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void onSessionCreation(BedrockServerSession bedrockServerSession) {
|
public void onSessionCreation(BedrockServerSession bedrockServerSession) {
|
||||||
bedrockServerSession.setLogging(true);
|
bedrockServerSession.setLogging(true);
|
||||||
|
bedrockServerSession.setCompressionLevel(connector.getConfig().getBedrock().getCompressionLevel());
|
||||||
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
|
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
|
||||||
// Set the packet codec to default just in case we need to send disconnect packets.
|
// Set the packet codec to default just in case we need to send disconnect packets.
|
||||||
bedrockServerSession.setPacketCodec(BedrockProtocol.DEFAULT_BEDROCK_CODEC);
|
bedrockServerSession.setPacketCodec(BedrockProtocol.DEFAULT_BEDROCK_CODEC);
|
||||||
|
@ -352,6 +352,12 @@ public class GeyserSession implements CommandSender {
|
|||||||
@Setter
|
@Setter
|
||||||
private long lastMovementTimestamp = System.currentTimeMillis();
|
private long lastMovementTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to send a ClientVehicleMovePacket for every PlayerInputPacket after idling on a boat/horse for more than 100ms
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private long lastVehicleMoveTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls whether the daylight cycle gamerule has been sent to the client, so the sun/moon remain motionless.
|
* Controls whether the daylight cycle gamerule has been sent to the client, so the sun/moon remain motionless.
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +41,8 @@ public class BedrockMoveEntityAbsoluteTranslator extends PacketTranslator<MoveEn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(MoveEntityAbsolutePacket packet, GeyserSession session) {
|
public void translate(MoveEntityAbsolutePacket packet, GeyserSession session) {
|
||||||
|
session.setLastVehicleMoveTimestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
float y = packet.getPosition().getY();
|
float y = packet.getPosition().getY();
|
||||||
if (session.getRidingVehicleEntity() instanceof BoatEntity) {
|
if (session.getRidingVehicleEntity() instanceof BoatEntity) {
|
||||||
// Remove some Y position to prevents boats from looking like they're floating in water
|
// Remove some Y position to prevents boats from looking like they're floating in water
|
||||||
|
@ -26,7 +26,15 @@
|
|||||||
package org.geysermc.connector.network.translators.bedrock;
|
package org.geysermc.connector.network.translators.bedrock;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerVehiclePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerVehiclePacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
|
||||||
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerInputPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerInputPacket;
|
||||||
|
import org.geysermc.connector.entity.BoatEntity;
|
||||||
|
import org.geysermc.connector.entity.Entity;
|
||||||
|
import org.geysermc.connector.entity.living.animal.horse.AbstractHorseEntity;
|
||||||
|
import org.geysermc.connector.entity.living.animal.horse.LlamaEntity;
|
||||||
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
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.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
@ -44,5 +52,42 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
|
|||||||
);
|
);
|
||||||
|
|
||||||
session.sendDownstreamPacket(clientSteerVehiclePacket);
|
session.sendDownstreamPacket(clientSteerVehiclePacket);
|
||||||
|
|
||||||
|
// Bedrock only sends movement vehicle packets while moving
|
||||||
|
// This allows horses to take damage while standing on magma
|
||||||
|
Entity vehicle = session.getRidingVehicleEntity();
|
||||||
|
boolean sendMovement = false;
|
||||||
|
if (vehicle instanceof AbstractHorseEntity && !(vehicle instanceof LlamaEntity)) {
|
||||||
|
sendMovement = vehicle.isOnGround();
|
||||||
|
} else if (vehicle instanceof BoatEntity) {
|
||||||
|
if (vehicle.getPassengers().size() == 1) {
|
||||||
|
// The player is the only rider
|
||||||
|
sendMovement = true;
|
||||||
|
} else {
|
||||||
|
// Check if the player is the front rider
|
||||||
|
Vector3f seatPos = session.getPlayerEntity().getMetadata().getVector3f(EntityData.RIDER_SEAT_POSITION, null);
|
||||||
|
if (seatPos != null && seatPos.getX() > 0) {
|
||||||
|
sendMovement = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sendMovement) {
|
||||||
|
long timeSinceVehicleMove = System.currentTimeMillis() - session.getLastVehicleMoveTimestamp();
|
||||||
|
if (timeSinceVehicleMove >= 100) {
|
||||||
|
Vector3f vehiclePosition = vehicle.getPosition();
|
||||||
|
Vector3f vehicleRotation = vehicle.getRotation();
|
||||||
|
|
||||||
|
if (vehicle instanceof BoatEntity) {
|
||||||
|
// Remove some Y position to prevents boats flying up
|
||||||
|
vehiclePosition = vehiclePosition.down(EntityType.BOAT.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientVehicleMovePacket clientVehicleMovePacket = new ClientVehicleMovePacket(
|
||||||
|
vehiclePosition.getX(), vehiclePosition.getY(), vehiclePosition.getZ(),
|
||||||
|
vehicleRotation.getX() - 90, vehicleRotation.getY()
|
||||||
|
);
|
||||||
|
session.sendDownstreamPacket(clientVehicleMovePacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2021 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.entity.player;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.RiderJumpPacket;
|
||||||
|
import org.geysermc.connector.entity.Entity;
|
||||||
|
import org.geysermc.connector.entity.living.animal.horse.AbstractHorseEntity;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
|
|
||||||
|
@Translator(packet = RiderJumpPacket.class)
|
||||||
|
public class BedrockRiderJumpTranslator extends PacketTranslator<RiderJumpPacket> {
|
||||||
|
@Override
|
||||||
|
public void translate(RiderJumpPacket packet, GeyserSession session) {
|
||||||
|
Entity vehicle = session.getRidingVehicleEntity();
|
||||||
|
if (vehicle instanceof AbstractHorseEntity) {
|
||||||
|
ClientPlayerStatePacket playerStatePacket = new ClientPlayerStatePacket((int) vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength());
|
||||||
|
session.sendDownstreamPacket(playerStatePacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@ import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequ
|
|||||||
import com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket;
|
import com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerEnchantOptionsPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerEnchantOptionsPacket;
|
||||||
import org.geysermc.connector.inventory.EnchantingContainer;
|
import org.geysermc.connector.inventory.EnchantingContainer;
|
||||||
|
import org.geysermc.connector.inventory.GeyserEnchantOption;
|
||||||
import org.geysermc.connector.inventory.Inventory;
|
import org.geysermc.connector.inventory.Inventory;
|
||||||
import org.geysermc.connector.inventory.PlayerInventory;
|
import org.geysermc.connector.inventory.PlayerInventory;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -67,18 +68,20 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
|
|||||||
case 6:
|
case 6:
|
||||||
// Enchantment type
|
// Enchantment type
|
||||||
slotToUpdate = key - 4;
|
slotToUpdate = key - 4;
|
||||||
int index = value;
|
// "value" here is the Java enchant ordinal, so that does not need to be changed
|
||||||
if (index != -1) {
|
// The Bedrock index might need changed, so let's look it up and see.
|
||||||
Enchantment enchantment = Enchantment.getByJavaIdentifier("minecraft:" + JavaEnchantment.values()[index].name().toLowerCase());
|
int bedrockIndex = value;
|
||||||
|
if (bedrockIndex != -1) {
|
||||||
|
Enchantment enchantment = Enchantment.getByJavaIdentifier("minecraft:" + JavaEnchantment.values()[bedrockIndex].name().toLowerCase());
|
||||||
if (enchantment != null) {
|
if (enchantment != null) {
|
||||||
// Convert the Java enchantment index to Bedrock's
|
// Convert the Java enchantment index to Bedrock's
|
||||||
index = enchantment.ordinal();
|
bedrockIndex = enchantment.ordinal();
|
||||||
} else {
|
} else {
|
||||||
index = -1;
|
// There is no Bedrock enchantment equivalent
|
||||||
|
bedrockIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enchantingInventory.getGeyserEnchantOptions()[slotToUpdate].setJavaEnchantIndex(value);
|
enchantingInventory.getGeyserEnchantOptions()[slotToUpdate].setEnchantIndex(value, bedrockIndex);
|
||||||
enchantingInventory.getGeyserEnchantOptions()[slotToUpdate].setBedrockEnchantIndex(index);
|
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
@ -91,8 +94,9 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shouldUpdate) {
|
GeyserEnchantOption enchantOption = enchantingInventory.getGeyserEnchantOptions()[slotToUpdate];
|
||||||
enchantingInventory.getEnchantOptions()[slotToUpdate] = enchantingInventory.getGeyserEnchantOptions()[slotToUpdate].build(session);
|
if (shouldUpdate && enchantOption.hasChanged()) {
|
||||||
|
enchantingInventory.getEnchantOptions()[slotToUpdate] = enchantOption.build(session);
|
||||||
PlayerEnchantOptionsPacket packet = new PlayerEnchantOptionsPacket();
|
PlayerEnchantOptionsPacket packet = new PlayerEnchantOptionsPacket();
|
||||||
packet.getOptions().addAll(Arrays.asList(enchantingInventory.getEnchantOptions()));
|
packet.getOptions().addAll(Arrays.asList(enchantingInventory.getEnchantOptions()));
|
||||||
session.sendUpstreamPacket(packet);
|
session.sendUpstreamPacket(packet);
|
||||||
|
@ -92,6 +92,10 @@ public class ItemRegistry {
|
|||||||
* Bucket item entries (excluding the milk bucket), used in BedrockInventoryTransactionTranslator.java
|
* Bucket item entries (excluding the milk bucket), used in BedrockInventoryTransactionTranslator.java
|
||||||
*/
|
*/
|
||||||
public static final IntSet BUCKETS = new IntArraySet();
|
public static final IntSet BUCKETS = new IntArraySet();
|
||||||
|
/**
|
||||||
|
* Carpet item data, used in LlamaEntity.java
|
||||||
|
*/
|
||||||
|
public static final List<ItemData> CARPETS = new ArrayList<>(16);
|
||||||
/**
|
/**
|
||||||
* Crossbow item entry, used in PillagerEntity.java
|
* Crossbow item entry, used in PillagerEntity.java
|
||||||
*/
|
*/
|
||||||
@ -452,6 +456,13 @@ public class ItemRegistry {
|
|||||||
BOATS.add(entry.getValue().get("bedrock_id").intValue());
|
BOATS.add(entry.getValue().get("bedrock_id").intValue());
|
||||||
} else if (entry.getKey().contains("bucket") && !entry.getKey().contains("milk")) {
|
} else if (entry.getKey().contains("bucket") && !entry.getKey().contains("milk")) {
|
||||||
BUCKETS.add(entry.getValue().get("bedrock_id").intValue());
|
BUCKETS.add(entry.getValue().get("bedrock_id").intValue());
|
||||||
|
} else if (entry.getKey().contains("_carpet")) {
|
||||||
|
// This should be the numerical order Java sends as an integer value for llamas
|
||||||
|
CARPETS.add(ItemData.builder()
|
||||||
|
.id(itemEntry.getBedrockId())
|
||||||
|
.damage(itemEntry.getBedrockData())
|
||||||
|
.count(1)
|
||||||
|
.blockRuntimeId(itemEntry.getBedrockBlockId()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
itemNames.add(entry.getKey());
|
itemNames.add(entry.getKey());
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.connector.network.translators.java.entity;
|
package org.geysermc.connector.network.translators.java.entity;
|
||||||
|
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
|
import org.geysermc.connector.entity.living.animal.horse.AbstractHorseEntity;
|
||||||
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.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
@ -47,6 +48,12 @@ public class JavaEntityVelocityTranslator extends PacketTranslator<ServerEntityV
|
|||||||
|
|
||||||
entity.setMotion(Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ()));
|
entity.setMotion(Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ()));
|
||||||
|
|
||||||
|
if (entity == session.getRidingVehicleEntity() && entity instanceof AbstractHorseEntity) {
|
||||||
|
// Horses for some reason teleport back when a SetEntityMotionPacket is sent while
|
||||||
|
// a player is riding on them. Java clients seem to ignore it anyways.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetEntityMotionPacket entityMotionPacket = new SetEntityMotionPacket();
|
SetEntityMotionPacket entityMotionPacket = new SetEntityMotionPacket();
|
||||||
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
|
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
entityMotionPacket.setMotion(entity.getMotion());
|
entityMotionPacket.setMotion(entity.getMotion());
|
||||||
|
@ -74,9 +74,6 @@ public abstract class BlockTranslator {
|
|||||||
private final Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
private final Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
|
||||||
private final Map<String, NbtMap> flowerPotBlocks = new HashMap<>();
|
private final Map<String, NbtMap> flowerPotBlocks = new HashMap<>();
|
||||||
|
|
||||||
// Bedrock carpet ID, used in LlamaEntity.java for decoration
|
|
||||||
public static final int CARPET = 171;
|
|
||||||
|
|
||||||
public static final Int2DoubleMap JAVA_RUNTIME_ID_TO_HARDNESS = new Int2DoubleOpenHashMap();
|
public static final Int2DoubleMap JAVA_RUNTIME_ID_TO_HARDNESS = new Int2DoubleOpenHashMap();
|
||||||
public static final Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap();
|
public static final Int2BooleanMap JAVA_RUNTIME_ID_TO_CAN_HARVEST_WITH_HAND = new Int2BooleanOpenHashMap();
|
||||||
public static final Int2ObjectMap<String> JAVA_RUNTIME_ID_TO_TOOL_TYPE = new Int2ObjectOpenHashMap<>();
|
public static final Int2ObjectMap<String> JAVA_RUNTIME_ID_TO_TOOL_TYPE = new Int2ObjectOpenHashMap<>();
|
||||||
|
@ -23,6 +23,9 @@ bedrock:
|
|||||||
motd2: "Another Geyser server."
|
motd2: "Another Geyser server."
|
||||||
# The Server Name that will be sent to Minecraft: Bedrock Edition clients. This is visible in both the pause menu and the settings menu.
|
# The Server Name that will be sent to Minecraft: Bedrock Edition clients. This is visible in both the pause menu and the settings menu.
|
||||||
server-name: "Geyser"
|
server-name: "Geyser"
|
||||||
|
# How much to compress network traffic to the Bedrock client. The higher the number, the more CPU usage used, but
|
||||||
|
# the smaller the bandwidth used. Does not have any effect below -1 or above 9. Set to -1 to disable.
|
||||||
|
compression-level: 6
|
||||||
# Whether to enable PROXY protocol or not for clients. You DO NOT WANT this feature unless you run UDP reverse proxy
|
# Whether to enable PROXY protocol or not for clients. You DO NOT WANT this feature unless you run UDP reverse proxy
|
||||||
# in front of your Geyser instance.
|
# in front of your Geyser instance.
|
||||||
enable-proxy-protocol: false
|
enable-proxy-protocol: false
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren