3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 16:40:14 +01:00

IT BOOOOOOOOOTS

Dieser Commit ist enthalten in:
Camotoy 2024-10-21 13:50:41 -04:00
Ursprung 04128907b4
Commit aaf95effc4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
8 geänderte Dateien mit 80 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -49,6 +49,7 @@ import java.io.DataInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -60,6 +61,9 @@ public final class RecipeRegistryLoader implements RegistryLoader<String, Map<Re
@Override @Override
public Map<RecipeType, List<GeyserRecipe>> load(String input) { public Map<RecipeType, List<GeyserRecipe>> load(String input) {
if (true) {
return Collections.emptyMap();
}
Map<RecipeType, List<GeyserRecipe>> deserializedRecipes = new Object2ObjectOpenHashMap<>(); Map<RecipeType, List<GeyserRecipe>> deserializedRecipes = new Object2ObjectOpenHashMap<>();
List<NbtMap> recipes; List<NbtMap> recipes;
@ -96,7 +100,7 @@ public final class RecipeRegistryLoader implements RegistryLoader<String, Map<Re
List<NbtMap> rawInputs = recipe.getList("inputs", NbtType.COMPOUND); List<NbtMap> rawInputs = recipe.getList("inputs", NbtType.COMPOUND);
Ingredient[] javaInputs = new Ingredient[rawInputs.size()]; Ingredient[] javaInputs = new Ingredient[rawInputs.size()];
for (int i = 0; i < rawInputs.size(); i++) { for (int i = 0; i < rawInputs.size(); i++) {
javaInputs[i] = new Ingredient(new ItemStack[] {toItemStack(rawInputs.get(i), helper)}); //javaInputs[i] = new Ingredient(new ItemStack[] {toItemStack(rawInputs.get(i), helper)});
} }
deserializedRecipes.add(new GeyserShapelessRecipe(javaInputs, output)); deserializedRecipes.add(new GeyserShapelessRecipe(javaInputs, output));
} }
@ -121,7 +125,7 @@ public final class RecipeRegistryLoader implements RegistryLoader<String, Map<Re
for (int j = 0; i < shape.size() * shape.get(0).length; j++) { for (int j = 0; i < shape.size() * shape.get(0).length; j++) {
for (int index : shape.get(j)) { for (int index : shape.get(j)) {
ItemStack stack = letterToRecipe.get(index); ItemStack stack = letterToRecipe.get(index);
inputs[i++] = new Ingredient(new ItemStack[] {stack}); //inputs[i++] = new Ingredient(new ItemStack[] {stack});
} }
} }
deserializedRecipes.add(new GeyserShapedRecipe(shape.size(), shape.get(0).length, inputs, output)); deserializedRecipes.add(new GeyserShapedRecipe(shape.size(), shape.get(0).length, inputs, output));

Datei anzeigen

@ -262,7 +262,7 @@ public final class BlockRegistryPopulator {
NbtMap originalBedrockTag = buildBedrockState(blockState, entry); NbtMap originalBedrockTag = buildBedrockState(blockState, entry);
NbtMap bedrockTag = stateMapper.remap(originalBedrockTag); NbtMap bedrockTag = stateMapper.remap(originalBedrockTag);
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(bedrockTag); GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.getOrDefault(bedrockTag, airDefinition); // FIXME EEE
GeyserBedrockBlock bedrockDefinition; GeyserBedrockBlock bedrockDefinition;
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId); CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);

Datei anzeigen

@ -240,7 +240,8 @@ public class ItemRegistryPopulator {
String bedrockIdentifier = mappingItem.getBedrockIdentifier(); String bedrockIdentifier = mappingItem.getBedrockIdentifier();
ItemDefinition definition = definitions.get(bedrockIdentifier); ItemDefinition definition = definitions.get(bedrockIdentifier);
if (definition == null) { if (definition == null) {
throw new RuntimeException("Missing Bedrock ItemDefinition in version " + palette.version() + " for mapping: " + mappingItem); definition = definitions.get("minecraft:air");
//throw new RuntimeException("Missing Bedrock ItemDefinition in version " + palette.version() + " for mapping: " + mappingItem);
} }
BlockDefinition bedrockBlock = null; BlockDefinition bedrockBlock = null;

Datei anzeigen

@ -202,6 +202,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.HandPreference; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.HandPreference;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction;
import org.geysermc.mcprotocollib.protocol.data.game.setting.ChatVisibility; import org.geysermc.mcprotocollib.protocol.data.game.setting.ChatVisibility;
import org.geysermc.mcprotocollib.protocol.data.game.setting.ParticleStatus;
import org.geysermc.mcprotocollib.protocol.data.game.setting.SkinPart; import org.geysermc.mcprotocollib.protocol.data.game.setting.SkinPart;
import org.geysermc.mcprotocollib.protocol.data.game.statistic.CustomStatistic; import org.geysermc.mcprotocollib.protocol.data.game.statistic.CustomStatistic;
import org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic; import org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic;
@ -1966,7 +1967,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
public void sendJavaClientSettings() { public void sendJavaClientSettings() {
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale(), ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale(),
getRenderDistance(), ChatVisibility.FULL, true, SKIN_PARTS, getRenderDistance(), ChatVisibility.FULL, true, SKIN_PARTS,
HandPreference.RIGHT_HAND, false, true); HandPreference.RIGHT_HAND, false, true, ParticleStatus.ALL); // TODO particle status
sendDownstreamPacket(clientSettingsPacket); sendDownstreamPacket(clientSettingsPacket);
} }

Datei anzeigen

@ -0,0 +1,52 @@
/*
* 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.entity;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.vehicle.ClientVehicle;
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.ingame.clientbound.entity.ClientboundEntityPositionSyncPacket;
@Translator(packet = ClientboundEntityPositionSyncPacket.class)
public class JavaEntityPositionSyncTranslator extends PacketTranslator<ClientboundEntityPositionSyncPacket> {
@Override
public void translate(GeyserSession session, ClientboundEntityPositionSyncPacket packet) {
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getId());
if (entity == null) return;
Vector3d pos = packet.getPosition();
if (entity instanceof ClientVehicle clientVehicle) {
clientVehicle.getVehicleComponent().moveAbsolute(pos.getX(), pos.getY(), pos.getZ());
}
entity.teleport(pos.toFloat(), packet.getXRot(), packet.getYRot(), packet.isOnGround());
}
}

Datei anzeigen

@ -25,26 +25,16 @@
package org.geysermc.geyser.translator.protocol.java.entity; package org.geysermc.geyser.translator.protocol.java.entity;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.vehicle.ClientVehicle;
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.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
@Translator(packet = ClientboundTeleportEntityPacket.class) @Translator(packet = ClientboundTeleportEntityPacket.class)
public class JavaTeleportEntityTranslator extends PacketTranslator<ClientboundTeleportEntityPacket> { public class JavaTeleportEntityTranslator extends PacketTranslator<ClientboundTeleportEntityPacket> {
@Override @Override
public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) { public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) {
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId()); session.getGeyser().getLogger().info(packet.toString());
if (entity == null) return;
if (entity instanceof ClientVehicle clientVehicle) {
clientVehicle.getVehicleComponent().moveAbsolute(packet.getX(), packet.getY(), packet.getZ());
}
entity.teleport(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), packet.isOnGround());
} }
} }

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.translator.protocol.java.entity.player; package org.geysermc.geyser.translator.protocol.java.entity.player;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PositionElement; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PositionElement;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
@ -50,14 +51,15 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
return; return;
SessionPlayerEntity entity = session.getPlayerEntity(); SessionPlayerEntity entity = session.getPlayerEntity();
Vector3d pos = packet.getPosition();
if (!session.isSpawned()) { if (!session.isSpawned()) {
// TODO this behavior seems outdated (1.21.2).
// The server sends an absolute teleport everytime the player is respawned // The server sends an absolute teleport everytime the player is respawned
Vector3f pos = packet.getPosition().toFloat(); entity.setPosition(pos.toFloat());
entity.setPosition(pos); entity.setYaw(packet.getXRot());
entity.setYaw(packet.getYaw()); entity.setPitch(packet.getYRot());
entity.setPitch(packet.getPitch()); entity.setHeadYaw(packet.getXRot());
entity.setHeadYaw(packet.getYaw());
RespawnPacket respawnPacket = new RespawnPacket(); RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.setRuntimeEntityId(0); // Bedrock server behavior respawnPacket.setRuntimeEntityId(0); // Bedrock server behavior
@ -98,15 +100,15 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
} }
// If coordinates are relative, then add to the existing coordinate // If coordinates are relative, then add to the existing coordinate
double newX = packet.getX() + double newX = pos.getX() +
(packet.getRelatives().contains(PositionElement.X) ? entity.getPosition().getX() : 0); (packet.getRelatives().contains(PositionElement.X) ? entity.getPosition().getX() : 0);
double newY = packet.getY() + double newY = pos.getY() +
(packet.getRelatives().contains(PositionElement.Y) ? entity.getPosition().getY() - EntityDefinitions.PLAYER.offset() : 0); (packet.getRelatives().contains(PositionElement.Y) ? entity.getPosition().getY() - EntityDefinitions.PLAYER.offset() : 0);
double newZ = packet.getZ() + double newZ = pos.getZ() +
(packet.getRelatives().contains(PositionElement.Z) ? entity.getPosition().getZ() : 0); (packet.getRelatives().contains(PositionElement.Z) ? entity.getPosition().getZ() : 0);
float newPitch = packet.getPitch() + (packet.getRelatives().contains(PositionElement.X_ROT) ? entity.getPitch() : 0); float newPitch = packet.getYRot() + (packet.getRelatives().contains(PositionElement.Y_ROT) ? entity.getPitch() : 0);
float newYaw = packet.getYaw() + (packet.getRelatives().contains(PositionElement.Y_ROT) ? entity.getYaw() : 0); float newYaw = packet.getXRot() + (packet.getRelatives().contains(PositionElement.X_ROT) ? entity.getYaw() : 0);
int id = packet.getId(); int id = packet.getId();

Datei anzeigen

@ -28,6 +28,7 @@ package org.geysermc.geyser.translator.protocol.java.inventory;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType; import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerSlotType;
import org.cloudburstmc.protocol.bedrock.data.inventory.FullContainerName; import org.cloudburstmc.protocol.bedrock.data.inventory.FullContainerName;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack; import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient; import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId; import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId;
@ -175,8 +176,8 @@ public class JavaContainerSetSlotTranslator extends PacketTranslator<Clientbound
for (int col = firstCol; col < width + firstCol; col++) { for (int col = firstCol; col < width + firstCol; col++) {
GeyserItemStack geyserItemStack = inventory.getItem(col + (row * gridDimensions) + 1); GeyserItemStack geyserItemStack = inventory.getItem(col + (row * gridDimensions) + 1);
ingredients[index] = geyserItemStack.getItemData(session); ingredients[index] = geyserItemStack.getItemData(session);
ItemStack[] itemStacks = new ItemStack[] {geyserItemStack.isEmpty() ? null : geyserItemStack.getItemStack(1)}; int[] items = new int[] {geyserItemStack.isEmpty() ? 0 : geyserItemStack.getJavaId()};
javaIngredients[index] = new Ingredient(itemStacks); javaIngredients[index] = new Ingredient(new HolderSet(items));
InventorySlotPacket slotPacket = new InventorySlotPacket(); InventorySlotPacket slotPacket = new InventorySlotPacket();
slotPacket.setContainerId(ContainerId.UI); slotPacket.setContainerId(ContainerId.UI);