mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 09:57:45 +01:00
Merge branch 'master' into new-block-api
# Conflicts: # src/main/java/net/minestom/server/instance/InstanceContainer.java # src/main/java/net/minestom/server/listener/BlockPlacementListener.java # src/main/java/net/minestom/server/listener/PlayerDiggingListener.java
This commit is contained in:
commit
d27b1ff1a4
@ -1318,9 +1318,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
* @param entity the entity to spectate
|
* @param entity the entity to spectate
|
||||||
*/
|
*/
|
||||||
public void spectate(@NotNull Entity entity) {
|
public void spectate(@NotNull Entity entity) {
|
||||||
CameraPacket cameraPacket = new CameraPacket();
|
playerConnection.sendPacket(new CameraPacket(entity));
|
||||||
cameraPacket.cameraId = entity.getEntityId();
|
|
||||||
playerConnection.sendPacket(cameraPacket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -637,10 +637,7 @@ public class InstanceContainer extends Instance {
|
|||||||
* @param block the new block
|
* @param block the new block
|
||||||
*/
|
*/
|
||||||
private void sendBlockChange(@NotNull Chunk chunk, @NotNull BlockPosition blockPosition, @NotNull Block block) {
|
private void sendBlockChange(@NotNull Chunk chunk, @NotNull BlockPosition blockPosition, @NotNull Block block) {
|
||||||
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
chunk.sendPacketToViewers(new BlockChangePacket(blockPosition, block.stateId()));
|
||||||
blockChangePacket.blockPosition = blockPosition;
|
|
||||||
blockChangePacket.blockStateId = block.stateId();
|
|
||||||
chunk.sendPacketToViewers(blockChangePacket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,10 +89,7 @@ public class BlockPlacementListener {
|
|||||||
//Send a block change with AIR as block to keep the client in sync,
|
//Send a block change with AIR as block to keep the client in sync,
|
||||||
//using refreshChunk results in the client not being in sync
|
//using refreshChunk results in the client not being in sync
|
||||||
//after rapid invalid block placements
|
//after rapid invalid block placements
|
||||||
BlockChangePacket blockChangePacket = new BlockChangePacket();
|
player.getPlayerConnection().sendPacket(new BlockChangePacket(blockPosition, Block.AIR.stateId()));
|
||||||
blockChangePacket.blockPosition = blockPosition;
|
|
||||||
blockChangePacket.blockStateId = Block.AIR.stateId();
|
|
||||||
player.getPlayerConnection().sendPacket(blockChangePacket);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,6 @@ public class PlayerDiggingListener {
|
|||||||
*/
|
*/
|
||||||
private static void sendAcknowledgePacket(@NotNull Player player, @NotNull BlockPosition blockPosition, Block block,
|
private static void sendAcknowledgePacket(@NotNull Player player, @NotNull BlockPosition blockPosition, Block block,
|
||||||
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
|
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
|
||||||
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
|
player.getPlayerConnection().sendPacket(new AcknowledgePlayerDiggingPacket(blockPosition, block.stateId(), status, success));
|
||||||
acknowledgePlayerDiggingPacket.blockPosition = blockPosition;
|
|
||||||
acknowledgePlayerDiggingPacket.blockStateId = block.stateId();
|
|
||||||
acknowledgePlayerDiggingPacket.status = status;
|
|
||||||
acknowledgePlayerDiggingPacket.successful = success;
|
|
||||||
|
|
||||||
player.getPlayerConnection().sendPacket(acknowledgePlayerDiggingPacket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,22 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class AcknowledgePlayerDiggingPacket implements ServerPacket {
|
public class AcknowledgePlayerDiggingPacket implements ServerPacket {
|
||||||
|
|
||||||
public BlockPosition blockPosition = new BlockPosition(0,0,0);
|
public BlockPosition blockPosition;
|
||||||
public int blockStateId;
|
public int blockStateId;
|
||||||
public ClientPlayerDiggingPacket.Status status = ClientPlayerDiggingPacket.Status.STARTED_DIGGING;
|
public ClientPlayerDiggingPacket.Status status;
|
||||||
public boolean successful;
|
public boolean successful;
|
||||||
|
|
||||||
public AcknowledgePlayerDiggingPacket() {}
|
public AcknowledgePlayerDiggingPacket(@NotNull BlockPosition blockPosition, int blockStateId,
|
||||||
|
@NotNull ClientPlayerDiggingPacket.Status status, boolean success) {
|
||||||
|
this.blockPosition = blockPosition;
|
||||||
|
this.blockStateId = blockStateId;
|
||||||
|
this.status = status;
|
||||||
|
this.successful = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AcknowledgePlayerDiggingPacket() {
|
||||||
|
this(new BlockPosition(0, 0, 0), 0, ClientPlayerDiggingPacket.Status.STARTED_DIGGING, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
|
@ -9,13 +9,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class ActionBarPacket implements ServerPacket {
|
public class ActionBarPacket implements ServerPacket {
|
||||||
|
|
||||||
public Component actionBarText = Component.empty();
|
public Component actionBarText;
|
||||||
|
|
||||||
public ActionBarPacket() {
|
public ActionBarPacket(@NotNull Component actionBarText) {
|
||||||
|
this.actionBarText = actionBarText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionBarPacket(Component actionBarText) {
|
public ActionBarPacket() {
|
||||||
this.actionBarText = actionBarText;
|
this(Component.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,17 +1,30 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
import net.minestom.server.utils.binary.BinaryWriter;
|
import net.minestom.server.utils.binary.BinaryWriter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class AttachEntityPacket implements ServerPacket {
|
public class AttachEntityPacket implements ServerPacket {
|
||||||
|
|
||||||
public int attachedEntityId;
|
public int attachedEntityId;
|
||||||
public int holdingEntityId; // Or -1 to detach
|
public int holdingEntityId; // Or -1 to detach
|
||||||
|
|
||||||
public AttachEntityPacket() {}
|
public AttachEntityPacket(int attachedEntityId, int holdingEntityId) {
|
||||||
|
this.attachedEntityId = attachedEntityId;
|
||||||
|
this.holdingEntityId = holdingEntityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachEntityPacket(@NotNull Entity attachedEntity, @Nullable Entity holdingEntity) {
|
||||||
|
this(attachedEntity.getEntityId(), holdingEntity != null ? holdingEntity.getEntityId() : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachEntityPacket() {
|
||||||
|
this(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
|
@ -12,8 +12,13 @@ public class BlockChangePacket implements ServerPacket {
|
|||||||
public BlockPosition blockPosition;
|
public BlockPosition blockPosition;
|
||||||
public int blockStateId;
|
public int blockStateId;
|
||||||
|
|
||||||
|
public BlockChangePacket(BlockPosition blockPosition, int blockStateId) {
|
||||||
|
this.blockPosition = blockPosition;
|
||||||
|
this.blockStateId = blockStateId;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockChangePacket() {
|
public BlockChangePacket() {
|
||||||
blockPosition = new BlockPosition(0,0,0);
|
this(new BlockPosition(0, 0, 0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.minestom.server.network.packet.server.play;
|
package net.minestom.server.network.packet.server.play;
|
||||||
|
|
||||||
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.network.packet.server.ServerPacket;
|
import net.minestom.server.network.packet.server.ServerPacket;
|
||||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||||
import net.minestom.server.utils.binary.BinaryReader;
|
import net.minestom.server.utils.binary.BinaryReader;
|
||||||
@ -10,7 +11,17 @@ public class CameraPacket implements ServerPacket {
|
|||||||
|
|
||||||
public int cameraId;
|
public int cameraId;
|
||||||
|
|
||||||
public CameraPacket() {}
|
public CameraPacket(int cameraId) {
|
||||||
|
this.cameraId = cameraId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CameraPacket(@NotNull Entity camera) {
|
||||||
|
this(camera.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CameraPacket() {
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
|
@ -26,18 +26,16 @@ public class ChatMessagePacket implements ComponentHoldingServerPacket {
|
|||||||
public ChatPosition position;
|
public ChatPosition position;
|
||||||
public UUID uuid;
|
public UUID uuid;
|
||||||
|
|
||||||
public ChatMessagePacket() {
|
|
||||||
this.message = Component.empty();
|
|
||||||
this.position = ChatPosition.SYSTEM_MESSAGE;
|
|
||||||
this.uuid = NULL_UUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatMessagePacket(@NotNull Component message, @NotNull ChatPosition position, @Nullable UUID uuid) {
|
public ChatMessagePacket(@NotNull Component message, @NotNull ChatPosition position, @Nullable UUID uuid) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.uuid = Objects.requireNonNullElse(uuid, NULL_UUID);
|
this.uuid = Objects.requireNonNullElse(uuid, NULL_UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChatMessagePacket() {
|
||||||
|
this(Component.empty(), ChatPosition.SYSTEM_MESSAGE, NULL_UUID);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
writer.writeComponent(message);
|
writer.writeComponent(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user