mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Merge branch 'master' into block-break-particles-fix
This commit is contained in:
commit
89c41cc44d
13 changed files with 110 additions and 31 deletions
|
|
@ -14,7 +14,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
|
|||
|
||||
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!
|
||||
|
||||
### Currently supporting Minecraft Bedrock 1.20.80 - 1.21.2 and Minecraft Java 1.21
|
||||
### Currently supporting Minecraft Bedrock 1.20.80 - 1.21.3 and Minecraft Java 1.21
|
||||
|
||||
## Setting Up
|
||||
Take a look [here](https://wiki.geysermc.org/geyser/setup/) for how to set up Geyser.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import net.md_5.bungee.api.event.ProxyPingEvent;
|
|||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.ping.GeyserPingInfo;
|
||||
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ import java.net.InetSocketAddress;
|
|||
import java.net.SocketAddress;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener {
|
||||
|
|
@ -59,7 +61,17 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
|
|||
future.complete(event);
|
||||
}
|
||||
}));
|
||||
ProxyPingEvent event = future.join();
|
||||
|
||||
ProxyPingEvent event;
|
||||
|
||||
try {
|
||||
event = future.get(100, TimeUnit.MILLISECONDS);
|
||||
} catch (Throwable cause) {
|
||||
String address = GeyserImpl.getInstance().getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
|
||||
GeyserImpl.getInstance().getLogger().error("Failed to get ping information for " + address, cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerPing response = event.getResponse();
|
||||
return new GeyserPingInfo(
|
||||
response.getDescriptionComponent().toLegacyText(),
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ public final class GameProtocol {
|
|||
SUPPORTED_BEDROCK_CODECS.add(CodecProcessor.processCodec(Bedrock_v685.CODEC.toBuilder()
|
||||
.minecraftVersion("1.21.0/1.21.1")
|
||||
.build()));
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
|
||||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
|
||||
.minecraftVersion("1.21.2/1.21.3")
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ import java.net.InetSocketAddress;
|
|||
public interface IGeyserPingPassthrough {
|
||||
|
||||
/**
|
||||
* Get the MOTD of the server displayed on the multiplayer screen
|
||||
* Gets the ping information, including the MOTD and player count, from the server
|
||||
*
|
||||
* @param inetSocketAddress the ip address of the client pinging the server
|
||||
* @return string of the MOTD
|
||||
* @return the ping information
|
||||
*/
|
||||
@Nullable
|
||||
GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ public class CreativeItemRegistryPopulator {
|
|||
private static ItemData.@Nullable Builder createItemData(JsonNode itemNode, BlockMappings blockMappings, Map<String, ItemDefinition> definitions) {
|
||||
int count = 1;
|
||||
int damage = 0;
|
||||
int bedrockBlockRuntimeId;
|
||||
NbtMap tag = null;
|
||||
|
||||
String identifier = itemNode.get("id").textValue();
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ public class ItemRegistryPopulator {
|
|||
Map<Item, ItemMapping> javaItemToMapping = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
List<ItemData> creativeItems = new ArrayList<>();
|
||||
Set<String> noBlockDefinitions = new ObjectOpenHashSet<>();
|
||||
|
||||
AtomicInteger creativeNetId = new AtomicInteger();
|
||||
CreativeItemRegistryPopulator.populate(palette, definitions, itemBuilder -> {
|
||||
|
|
@ -187,6 +188,9 @@ public class ItemRegistryPopulator {
|
|||
bedrockBlockIdOverrides.put(identifier, item.getBlockDefinition());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Item mappings should also NOT have a block definition for these.
|
||||
noBlockDefinitions.add(item.getDefinition().getIdentifier());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -254,7 +258,12 @@ public class ItemRegistryPopulator {
|
|||
} else {
|
||||
// Try to get an example block runtime ID from the creative contents packet, for Bedrock identifier obtaining
|
||||
int aValidBedrockBlockId = blacklistedIdentifiers.getOrDefault(bedrockIdentifier, customBlockItemOverride != null ? customBlockItemOverride.getRuntimeId() : -1);
|
||||
if (aValidBedrockBlockId != -1 || customBlockItemOverride != null) {
|
||||
if (aValidBedrockBlockId == -1 && customBlockItemOverride == null) {
|
||||
// Fallback
|
||||
if (!noBlockDefinitions.contains(entry.getValue().getBedrockIdentifier())) {
|
||||
bedrockBlock = blockMappings.getBedrockBlock(firstBlockRuntimeId);
|
||||
}
|
||||
} else {
|
||||
// As of 1.16.220, every item requires a block runtime ID attached to it.
|
||||
// This is mostly for identifying different blocks with the same item ID - wool, slabs, some walls.
|
||||
// However, in order for some visuals and crafting to work, we need to send the first matching block state
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ package org.geysermc.geyser.registry.type;
|
|||
import it.unimi.dsi.fastutil.Pair;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||
|
|
@ -42,6 +43,7 @@ import java.util.List;
|
|||
@Value
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class ItemMapping {
|
||||
public static final ItemMapping AIR = new ItemMapping(
|
||||
"minecraft:air",
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ public class EntityCache {
|
|||
return playerEntities.values();
|
||||
}
|
||||
|
||||
public void removeAllPlayerEntities() {
|
||||
playerEntities.clear();
|
||||
}
|
||||
|
||||
public void addBossBar(UUID uuid, BossBar bossBar) {
|
||||
bossBars.put(uuid, bossBar);
|
||||
bossBar.addBossBar();
|
||||
|
|
|
|||
|
|
@ -243,8 +243,16 @@ public class SkullCache {
|
|||
}
|
||||
|
||||
public void clear() {
|
||||
for (Skull skull : skulls.values()) {
|
||||
if (skull.entity != null) {
|
||||
skull.entity.despawnEntity();
|
||||
}
|
||||
}
|
||||
skulls.clear();
|
||||
inRangeSkulls.clear();
|
||||
for (SkullPlayerEntity skull : unusedSkullEntities) {
|
||||
skull.despawnEntity();
|
||||
}
|
||||
unusedSkullEntities.clear();
|
||||
totalSkullEntities = 0;
|
||||
lastPlayerPosition = null;
|
||||
|
|
|
|||
|
|
@ -42,10 +42,9 @@ public class CampfireBlockEntityTranslator extends BlockEntityTranslator {
|
|||
public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, BlockState blockState) {
|
||||
List<NbtMap> items = javaNbt.getList("Items", NbtType.COMPOUND);
|
||||
if (items != null) {
|
||||
int i = 1;
|
||||
for (NbtMap itemTag : items) {
|
||||
bedrockNbt.put("Item" + i, getItem(session, itemTag));
|
||||
i++;
|
||||
int slot = itemTag.getByte("Slot") + 1;
|
||||
bedrockNbt.put("Item" + slot, getItem(session, itemTag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,8 +54,7 @@ public class CampfireBlockEntityTranslator extends BlockEntityTranslator {
|
|||
if (mapping == null) {
|
||||
mapping = ItemMapping.AIR;
|
||||
}
|
||||
NbtMapBuilder tagBuilder = BedrockItemBuilder.createItemNbt(mapping, tag.getByte("Count"), mapping.getBedrockData());
|
||||
tagBuilder.put("tag", NbtMap.builder().build()); // I don't think this is necessary... - Camo, 1.20.5/1.20.80
|
||||
NbtMapBuilder tagBuilder = BedrockItemBuilder.createItemNbt(mapping, tag.getInt("count"), mapping.getBedrockData());
|
||||
return tagBuilder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2024 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;
|
||||
|
||||
import org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket;
|
||||
import org.geysermc.geyser.entity.type.player.PlayerEntity;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundFinishConfigurationPacket;
|
||||
|
||||
@Translator(packet = ClientboundFinishConfigurationPacket.class)
|
||||
public class JavaFinishConfigurationPacketTranslator extends PacketTranslator<ClientboundFinishConfigurationPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundFinishConfigurationPacket packet) {
|
||||
// Clear the player list, as on Java the player list is cleared after transitioning from config to play phase
|
||||
PlayerListPacket playerListPacket = new PlayerListPacket();
|
||||
playerListPacket.setAction(PlayerListPacket.Action.REMOVE);
|
||||
for (PlayerEntity otherEntity : session.getEntityCache().getAllPlayerEntities()) {
|
||||
playerListPacket.getEntries().add(new PlayerListPacket.Entry(otherEntity.getTabListUuid()));
|
||||
}
|
||||
session.sendUpstreamPacket(playerListPacket);
|
||||
session.getEntityCache().removeAllPlayerEntities();
|
||||
}
|
||||
}
|
||||
|
|
@ -79,25 +79,6 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
// Remove extra hearts, hunger, etc.
|
||||
entity.resetAttributes();
|
||||
entity.resetMetadata();
|
||||
|
||||
// Reset weather
|
||||
if (session.isRaining()) {
|
||||
LevelEventPacket stopRainPacket = new LevelEventPacket();
|
||||
stopRainPacket.setType(LevelEvent.STOP_RAINING);
|
||||
stopRainPacket.setData(0);
|
||||
stopRainPacket.setPosition(Vector3f.ZERO);
|
||||
session.sendUpstreamPacket(stopRainPacket);
|
||||
session.setRaining(false);
|
||||
}
|
||||
|
||||
if (session.isThunder()) {
|
||||
LevelEventPacket stopThunderPacket = new LevelEventPacket();
|
||||
stopThunderPacket.setType(LevelEvent.STOP_THUNDERSTORM);
|
||||
stopThunderPacket.setData(0);
|
||||
stopThunderPacket.setPosition(Vector3f.ZERO);
|
||||
session.sendUpstreamPacket(stopThunderPacket);
|
||||
session.setThunder(false);
|
||||
}
|
||||
}
|
||||
|
||||
session.setWorldName(spawnInfo.getWorldName());
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.util;
|
|||
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||
import org.cloudburstmc.protocol.bedrock.data.PlayerActionType;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.*;
|
||||
import org.geysermc.geyser.entity.type.Entity;
|
||||
|
|
@ -110,6 +111,20 @@ public class DimensionUtils {
|
|||
// Effects are re-sent from server
|
||||
entityEffects.clear();
|
||||
|
||||
// Always reset weather, as it sometimes suddenly starts raining. See https://github.com/GeyserMC/Geyser/issues/3679
|
||||
LevelEventPacket stopRainPacket = new LevelEventPacket();
|
||||
stopRainPacket.setType(LevelEvent.STOP_RAINING);
|
||||
stopRainPacket.setData(0);
|
||||
stopRainPacket.setPosition(Vector3f.ZERO);
|
||||
session.sendUpstreamPacket(stopRainPacket);
|
||||
session.setRaining(false);
|
||||
LevelEventPacket stopThunderPacket = new LevelEventPacket();
|
||||
stopThunderPacket.setType(LevelEvent.STOP_THUNDERSTORM);
|
||||
stopThunderPacket.setData(0);
|
||||
stopThunderPacket.setPosition(Vector3f.ZERO);
|
||||
session.sendUpstreamPacket(stopThunderPacket);
|
||||
session.setThunder(false);
|
||||
|
||||
//let java server handle portal travel sound
|
||||
StopSoundPacket stopSoundPacket = new StopSoundPacket();
|
||||
stopSoundPacket.setStoppingAllSound(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue