mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Merge branch 'master' into new-block-api
This commit is contained in:
commit
3917d3cb1d
@ -483,10 +483,11 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
// connection null during Player initialization (due to #super call)
|
||||
self = playerConnection != null && playerConnection.getConnectionState() == ConnectionState.PLAY;
|
||||
}
|
||||
EntityPropertiesPacket propertiesPacket = getPropertiesPacket(Collections.singleton(attributeInstance));
|
||||
if (self) {
|
||||
sendPacketToViewersAndSelf(getPropertiesPacket());
|
||||
sendPacketToViewersAndSelf(propertiesPacket);
|
||||
} else {
|
||||
sendPacketToViewers(getPropertiesPacket());
|
||||
sendPacketToViewers(propertiesPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -600,8 +601,19 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
*/
|
||||
@NotNull
|
||||
protected EntityPropertiesPacket getPropertiesPacket() {
|
||||
return getPropertiesPacket(attributeModifiers.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link EntityPropertiesPacket} for this entity with the specified attribute values.
|
||||
*
|
||||
* @param attributes the attributes to include in the packet
|
||||
* @return an {@link EntityPropertiesPacket} linked to this entity
|
||||
*/
|
||||
@NotNull
|
||||
protected EntityPropertiesPacket getPropertiesPacket(@NotNull Collection<AttributeInstance> attributes) {
|
||||
// Get all the attributes which should be sent to the client
|
||||
final AttributeInstance[] instances = attributeModifiers.values().stream()
|
||||
final AttributeInstance[] instances = attributes.stream()
|
||||
.filter(i -> i.getAttribute().isShared())
|
||||
.toArray(AttributeInstance[]::new);
|
||||
|
||||
|
@ -80,7 +80,9 @@ public class CrossbowMeta extends ItemMeta implements ItemMetaBuilder.Provider<S
|
||||
public static class Builder extends ItemMetaBuilder {
|
||||
|
||||
private boolean triple;
|
||||
private ItemStack projectile1, projectile2, projectile3 = ItemStack.AIR;
|
||||
private ItemStack projectile1 = ItemStack.AIR;
|
||||
private ItemStack projectile2 = ItemStack.AIR;
|
||||
private ItemStack projectile3 = ItemStack.AIR;
|
||||
private boolean charged;
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.metadata.PlayerMeta;
|
||||
import net.minestom.server.event.EventDispatcher;
|
||||
import net.minestom.server.event.item.ItemUpdateStateEvent;
|
||||
import net.minestom.server.event.player.PlayerStartDiggingEvent;
|
||||
@ -99,14 +100,9 @@ public class PlayerDiggingListener {
|
||||
}
|
||||
|
||||
} else if (status == ClientPlayerDiggingPacket.Status.UPDATE_ITEM_STATE) {
|
||||
Player.Hand hand = null;
|
||||
if (player.isEating()) {
|
||||
hand = player.getEatingHand();
|
||||
} else if (player.getItemInHand(Player.Hand.OFF).getMaterial().hasState()) {
|
||||
hand = Player.Hand.OFF;
|
||||
} else if (player.getItemInHand(Player.Hand.MAIN).getMaterial().hasState()) {
|
||||
hand = Player.Hand.MAIN;
|
||||
}
|
||||
PlayerMeta meta = player.getEntityMeta();
|
||||
if (!meta.isHandActive()) return;
|
||||
Player.Hand hand = meta.getActiveHand();
|
||||
|
||||
player.refreshEating(null);
|
||||
player.triggerStatus((byte) 9);
|
||||
|
Loading…
Reference in New Issue
Block a user