Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feature/1.16.2
Dieser Commit ist enthalten in:
Commit
9a3a7ef50f
@ -36,12 +36,11 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket;
|
||||
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.ItemFrameEntity;
|
||||
import org.geysermc.connector.entity.living.merchant.AbstractMerchantEntity;
|
||||
@ -98,11 +97,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
false);
|
||||
session.sendDownstreamPacket(blockPacket);
|
||||
|
||||
// Otherwise boats will not be able to be placed in survival
|
||||
if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BOAT.getBedrockId()) {
|
||||
// Otherwise boats will not be able to be placed in survival and buckets wont work on mobile
|
||||
if (packet.getItemInHand() != null && (packet.getItemInHand().getId() == ItemRegistry.BOAT.getBedrockId() || packet.getItemInHand().getId() == ItemRegistry.BUCKET.getBedrockId())) {
|
||||
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(itemPacket);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3i blockPos = packet.getBlockPosition();
|
||||
// TODO: Find a better way to do this?
|
||||
@ -136,9 +135,16 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
break;
|
||||
case 1:
|
||||
ItemStack shieldSlot = session.getInventory().getItem(session.getInventory().getHeldItemSlot() + 36);
|
||||
// Handled in Entity.java
|
||||
if (shieldSlot != null && shieldSlot.getId() == ItemRegistry.SHIELD.getJavaId()) {
|
||||
break;
|
||||
} // Handled in Entity.java
|
||||
}
|
||||
|
||||
// Handled in ITEM_USE
|
||||
if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BUCKET.getBedrockId()) {
|
||||
break;
|
||||
}
|
||||
|
||||
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(useItemPacket);
|
||||
// Used for sleeping in beds
|
||||
|
@ -26,12 +26,13 @@
|
||||
package org.geysermc.connector.network.translators.inventory;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
|
||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.inventory.updater.CursorInventoryUpdater;
|
||||
@ -106,7 +107,9 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||
String rename;
|
||||
NbtMap tag = itemName.getTag();
|
||||
if (tag != null) {
|
||||
rename = tag.getCompound("display").getString("Name");
|
||||
String name = tag.getCompound("display").getString("Name");
|
||||
Component component = GsonComponentSerializer.gson().deserialize(name);
|
||||
rename = LegacyComponentSerializer.legacySection().serialize(component);
|
||||
} else {
|
||||
rename = "";
|
||||
}
|
||||
@ -138,8 +141,8 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||
CompoundTag displayTag = tag.get("display");
|
||||
if (displayTag != null && displayTag.contains("Name")) {
|
||||
String itemName = displayTag.get("Name").getValue().toString();
|
||||
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
|
||||
rename = message.getText();
|
||||
Component component = GsonComponentSerializer.gson().deserialize(itemName);
|
||||
rename = LegacyComponentSerializer.legacySection().serialize(component);
|
||||
} else {
|
||||
rename = "";
|
||||
}
|
||||
|
@ -56,12 +56,14 @@ public class ItemRegistry {
|
||||
public static final List<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
|
||||
public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Shield ID, used in Entity.java
|
||||
public static ItemEntry SHIELD;
|
||||
// Boat ID, used in BedrockInventoryTransactionTranslator.java
|
||||
public static ItemEntry BOAT;
|
||||
// Gold ID, used in BedrockInventoryTransactionTranslator.java
|
||||
public static ItemEntry BUCKET;
|
||||
// Gold ID, used in PiglinEntity.java
|
||||
public static ItemEntry GOLD;
|
||||
// Shield ID, used in Entity.java
|
||||
public static ItemEntry SHIELD;
|
||||
|
||||
public static int BARRIER_INDEX = 0;
|
||||
|
||||
@ -138,6 +140,9 @@ public class ItemRegistry {
|
||||
case "minecraft:shield":
|
||||
SHIELD = ITEM_ENTRIES.get(itemIndex);
|
||||
break;
|
||||
case "minecraft:bucket":
|
||||
BUCKET = ITEM_ENTRIES.get(itemIndex);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public abstract class ItemTranslator {
|
||||
|
||||
// If its not a message convert it
|
||||
if (!MessageUtils.isMessage(name)) {
|
||||
TextComponent component = LegacyComponentSerializer.legacy().deserialize(name);
|
||||
TextComponent component = LegacyComponentSerializer.legacySection().deserialize(name);
|
||||
name = GsonComponentSerializer.gson().serialize(component);
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,8 @@ public class BasicItemTranslator extends NbtItemStackTranslator {
|
||||
String message = tag.getValue();
|
||||
if (message == null) return null;
|
||||
TextComponent component = (TextComponent) MessageUtils.phraseJavaMessage(message);
|
||||
String legacy = LegacyComponentSerializer.legacy().serialize(component);
|
||||
if (hasFormatting(LegacyComponentSerializer.legacy().deserialize(legacy))) {
|
||||
String legacy = LegacyComponentSerializer.legacySection().serialize(component);
|
||||
if (hasFormatting(LegacyComponentSerializer.legacySection().deserialize(legacy))) {
|
||||
return "§r" + legacy;
|
||||
}
|
||||
return legacy;
|
||||
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
@ -48,8 +49,9 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||
EntityEventPacket entityEventPacket = new EntityEventPacket();
|
||||
entityEventPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
switch (packet.getStatus()) {
|
||||
// EntityEventType.HURT sends extra data depending on the type of damage. However this appears to have no visual changes
|
||||
case LIVING_BURN:
|
||||
case LIVING_DROWN:
|
||||
entityEventPacket.setData(9);
|
||||
case LIVING_HURT:
|
||||
case LIVING_HURT_SWEET_BERRY_BUSH:
|
||||
entityEventPacket.setType(EntityEventType.HURT);
|
||||
@ -88,7 +90,11 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||
entityEventPacket.setType(EntityEventType.CONSUME_TOTEM);
|
||||
break;
|
||||
case SHEEP_GRAZE_OR_TNT_CART_EXPLODE:
|
||||
entityEventPacket.setType(EntityEventType.PRIME_TNT_MINECART);
|
||||
if (entity.getEntityType() == EntityType.SHEEP) {
|
||||
entityEventPacket.setType(EntityEventType.EAT_GRASS);
|
||||
} else {
|
||||
entityEventPacket.setType(EntityEventType.PRIME_TNT_MINECART);
|
||||
}
|
||||
break;
|
||||
case IRON_GOLEM_HOLD_POPPY:
|
||||
entityEventPacket.setType(EntityEventType.GOLEM_FLOWER_OFFER);
|
||||
|
@ -259,7 +259,7 @@ public class MessageUtils {
|
||||
|
||||
public static String getBedrockMessage(String message) {
|
||||
Component component = phraseJavaMessage(message);
|
||||
return LegacyComponentSerializer.legacy().serialize(component);
|
||||
return LegacyComponentSerializer.legacySection().serialize(component);
|
||||
}
|
||||
|
||||
public static Component phraseJavaMessage(String message) {
|
||||
@ -267,7 +267,7 @@ public class MessageUtils {
|
||||
}
|
||||
|
||||
public static String getJavaMessage(String message) {
|
||||
Component component = LegacyComponentSerializer.legacy().deserialize(message);
|
||||
Component component = LegacyComponentSerializer.legacySection().deserialize(message);
|
||||
return GsonComponentSerializer.gson().serialize(component);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren