2019-09-29 23:25:42 +00:00
|
|
|
/*
|
2020-01-09 03:05:42 +00:00
|
|
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
2019-09-29 23:25:42 +00:00
|
|
|
*
|
|
|
|
* 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.connector.network.translators.bedrock;
|
|
|
|
|
2020-05-24 18:06:25 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
2019-09-29 23:25:42 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
2019-10-27 09:56:47 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
2019-09-29 23:25:42 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
2019-10-07 18:30:08 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
2019-09-29 23:25:42 +00:00
|
|
|
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
|
|
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
|
|
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
2019-10-07 18:30:08 +00:00
|
|
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
2020-05-03 04:06:53 +00:00
|
|
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
2019-09-29 23:25:42 +00:00
|
|
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
2020-04-23 06:01:33 +00:00
|
|
|
import com.nukkitx.math.vector.Vector3f;
|
2020-07-21 17:17:55 +00:00
|
|
|
import com.nukkitx.math.vector.Vector3i;
|
2020-04-29 20:01:53 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
2020-09-24 19:11:42 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
|
2020-09-15 00:54:19 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
|
|
|
import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
|
2020-09-24 19:11:42 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
2019-09-29 23:25:42 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket;
|
2020-07-21 17:17:55 +00:00
|
|
|
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
2020-09-15 00:54:19 +00:00
|
|
|
import org.geysermc.connector.entity.CommandBlockMinecartEntity;
|
2020-04-23 06:01:33 +00:00
|
|
|
import org.geysermc.connector.entity.Entity;
|
2020-05-03 04:06:53 +00:00
|
|
|
import org.geysermc.connector.entity.ItemFrameEntity;
|
2020-06-06 04:04:05 +00:00
|
|
|
import org.geysermc.connector.entity.living.merchant.AbstractMerchantEntity;
|
2020-04-23 06:01:33 +00:00
|
|
|
import org.geysermc.connector.inventory.Inventory;
|
|
|
|
import org.geysermc.connector.network.session.GeyserSession;
|
|
|
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
|
|
|
import org.geysermc.connector.network.translators.Translator;
|
2020-05-25 01:07:05 +00:00
|
|
|
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
2020-04-23 06:01:33 +00:00
|
|
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
2020-05-25 01:07:05 +00:00
|
|
|
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
2020-05-02 06:06:22 +00:00
|
|
|
import org.geysermc.connector.network.translators.sound.EntitySoundInteractionHandler;
|
2020-04-29 20:01:53 +00:00
|
|
|
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
2020-04-23 06:01:33 +00:00
|
|
|
import org.geysermc.connector.utils.InventoryUtils;
|
|
|
|
|
2020-03-24 04:24:17 +00:00
|
|
|
@Translator(packet = InventoryTransactionPacket.class)
|
2019-09-29 23:25:42 +00:00
|
|
|
public class BedrockInventoryTransactionTranslator extends PacketTranslator<InventoryTransactionPacket> {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void translate(InventoryTransactionPacket packet, GeyserSession session) {
|
|
|
|
switch (packet.getTransactionType()) {
|
2019-10-20 21:25:41 +00:00
|
|
|
case NORMAL:
|
|
|
|
Inventory inventory = session.getInventoryCache().getOpenInventory();
|
2020-01-31 01:05:57 +00:00
|
|
|
if (inventory == null) inventory = session.getInventory();
|
2020-05-25 01:07:05 +00:00
|
|
|
InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType()).translateActions(session, inventory, packet.getActions());
|
2019-10-20 21:25:41 +00:00
|
|
|
break;
|
|
|
|
case INVENTORY_MISMATCH:
|
|
|
|
Inventory inv = session.getInventoryCache().getOpenInventory();
|
2020-01-31 01:05:57 +00:00
|
|
|
if (inv == null) inv = session.getInventory();
|
2020-05-25 01:07:05 +00:00
|
|
|
InventoryTranslator.INVENTORY_TRANSLATORS.get(inv.getWindowType()).updateInventory(session, inv);
|
2020-01-31 01:05:57 +00:00
|
|
|
InventoryUtils.updateCursor(session);
|
2019-11-28 03:55:58 +00:00
|
|
|
break;
|
2019-09-29 23:25:42 +00:00
|
|
|
case ITEM_USE:
|
2020-04-10 18:46:29 +00:00
|
|
|
switch (packet.getActionType()) {
|
|
|
|
case 0:
|
2020-09-24 16:54:18 +00:00
|
|
|
// Check to make sure the client isn't spamming interaction
|
|
|
|
// Based on Nukkit 1.0, with changes to ensure holding down still works
|
|
|
|
boolean hasAlreadyClicked = System.currentTimeMillis() - session.getLastInteractionTime() < 110.0 &&
|
|
|
|
packet.getBlockPosition().distanceSquared(session.getLastInteractionPosition()) < 0.00001;
|
|
|
|
session.setLastInteractionPosition(packet.getBlockPosition());
|
|
|
|
if (hasAlreadyClicked) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
// Only update the interaction time if it's valid - that way holding down still works.
|
|
|
|
session.setLastInteractionTime(System.currentTimeMillis());
|
|
|
|
}
|
2020-05-02 20:44:05 +00:00
|
|
|
|
|
|
|
// Bedrock sends block interact code for a Java entity so we send entity code back to Java
|
|
|
|
if (BlockTranslator.isItemFrame(packet.getBlockRuntimeId()) &&
|
|
|
|
session.getEntityCache().getEntityByJavaId(ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition())) != null) {
|
|
|
|
Vector3f vector = packet.getClickPosition();
|
|
|
|
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
2020-05-02 20:44:05 +00:00
|
|
|
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND, session.isSneaking());
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(interactPacket);
|
|
|
|
session.sendDownstreamPacket(interactAtPacket);
|
2020-05-02 20:44:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-10 18:46:29 +00:00
|
|
|
ClientPlayerPlaceBlockPacket blockPacket = new ClientPlayerPlaceBlockPacket(
|
|
|
|
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
|
2020-06-23 00:11:09 +00:00
|
|
|
BlockFace.values()[packet.getBlockFace()],
|
2020-04-10 18:46:29 +00:00
|
|
|
Hand.MAIN_HAND,
|
|
|
|
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
|
|
|
|
false);
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(blockPacket);
|
2020-05-23 21:39:17 +00:00
|
|
|
|
2020-07-21 17:17:55 +00:00
|
|
|
// Otherwise boats will not be able to be placed in survival and buckets wont work on mobile
|
2020-09-24 19:11:42 +00:00
|
|
|
if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BOAT.getBedrockId()) {
|
|
|
|
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
|
|
|
session.sendDownstreamPacket(itemPacket);
|
|
|
|
}
|
2020-09-12 13:47:43 +00:00
|
|
|
// Check actions, otherwise buckets may be activated when block inventories are accessed
|
2020-09-24 19:11:42 +00:00
|
|
|
// But don't check actions if the item damage is 0
|
|
|
|
else if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BUCKET.getBedrockId() &&
|
|
|
|
(packet.getItemInHand().getDamage() == 0 || !packet.getActions().isEmpty())) {
|
|
|
|
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
|
|
|
session.sendDownstreamPacket(itemPacket);
|
|
|
|
|
|
|
|
// Let the server decide if the bucket item should change, not the client, and revert the changes the client made
|
|
|
|
InventorySlotPacket slotPacket = new InventorySlotPacket();
|
|
|
|
slotPacket.setContainerId(ContainerId.INVENTORY);
|
|
|
|
slotPacket.setSlot(packet.getHotbarSlot());
|
|
|
|
slotPacket.setItem(packet.getItemInHand());
|
|
|
|
session.sendUpstreamPacket(slotPacket);
|
2020-07-21 17:17:55 +00:00
|
|
|
}
|
2020-05-23 21:39:17 +00:00
|
|
|
|
2020-09-15 00:54:19 +00:00
|
|
|
if (packet.getActions().isEmpty()) {
|
|
|
|
if (session.getOpPermissionLevel() >= 2 && session.getGameMode() == GameMode.CREATIVE) {
|
|
|
|
// Otherwise insufficient permissions
|
|
|
|
int blockState = BlockTranslator.getJavaBlockState(packet.getBlockRuntimeId());
|
|
|
|
String blockName = BlockTranslator.getJavaIdBlockMap().inverse().getOrDefault(blockState, "");
|
|
|
|
// In the future this can be used for structure blocks too, however not all elements
|
|
|
|
// are available in each GUI
|
|
|
|
if (blockName.contains("jigsaw")) {
|
|
|
|
ContainerOpenPacket openPacket = new ContainerOpenPacket();
|
|
|
|
openPacket.setBlockPosition(packet.getBlockPosition());
|
|
|
|
openPacket.setId((byte) 1);
|
|
|
|
openPacket.setType(ContainerType.JIGSAW_EDITOR);
|
|
|
|
openPacket.setUniqueEntityId(-1);
|
|
|
|
session.sendUpstreamPacket(openPacket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-29 20:01:53 +00:00
|
|
|
Vector3i blockPos = packet.getBlockPosition();
|
2020-04-23 04:40:49 +00:00
|
|
|
// TODO: Find a better way to do this?
|
2020-06-23 00:11:09 +00:00
|
|
|
switch (packet.getBlockFace()) {
|
2020-04-23 04:40:49 +00:00
|
|
|
case 0:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.sub(0, 1, 0);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.add(0, 1, 0);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.sub(0, 0, 1);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.add(0, 0, 1);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.sub(1, 0, 0);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-04-29 20:01:53 +00:00
|
|
|
blockPos = blockPos.add(1, 0, 0);
|
2020-04-23 04:40:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-25 01:07:05 +00:00
|
|
|
ItemEntry handItem = ItemRegistry.getItem(packet.getItemInHand());
|
2020-04-23 06:01:33 +00:00
|
|
|
if (handItem.isBlock()) {
|
2020-04-29 20:01:53 +00:00
|
|
|
session.setLastBlockPlacePosition(blockPos);
|
2020-04-23 06:01:33 +00:00
|
|
|
session.setLastBlockPlacedId(handItem.getJavaIdentifier());
|
|
|
|
}
|
2020-04-30 05:21:02 +00:00
|
|
|
session.setInteracting(true);
|
2020-04-10 18:46:29 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-05-24 18:06:25 +00:00
|
|
|
ItemStack shieldSlot = session.getInventory().getItem(session.getInventory().getHeldItemSlot() + 36);
|
2020-07-21 17:17:55 +00:00
|
|
|
// Handled in Entity.java
|
2020-07-07 20:40:19 +00:00
|
|
|
if (shieldSlot != null && shieldSlot.getId() == ItemRegistry.SHIELD.getJavaId()) {
|
2020-04-25 03:11:28 +00:00
|
|
|
break;
|
2020-07-21 17:17:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handled in ITEM_USE
|
2020-09-24 19:11:42 +00:00
|
|
|
if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BUCKET.getBedrockId() &&
|
|
|
|
// Normal bucket, water bucket, lava bucket
|
|
|
|
(packet.getItemInHand().getDamage() == 0 || packet.getItemInHand().getDamage() == 8 || packet.getItemInHand().getDamage() == 10)) {
|
2020-07-21 17:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-10 18:46:29 +00:00
|
|
|
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(useItemPacket);
|
2020-04-10 18:46:29 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-06-19 01:44:50 +00:00
|
|
|
int blockState = session.getConnector().getWorldManager().getBlockAt(session, packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
|
|
|
|
double blockHardness = BlockTranslator.JAVA_RUNTIME_ID_TO_HARDNESS.get(blockState);
|
2020-04-29 20:47:29 +00:00
|
|
|
if (session.getGameMode() == GameMode.CREATIVE || (session.getConnector().getConfig().isCacheChunks() && blockHardness == 0)) {
|
2020-04-29 20:01:53 +00:00
|
|
|
session.setLastBlockPlacedId(null);
|
|
|
|
session.setLastBlockPlacePosition(null);
|
|
|
|
|
|
|
|
LevelEventPacket blockBreakPacket = new LevelEventPacket();
|
2020-07-07 01:38:10 +00:00
|
|
|
blockBreakPacket.setType(LevelEventType.PARTICLE_DESTROY_BLOCK);
|
2020-04-29 20:01:53 +00:00
|
|
|
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
|
|
|
|
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendUpstreamPacket(blockBreakPacket);
|
2020-04-29 20:01:53 +00:00
|
|
|
}
|
2020-05-02 20:44:05 +00:00
|
|
|
|
|
|
|
if (ItemFrameEntity.positionContainsItemFrame(session, packet.getBlockPosition()) &&
|
|
|
|
session.getEntityCache().getEntityByJavaId(ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition())) != null) {
|
|
|
|
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.ATTACK, session.isSneaking());
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(attackPacket);
|
2020-05-02 20:44:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-10 18:46:29 +00:00
|
|
|
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
|
|
|
|
Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
|
2020-06-23 00:11:09 +00:00
|
|
|
ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getBlockFace()]);
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(breakPacket);
|
2020-04-10 18:46:29 +00:00
|
|
|
break;
|
2019-09-29 23:25:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITEM_RELEASE:
|
2019-09-29 23:39:03 +00:00
|
|
|
if (packet.getActionType() == 0) {
|
2020-04-09 02:17:29 +00:00
|
|
|
// Followed to the Minecraft Protocol specification outlined at wiki.vg
|
|
|
|
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0),
|
2020-04-09 01:29:33 +00:00
|
|
|
BlockFace.DOWN);
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(releaseItemPacket);
|
2019-09-29 23:39:03 +00:00
|
|
|
}
|
2019-09-29 23:25:42 +00:00
|
|
|
break;
|
2019-10-07 18:30:08 +00:00
|
|
|
case ITEM_USE_ON_ENTITY:
|
2019-10-16 20:32:53 +00:00
|
|
|
Entity entity = session.getEntityCache().getEntityByGeyserId(packet.getRuntimeEntityId());
|
|
|
|
if (entity == null)
|
|
|
|
return;
|
2019-10-07 18:30:08 +00:00
|
|
|
|
2020-04-18 09:13:00 +00:00
|
|
|
//https://wiki.vg/Protocol#Interact_Entity
|
|
|
|
switch (packet.getActionType()) {
|
|
|
|
case 0: //Interact
|
2020-09-15 00:54:19 +00:00
|
|
|
if (entity instanceof CommandBlockMinecartEntity) {
|
|
|
|
// The UI is handled client-side on Java Edition
|
|
|
|
// Ensure OP permission level and gamemode is appropriate
|
|
|
|
if (session.getOpPermissionLevel() < 2 || session.getGameMode() != GameMode.CREATIVE) return;
|
|
|
|
ContainerOpenPacket openPacket = new ContainerOpenPacket();
|
|
|
|
openPacket.setBlockPosition(Vector3i.ZERO);
|
|
|
|
openPacket.setId((byte) 1);
|
|
|
|
openPacket.setType(ContainerType.COMMAND_BLOCK);
|
|
|
|
openPacket.setUniqueEntityId(entity.getGeyserId());
|
|
|
|
session.sendUpstreamPacket(openPacket);
|
|
|
|
break;
|
|
|
|
}
|
2020-04-18 09:13:00 +00:00
|
|
|
Vector3f vector = packet.getClickPosition();
|
|
|
|
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
2020-04-18 09:13:00 +00:00
|
|
|
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND, session.isSneaking());
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(interactPacket);
|
|
|
|
session.sendDownstreamPacket(interactAtPacket);
|
2020-05-02 06:06:22 +00:00
|
|
|
|
|
|
|
EntitySoundInteractionHandler.handleEntityInteraction(session, vector, entity);
|
2020-06-06 04:04:05 +00:00
|
|
|
|
|
|
|
if (entity instanceof AbstractMerchantEntity) {
|
|
|
|
session.setLastInteractedVillagerEid(packet.getRuntimeEntityId());
|
|
|
|
}
|
2020-04-18 09:13:00 +00:00
|
|
|
break;
|
|
|
|
case 1: //Attack
|
|
|
|
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
2020-06-21 02:24:45 +00:00
|
|
|
InteractAction.ATTACK, session.isSneaking());
|
2020-05-05 15:51:43 +00:00
|
|
|
session.sendDownstreamPacket(attackPacket);
|
2020-04-18 09:13:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-16 20:32:53 +00:00
|
|
|
break;
|
2019-09-29 23:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|