mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
IT BOOOOOOOOOTS
This commit is contained in:
parent
04128907b4
commit
aaf95effc4
8 changed files with 80 additions and 29 deletions
|
@ -49,6 +49,7 @@ import java.io.DataInputStream;
|
|||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -60,6 +61,9 @@ public final class RecipeRegistryLoader implements RegistryLoader<String, Map<Re
|
|||
|
||||
@Override
|
||||
public Map<RecipeType, List<GeyserRecipe>> load(String input) {
|
||||
if (true) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<RecipeType, List<GeyserRecipe>> deserializedRecipes = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
List<NbtMap> recipes;
|
||||
|
@ -96,7 +100,7 @@ public final class RecipeRegistryLoader implements RegistryLoader<String, Map<Re
|
|||
List<NbtMap> rawInputs = recipe.getList("inputs", NbtType.COMPOUND);
|
||||
Ingredient[] javaInputs = new Ingredient[rawInputs.size()];
|
||||
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));
|
||||
}
|
||||
|
@ -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 index : shape.get(j)) {
|
||||
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));
|
||||
|
|
|
@ -262,7 +262,7 @@ public final class BlockRegistryPopulator {
|
|||
NbtMap originalBedrockTag = buildBedrockState(blockState, entry);
|
||||
NbtMap bedrockTag = stateMapper.remap(originalBedrockTag);
|
||||
|
||||
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.get(bedrockTag);
|
||||
GeyserBedrockBlock vanillaBedrockDefinition = blockStateOrderedMap.getOrDefault(bedrockTag, airDefinition); // FIXME EEE
|
||||
|
||||
GeyserBedrockBlock bedrockDefinition;
|
||||
CustomBlockState blockStateOverride = BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get(javaRuntimeId);
|
||||
|
|
|
@ -240,7 +240,8 @@ public class ItemRegistryPopulator {
|
|||
String bedrockIdentifier = mappingItem.getBedrockIdentifier();
|
||||
ItemDefinition definition = definitions.get(bedrockIdentifier);
|
||||
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;
|
||||
|
|
|
@ -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.PlayerAction;
|
||||
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.statistic.CustomStatistic;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic;
|
||||
|
@ -1966,7 +1967,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
public void sendJavaClientSettings() {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale(),
|
||||
getRenderDistance(), ChatVisibility.FULL, true, SKIN_PARTS,
|
||||
HandPreference.RIGHT_HAND, false, true);
|
||||
HandPreference.RIGHT_HAND, false, true, ParticleStatus.ALL); // TODO particle status
|
||||
sendDownstreamPacket(clientSettingsPacket);
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -25,26 +25,16 @@
|
|||
|
||||
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.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
|
||||
|
||||
@Translator(packet = ClientboundTeleportEntityPacket.class)
|
||||
public class JavaTeleportEntityTranslator extends PacketTranslator<ClientboundTeleportEntityPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
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());
|
||||
session.getGeyser().getLogger().info(packet.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
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.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
|
@ -50,14 +51,15 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
|
|||
return;
|
||||
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
Vector3d pos = packet.getPosition();
|
||||
|
||||
if (!session.isSpawned()) {
|
||||
// TODO this behavior seems outdated (1.21.2).
|
||||
// The server sends an absolute teleport everytime the player is respawned
|
||||
Vector3f pos = packet.getPosition().toFloat();
|
||||
entity.setPosition(pos);
|
||||
entity.setYaw(packet.getYaw());
|
||||
entity.setPitch(packet.getPitch());
|
||||
entity.setHeadYaw(packet.getYaw());
|
||||
entity.setPosition(pos.toFloat());
|
||||
entity.setYaw(packet.getXRot());
|
||||
entity.setPitch(packet.getYRot());
|
||||
entity.setHeadYaw(packet.getXRot());
|
||||
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
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
|
||||
double newX = packet.getX() +
|
||||
double newX = pos.getX() +
|
||||
(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);
|
||||
double newZ = packet.getZ() +
|
||||
double newZ = pos.getZ() +
|
||||
(packet.getRelatives().contains(PositionElement.Z) ? entity.getPosition().getZ() : 0);
|
||||
|
||||
float newPitch = packet.getPitch() + (packet.getRelatives().contains(PositionElement.X_ROT) ? entity.getPitch() : 0);
|
||||
float newYaw = packet.getYaw() + (packet.getRelatives().contains(PositionElement.Y_ROT) ? entity.getYaw() : 0);
|
||||
float newPitch = packet.getYRot() + (packet.getRelatives().contains(PositionElement.Y_ROT) ? entity.getPitch() : 0);
|
||||
float newYaw = packet.getXRot() + (packet.getRelatives().contains(PositionElement.X_ROT) ? entity.getYaw() : 0);
|
||||
|
||||
int id = packet.getId();
|
||||
|
||||
|
|
|
@ -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.FullContainerName;
|
||||
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.packet.ingame.clientbound.inventory.ClientboundContainerSetSlotPacket;
|
||||
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++) {
|
||||
GeyserItemStack geyserItemStack = inventory.getItem(col + (row * gridDimensions) + 1);
|
||||
ingredients[index] = geyserItemStack.getItemData(session);
|
||||
ItemStack[] itemStacks = new ItemStack[] {geyserItemStack.isEmpty() ? null : geyserItemStack.getItemStack(1)};
|
||||
javaIngredients[index] = new Ingredient(itemStacks);
|
||||
int[] items = new int[] {geyserItemStack.isEmpty() ? 0 : geyserItemStack.getJavaId()};
|
||||
javaIngredients[index] = new Ingredient(new HolderSet(items));
|
||||
|
||||
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
||||
slotPacket.setContainerId(ContainerId.UI);
|
||||
|
|
Loading…
Reference in a new issue