mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +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)
|
// connection null during Player initialization (due to #super call)
|
||||||
self = playerConnection != null && playerConnection.getConnectionState() == ConnectionState.PLAY;
|
self = playerConnection != null && playerConnection.getConnectionState() == ConnectionState.PLAY;
|
||||||
}
|
}
|
||||||
|
EntityPropertiesPacket propertiesPacket = getPropertiesPacket(Collections.singleton(attributeInstance));
|
||||||
if (self) {
|
if (self) {
|
||||||
sendPacketToViewersAndSelf(getPropertiesPacket());
|
sendPacketToViewersAndSelf(propertiesPacket);
|
||||||
} else {
|
} else {
|
||||||
sendPacketToViewers(getPropertiesPacket());
|
sendPacketToViewers(propertiesPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -600,8 +601,19 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
protected EntityPropertiesPacket getPropertiesPacket() {
|
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
|
// 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())
|
.filter(i -> i.getAttribute().isShared())
|
||||||
.toArray(AttributeInstance[]::new);
|
.toArray(AttributeInstance[]::new);
|
||||||
|
|
||||||
|
@ -80,7 +80,9 @@ public class CrossbowMeta extends ItemMeta implements ItemMetaBuilder.Provider<S
|
|||||||
public static class Builder extends ItemMetaBuilder {
|
public static class Builder extends ItemMetaBuilder {
|
||||||
|
|
||||||
private boolean triple;
|
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;
|
private boolean charged;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@ package net.minestom.server.listener;
|
|||||||
|
|
||||||
import net.minestom.server.entity.GameMode;
|
import net.minestom.server.entity.GameMode;
|
||||||
import net.minestom.server.entity.Player;
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.entity.metadata.PlayerMeta;
|
||||||
import net.minestom.server.event.EventDispatcher;
|
import net.minestom.server.event.EventDispatcher;
|
||||||
import net.minestom.server.event.item.ItemUpdateStateEvent;
|
import net.minestom.server.event.item.ItemUpdateStateEvent;
|
||||||
import net.minestom.server.event.player.PlayerStartDiggingEvent;
|
import net.minestom.server.event.player.PlayerStartDiggingEvent;
|
||||||
@ -99,14 +100,9 @@ public class PlayerDiggingListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (status == ClientPlayerDiggingPacket.Status.UPDATE_ITEM_STATE) {
|
} else if (status == ClientPlayerDiggingPacket.Status.UPDATE_ITEM_STATE) {
|
||||||
Player.Hand hand = null;
|
PlayerMeta meta = player.getEntityMeta();
|
||||||
if (player.isEating()) {
|
if (!meta.isHandActive()) return;
|
||||||
hand = player.getEatingHand();
|
Player.Hand hand = meta.getActiveHand();
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.refreshEating(null);
|
player.refreshEating(null);
|
||||||
player.triggerStatus((byte) 9);
|
player.triggerStatus((byte) 9);
|
||||||
|
Loading…
Reference in New Issue
Block a user