Skip to content

Commit

Permalink
25w03a
Browse files Browse the repository at this point in the history
  • Loading branch information
basaigh committed Mar 2, 2025
1 parent 6d18428 commit 2b598ae
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundStopSoundPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTabListPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTestInstanceBlockStatus;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTickingStatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTickingStepPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundUpdateAdvancementsPacket;
Expand Down Expand Up @@ -185,8 +186,10 @@
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundMoveVehiclePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundPaddleBoatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundPlayerInputPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundSetTestBlockPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundSignUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTeleportToEntityPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundTestInstanceBlockActionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
Expand Down Expand Up @@ -215,8 +218,8 @@

public class MinecraftCodec {
public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion((1 << 30) | 229)
.minecraftVersion("25w02a")
.protocolVersion((1 << 30) | 230)
.minecraftVersion("25w03a")
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
)
Expand Down Expand Up @@ -383,6 +386,7 @@ public class MinecraftCodec {
.registerClientboundPacket(ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new)
.registerClientboundPacket(ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new)
.registerClientboundPacket(ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new)
.registerClientboundPacket(ClientboundTestInstanceBlockStatus.class, ClientboundTestInstanceBlockStatus::new)
.registerClientboundPacket(ClientboundTickingStatePacket.class, ClientboundTickingStatePacket::new)
.registerClientboundPacket(ClientboundTickingStepPacket.class, ClientboundTickingStepPacket::new)
.registerClientboundPacket(ClientboundTransferPacket.class, ClientboundTransferPacket::new)
Expand Down Expand Up @@ -451,9 +455,11 @@ public class MinecraftCodec {
.registerServerboundPacket(ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new)
.registerServerboundPacket(ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new)
.registerServerboundPacket(ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new)
.registerServerboundPacket(ServerboundSetTestBlockPacket.class, ServerboundSetTestBlockPacket::new)
.registerServerboundPacket(ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new)
.registerServerboundPacket(ServerboundSwingPacket.class, ServerboundSwingPacket::new)
.registerServerboundPacket(ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new)
.registerServerboundPacket(ServerboundTestInstanceBlockActionPacket.class, ServerboundTestInstanceBlockActionPacket::new)
.registerServerboundPacket(ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new)
.registerServerboundPacket(ServerboundUseItemPacket.class, ServerboundUseItemPacket::new)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet;
import org.geysermc.mcprotocollib.protocol.data.game.level.LightUpdateData;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.TestInstanceBlockEntity;
import org.geysermc.mcprotocollib.protocol.data.game.level.event.LevelEvent;
import org.geysermc.mcprotocollib.protocol.data.game.level.event.LevelEventType;
import org.geysermc.mcprotocollib.protocol.data.game.level.event.UnknownLevelEvent;
Expand Down Expand Up @@ -529,6 +530,38 @@ public static void writeTradeItemStack(ByteBuf buf, @NotNull ItemStack item) {
}
}

public static TestInstanceBlockEntity readTestBlockEntity(ByteBuf buf) {
Key test = MinecraftTypes.readNullable(buf, MinecraftTypes::readResourceLocation);
Vector3i size = MinecraftTypes.readVec3i(buf);
int rotation = MinecraftTypes.readVarInt(buf);
boolean ignoreEntities = buf.readBoolean();
int status = MinecraftTypes.readVarInt(buf);
Component errorMessage = MinecraftTypes.readNullable(buf, MinecraftTypes::readComponent);
return new TestInstanceBlockEntity(test, size, rotation, ignoreEntities, status, errorMessage);
}

public static void writeTestBlockEntity(ByteBuf buf, TestInstanceBlockEntity testBlockEntity) {
MinecraftTypes.writeNullable(buf, testBlockEntity.test(), MinecraftTypes::writeResourceLocation);
MinecraftTypes.writeVec3i(buf, testBlockEntity.size());
MinecraftTypes.writeVarInt(buf, testBlockEntity.rotation());
buf.writeBoolean(testBlockEntity.ignoreEntities());
MinecraftTypes.writeVarInt(buf, testBlockEntity.status());
MinecraftTypes.writeNullable(buf, testBlockEntity.errorMessage(), MinecraftTypes::writeComponent);
}

public static Vector3i readVec3i(ByteBuf buf) {
int x = MinecraftTypes.readVarInt(buf);
int y = MinecraftTypes.readVarInt(buf);
int z = MinecraftTypes.readVarInt(buf);
return Vector3i.from(x, y, z);
}

public static void writeVec3i(ByteBuf buf, Vector3i vec) {
MinecraftTypes.writeVarInt(buf, vec.getX());
MinecraftTypes.writeVarInt(buf, vec.getY());
MinecraftTypes.writeVarInt(buf, vec.getZ());
}

public static Vector3i readPosition(ByteBuf buf) {
long val = buf.readLong();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public enum EntityEvent {
SNIFFER_MAKE_SOUND,
ARMADILLO_PEEKING,
LIVING_EQUIPMENT_BREAK_BODY,
SHAKE;
SHAKE,
DROWN_PARTICLES,
SADDLE_BREAK;

private static final EntityEvent[] VALUES = values();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PaintingVariant;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PigVariant;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.WolfVariant;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.BooleanDataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.type.IntDataComponent;
Expand Down Expand Up @@ -90,6 +93,27 @@ public class DataComponentType<T> {
public static final DataComponentType<List<BeehiveOccupant>> BEES = new DataComponentType<>("bees", listReader(ItemTypes::readBeehiveOccupant), listWriter(ItemTypes::writeBeehiveOccupant), ObjectDataComponent::new);
public static final DataComponentType<NbtMap> LOCK = new DataComponentType<>("lock", MinecraftTypes::readCompoundTag, MinecraftTypes::writeAnyTag, ObjectDataComponent::new);
public static final DataComponentType<NbtMap> CONTAINER_LOOT = new DataComponentType<>("container_loot", MinecraftTypes::readCompoundTag, MinecraftTypes::writeAnyTag, ObjectDataComponent::new);
public static final IntComponentType VILLAGER_VARIANT = new IntComponentType("villager/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final DataComponentType<Holder<WolfVariant>> WOLF_VARIANT = new DataComponentType<>("wolf/variant", MinecraftTypes::readWolfVariant, MinecraftTypes::writeWolfVariant, ObjectDataComponent::new);
public static final IntComponentType WOLF_COLLAR = new IntComponentType("wolf/collar", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType FOX_VARIANT = new IntComponentType("fox/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType SALMON_SIZE = new IntComponentType("salmon/size", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType PARROT_VARIANT = new IntComponentType("parrot/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType TROPICAL_FISH_PATTERN = new IntComponentType("tropical_fish/pattern", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType TROPICAL_FISH_BASE_COLOR = new IntComponentType("tropical_fish/base_color", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType TROPICAL_FISH_PATTERN_COLOR = new IntComponentType("tropical_fish/pattern_color", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType MOOSHROOM_VARIANT = new IntComponentType("mooshroom/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType RABBIT_VARIANT = new IntComponentType("rabbit/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final DataComponentType<Holder<PigVariant>> PIG_VARIANT = new DataComponentType<>("pig/variant", MinecraftTypes::readPigVariant, MinecraftTypes::writePigVariant, ObjectDataComponent::new);
public static final IntComponentType FROG_VARIANT = new IntComponentType("frog/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType HORSE_VARIANT = new IntComponentType("horse/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final DataComponentType<Holder<PaintingVariant>> PAINTING_VARIANT = new DataComponentType<>("painting/variant", MinecraftTypes::readPaintingVariant, MinecraftTypes::writePaintingVariant, ObjectDataComponent::new);
public static final IntComponentType LLAMA_VARIANT = new IntComponentType("llama/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType AXOLOTL_VARIANT = new IntComponentType("axolotl/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType CAT_VARIANT = new IntComponentType("cat/variant", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType CAT_COLLAR = new IntComponentType("cat/collar", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType SHEEP_COLOR = new IntComponentType("sheep/color", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);
public static final IntComponentType SHULKER_COLOR = new IntComponentType("shulker/color", MinecraftTypes::readVarInt, MinecraftTypes::writeVarInt, IntDataComponent::new);

protected final int id;
protected final Key key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;

public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable Key cameraOverlay,
@Nullable HolderSet allowedEntities, boolean dispensable, boolean swappable, boolean damageOnHurt) {
@Nullable HolderSet allowedEntities, boolean dispensable, boolean swappable, boolean damageOnHurt,
boolean equipOnInteract) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static Weapon readWeapon(ByteBuf buf) {
}

public static void writeWeapon(ByteBuf buf, Weapon weapon) {
MinecraftTypes.writeVarInt(buf, weapon.damagePerAttack());
MinecraftTypes.writeVarInt(buf, weapon.itemDamagePerAttack());
buf.writeBoolean(weapon.canDisableBlocking());
}

Expand All @@ -165,7 +165,8 @@ public static Equippable readEquippable(ByteBuf buf) {
boolean dispensable = buf.readBoolean();
boolean swappable = buf.readBoolean();
boolean damageOnHurt = buf.readBoolean();
return new Equippable(slot, equipSound, model, cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt);
boolean equipOnInteract = buf.readBoolean();
return new Equippable(slot, equipSound, model, cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt, equipOnInteract);
}

public static void writeEquippable(ByteBuf buf, Equippable equippable) {
Expand All @@ -183,6 +184,7 @@ public static void writeEquippable(ByteBuf buf, Equippable equippable) {
buf.writeBoolean(equippable.dispensable());
buf.writeBoolean(equippable.swappable());
buf.writeBoolean(equippable.damageOnHurt());
buf.writeBoolean(equippable.equipOnInteract());
}

public static ItemAttributeModifiers readItemAttributeModifiers(ByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.geysermc.mcprotocollib.protocol.data.game.item.component;

public record Weapon(int damagePerAttack, boolean canDisableBlocking) {
public record Weapon(int itemDamagePerAttack, boolean canDisableBlocking) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public enum BlockEntityType {
DECORATED_POT,
CRAFTER,
TRIAL_SPAWNER,
VAULT;
VAULT,
TEST_BLOCK,
TEST_INSTANCE_BLOCK;

private static final BlockEntityType[] VALUES = values();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.geysermc.mcprotocollib.protocol.data.game.level.block;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3i;
import org.jetbrains.annotations.Nullable;

public record TestInstanceBlockEntity(@Nullable Key test, Vector3i size, int rotation, boolean ignoreEntities,
int status, @Nullable Component errorMessage) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound;

import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3i;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
import org.jetbrains.annotations.Nullable;

@Data
@With
@AllArgsConstructor
public class ClientboundTestInstanceBlockStatus implements MinecraftPacket {
private final Component status;
private final @Nullable Vector3i size;

public ClientboundTestInstanceBlockStatus(ByteBuf in) {
this.status = MinecraftTypes.readComponent(in);
this.size = MinecraftTypes.readNullable(in, MinecraftTypes::readVec3i);
}

@Override
public void serialize(ByteBuf out) {
MinecraftTypes.writeComponent(out, this.status);
MinecraftTypes.writeNullable(out, this.size, MinecraftTypes::writeVec3i);
}

@Override
public boolean shouldRunOnGameThread() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ClientboundBlockEventPacket implements MinecraftPacket {
private static final int SHULKER_BOX_LOWER = 641;
private static final int SHULKER_BOX_HIGHER = 657;
private static final int BELL = 811;
private static final int DECORATED_POT = 1085;
private static final int DECORATED_POT = 1087;
private static final Logger log = LoggerFactory.getLogger(ClientboundBlockEventPacket.class);

private final @NonNull Vector3i position;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level;

import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;
import org.cloudburstmc.math.vector.Vector3i;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;

@Data
@With
@AllArgsConstructor
public class ServerboundSetTestBlockPacket implements MinecraftPacket {
private final Vector3i position;
private final int mode;
private final String message;

public ServerboundSetTestBlockPacket(ByteBuf in) {
this.position = MinecraftTypes.readPosition(in);
this.mode = MinecraftTypes.readVarInt(in);
this.message = MinecraftTypes.readString(in);
}

@Override
public void serialize(ByteBuf out) {
MinecraftTypes.writePosition(out, this.position);
MinecraftTypes.writeVarInt(out, this.mode);
MinecraftTypes.writeString(out, this.message);
}

@Override
public boolean shouldRunOnGameThread() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level;

import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;
import org.cloudburstmc.math.vector.Vector3i;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.TestInstanceBlockEntity;

@Data
@With
@AllArgsConstructor
public class ServerboundTestInstanceBlockActionPacket implements MinecraftPacket {
private final Vector3i pos;
private final int action;
private final TestInstanceBlockEntity data;

public ServerboundTestInstanceBlockActionPacket(ByteBuf in) {
this.pos = MinecraftTypes.readPosition(in);
this.action = MinecraftTypes.readVarInt(in);
this.data = MinecraftTypes.readTestBlockEntity(in);
}

@Override
public void serialize(ByteBuf out) {
MinecraftTypes.writePosition(out, this.pos);
MinecraftTypes.writeVarInt(out, this.action);
MinecraftTypes.writeTestBlockEntity(out, this.data);
}

@Override
public boolean shouldRunOnGameThread() {
return true;
}
}
Binary file modified protocol/src/main/resources/networkCodec.nbt
Binary file not shown.

0 comments on commit 2b598ae

Please sign in to comment.