3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-17 00:33:47 +02:00

Initial bow support

Dieser Commit ist enthalten in:
DoctorMacc 2020-04-08 21:29:33 -04:00
Ursprung ece1eeb451
Commit c393dc9f21
2 geänderte Dateien mit 16 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -41,6 +41,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket; import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket;
import org.geysermc.connector.network.translators.block.BlockTranslator;
@Translator(packet = InventoryTransactionPacket.class) @Translator(packet = InventoryTransactionPacket.class)
public class BedrockInventoryTransactionTranslator extends PacketTranslator<InventoryTransactionPacket> { public class BedrockInventoryTransactionTranslator extends PacketTranslator<InventoryTransactionPacket> {
@ -61,11 +62,18 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
break; break;
case ITEM_RELEASE: case ITEM_RELEASE:
if (packet.getActionType() == 0) { if (packet.getActionType() == 0) {
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position( ClientPlayerActionPacket releaseItemPacket;
packet.getBlockPosition().getX(), if (packet.getItemInHand().getId() == BlockTranslator.BOW) {
packet.getBlockPosition().getY(), // Followed to the Minecraft Protocol specification outlined at wiki.vg
packet.getBlockPosition().getZ() releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0),
), BlockFace.values()[packet.getFace()]); BlockFace.DOWN);
} else {
releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(
packet.getBlockPosition().getX(),
packet.getBlockPosition().getY(),
packet.getBlockPosition().getZ()
), BlockFace.values()[packet.getFace()]);
}
session.getDownstream().getSession().send(releaseItemPacket); session.getDownstream().getSession().send(releaseItemPacket);
} }
break; break;

Datei anzeigen

@ -55,6 +55,9 @@ public class BlockTranslator {
private static final Int2ObjectMap<BlockState> BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<BlockState> BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>();
private static final IntSet WATERLOGGED = new IntOpenHashSet(); private static final IntSet WATERLOGGED = new IntOpenHashSet();
// Bedrock bow ID, used in BedrockInventoryTransactionTranslator.java for bow support
public static final int BOW = 261;
// Bedrock carpet ID, used in LlamaEntity.java for decoration // Bedrock carpet ID, used in LlamaEntity.java for decoration
public static final int CARPET = 171; public static final int CARPET = 171;