hollow-cube/1.20

* initial 1.20 support

* test fixes

* anvil 1.20, 1.20.1

(cherry picked from commit 716f32972a)
This commit is contained in:
Matt Worzala 2023-06-14 22:11:18 -04:00 committed by mworzala
parent 5aa466b937
commit c20a28ccfc
No known key found for this signature in database
GPG Key ID: B148F922E64797C7
18 changed files with 180 additions and 65 deletions

View File

@ -3,11 +3,11 @@ metadata.format.version = "1.1"
[versions]
# Important dependencies
data = "1.19.4-rv2"
data = "1.20-rv2"
adventure = "4.12.0"
kotlin = "1.7.22"
hydrazine = "1.7.2"
hephaistos = "2.5.3"
hephaistos = "2.6.0"
jetbrainsAnnotations = "23.0.0"
slf4j = "2.0.7"

View File

@ -81,6 +81,8 @@ interface Blocks {
Block GRAVEL = BlockImpl.get("minecraft:gravel");
Block SUSPICIOUS_GRAVEL = BlockImpl.get("minecraft:suspicious_gravel");
Block GOLD_ORE = BlockImpl.get("minecraft:gold_ore");
Block DEEPSLATE_GOLD_ORE = BlockImpl.get("minecraft:deepslate_gold_ore");
@ -1201,6 +1203,10 @@ interface Blocks {
Block TORCHFLOWER_CROP = BlockImpl.get("minecraft:torchflower_crop");
Block PITCHER_CROP = BlockImpl.get("minecraft:pitcher_crop");
Block PITCHER_PLANT = BlockImpl.get("minecraft:pitcher_plant");
Block BEETROOTS = BlockImpl.get("minecraft:beetroots");
Block DIRT_PATH = BlockImpl.get("minecraft:dirt_path");
@ -1363,6 +1369,8 @@ interface Blocks {
Block TURTLE_EGG = BlockImpl.get("minecraft:turtle_egg");
Block SNIFFER_EGG = BlockImpl.get("minecraft:sniffer_egg");
Block DEAD_TUBE_CORAL_BLOCK = BlockImpl.get("minecraft:dead_tube_coral_block");
Block DEAD_BRAIN_CORAL_BLOCK = BlockImpl.get("minecraft:dead_brain_coral_block");
@ -1825,6 +1833,8 @@ interface Blocks {
Block SCULK_SENSOR = BlockImpl.get("minecraft:sculk_sensor");
Block CALIBRATED_SCULK_SENSOR = BlockImpl.get("minecraft:calibrated_sculk_sensor");
Block SCULK = BlockImpl.get("minecraft:sculk");
Block SCULK_VEIN = BlockImpl.get("minecraft:sculk_vein");

View File

@ -97,6 +97,8 @@ interface Materials {
Material SUSPICIOUS_SAND = MaterialImpl.get("minecraft:suspicious_sand");
Material SUSPICIOUS_GRAVEL = MaterialImpl.get("minecraft:suspicious_gravel");
Material RED_SAND = MaterialImpl.get("minecraft:red_sand");
Material GRAVEL = MaterialImpl.get("minecraft:gravel");
@ -423,6 +425,8 @@ interface Materials {
Material TORCHFLOWER = MaterialImpl.get("minecraft:torchflower");
Material PITCHER_PLANT = MaterialImpl.get("minecraft:pitcher_plant");
Material SPORE_BLOSSOM = MaterialImpl.get("minecraft:spore_blossom");
Material BROWN_MUSHROOM = MaterialImpl.get("minecraft:brown_mushroom");
@ -1133,6 +1137,8 @@ interface Materials {
Material TURTLE_EGG = MaterialImpl.get("minecraft:turtle_egg");
Material SNIFFER_EGG = MaterialImpl.get("minecraft:sniffer_egg");
Material DEAD_TUBE_CORAL_BLOCK = MaterialImpl.get("minecraft:dead_tube_coral_block");
Material DEAD_BRAIN_CORAL_BLOCK = MaterialImpl.get("minecraft:dead_brain_coral_block");
@ -1307,6 +1313,8 @@ interface Materials {
Material SCULK_SENSOR = MaterialImpl.get("minecraft:sculk_sensor");
Material CALIBRATED_SCULK_SENSOR = MaterialImpl.get("minecraft:calibrated_sculk_sensor");
Material TRIPWIRE_HOOK = MaterialImpl.get("minecraft:tripwire_hook");
Material TRAPPED_CHEST = MaterialImpl.get("minecraft:trapped_chest");
@ -2211,6 +2219,8 @@ interface Materials {
Material TORCHFLOWER_SEEDS = MaterialImpl.get("minecraft:torchflower_seeds");
Material PITCHER_POD = MaterialImpl.get("minecraft:pitcher_pod");
Material BEETROOT = MaterialImpl.get("minecraft:beetroot");
Material BEETROOT_SEEDS = MaterialImpl.get("minecraft:beetroot_seeds");
@ -2265,6 +2275,8 @@ interface Materials {
Material MUSIC_DISC_OTHERSIDE = MaterialImpl.get("minecraft:music_disc_otherside");
Material MUSIC_DISC_RELIC = MaterialImpl.get("minecraft:music_disc_relic");
Material MUSIC_DISC_5 = MaterialImpl.get("minecraft:music_disc_5");
Material MUSIC_DISC_PIGSTEP = MaterialImpl.get("minecraft:music_disc_pigstep");
@ -2453,11 +2465,53 @@ interface Materials {
Material SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:spire_armor_trim_smithing_template");
Material POTTERY_SHARD_ARCHER = MaterialImpl.get("minecraft:pottery_shard_archer");
Material WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:wayfinder_armor_trim_smithing_template");
Material POTTERY_SHARD_PRIZE = MaterialImpl.get("minecraft:pottery_shard_prize");
Material SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:shaper_armor_trim_smithing_template");
Material POTTERY_SHARD_ARMS_UP = MaterialImpl.get("minecraft:pottery_shard_arms_up");
Material SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:silence_armor_trim_smithing_template");
Material POTTERY_SHARD_SKULL = MaterialImpl.get("minecraft:pottery_shard_skull");
Material RAISER_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:raiser_armor_trim_smithing_template");
Material HOST_ARMOR_TRIM_SMITHING_TEMPLATE = MaterialImpl.get("minecraft:host_armor_trim_smithing_template");
Material ANGLER_POTTERY_SHERD = MaterialImpl.get("minecraft:angler_pottery_sherd");
Material ARCHER_POTTERY_SHERD = MaterialImpl.get("minecraft:archer_pottery_sherd");
Material ARMS_UP_POTTERY_SHERD = MaterialImpl.get("minecraft:arms_up_pottery_sherd");
Material BLADE_POTTERY_SHERD = MaterialImpl.get("minecraft:blade_pottery_sherd");
Material BREWER_POTTERY_SHERD = MaterialImpl.get("minecraft:brewer_pottery_sherd");
Material BURN_POTTERY_SHERD = MaterialImpl.get("minecraft:burn_pottery_sherd");
Material DANGER_POTTERY_SHERD = MaterialImpl.get("minecraft:danger_pottery_sherd");
Material EXPLORER_POTTERY_SHERD = MaterialImpl.get("minecraft:explorer_pottery_sherd");
Material FRIEND_POTTERY_SHERD = MaterialImpl.get("minecraft:friend_pottery_sherd");
Material HEART_POTTERY_SHERD = MaterialImpl.get("minecraft:heart_pottery_sherd");
Material HEARTBREAK_POTTERY_SHERD = MaterialImpl.get("minecraft:heartbreak_pottery_sherd");
Material HOWL_POTTERY_SHERD = MaterialImpl.get("minecraft:howl_pottery_sherd");
Material MINER_POTTERY_SHERD = MaterialImpl.get("minecraft:miner_pottery_sherd");
Material MOURNER_POTTERY_SHERD = MaterialImpl.get("minecraft:mourner_pottery_sherd");
Material PLENTY_POTTERY_SHERD = MaterialImpl.get("minecraft:plenty_pottery_sherd");
Material PRIZE_POTTERY_SHERD = MaterialImpl.get("minecraft:prize_pottery_sherd");
Material SHEAF_POTTERY_SHERD = MaterialImpl.get("minecraft:sheaf_pottery_sherd");
Material SHELTER_POTTERY_SHERD = MaterialImpl.get("minecraft:shelter_pottery_sherd");
Material SKULL_POTTERY_SHERD = MaterialImpl.get("minecraft:skull_pottery_sherd");
Material SNORT_POTTERY_SHERD = MaterialImpl.get("minecraft:snort_pottery_sherd");
}

View File

@ -63,11 +63,7 @@ interface Particles {
Particle FLAME = ParticleImpl.get("minecraft:flame");
Particle DRIPPING_CHERRY_LEAVES = ParticleImpl.get("minecraft:dripping_cherry_leaves");
Particle FALLING_CHERRY_LEAVES = ParticleImpl.get("minecraft:falling_cherry_leaves");
Particle LANDING_CHERRY_LEAVES = ParticleImpl.get("minecraft:landing_cherry_leaves");
Particle CHERRY_LEAVES = ParticleImpl.get("minecraft:cherry_leaves");
Particle SCULK_SOUL = ParticleImpl.get("minecraft:sculk_soul");
@ -196,4 +192,6 @@ interface Particles {
Particle SCRAPE = ParticleImpl.get("minecraft:scrape");
Particle SHRIEK = ParticleImpl.get("minecraft:shriek");
Particle EGG_CRACK = ParticleImpl.get("minecraft:egg_crack");
}

View File

@ -73,6 +73,8 @@ interface SoundEvents {
SoundEvent BLOCK_AMETHYST_BLOCK_PLACE = SoundEventImpl.get("minecraft:block.amethyst_block.place");
SoundEvent BLOCK_AMETHYST_BLOCK_RESONATE = SoundEventImpl.get("minecraft:block.amethyst_block.resonate");
SoundEvent BLOCK_AMETHYST_BLOCK_STEP = SoundEventImpl.get("minecraft:block.amethyst_block.step");
SoundEvent BLOCK_AMETHYST_CLUSTER_BREAK = SoundEventImpl.get("minecraft:block.amethyst_cluster.break");
@ -337,9 +339,15 @@ interface SoundEvents {
SoundEvent BLOCK_BREWING_STAND_BREW = SoundEventImpl.get("minecraft:block.brewing_stand.brew");
SoundEvent ITEM_BRUSH_BRUSHING = SoundEventImpl.get("minecraft:item.brush.brushing");
SoundEvent ITEM_BRUSH_BRUSHING_GENERIC = SoundEventImpl.get("minecraft:item.brush.brushing.generic");
SoundEvent ITEM_BRUSH_BRUSH_SAND_COMPLETED = SoundEventImpl.get("minecraft:item.brush.brush_sand_completed");
SoundEvent ITEM_BRUSH_BRUSHING_SAND = SoundEventImpl.get("minecraft:item.brush.brushing.sand");
SoundEvent ITEM_BRUSH_BRUSHING_GRAVEL = SoundEventImpl.get("minecraft:item.brush.brushing.gravel");
SoundEvent ITEM_BRUSH_BRUSHING_SAND_COMPLETE = SoundEventImpl.get("minecraft:item.brush.brushing.sand.complete");
SoundEvent ITEM_BRUSH_BRUSHING_GRAVEL_COMPLETE = SoundEventImpl.get("minecraft:item.brush.brushing.gravel.complete");
SoundEvent BLOCK_BUBBLE_COLUMN_BUBBLE_POP = SoundEventImpl.get("minecraft:block.bubble_column.bubble_pop");
@ -961,6 +969,16 @@ interface SoundEvents {
SoundEvent BLOCK_SUSPICIOUS_SAND_FALL = SoundEventImpl.get("minecraft:block.suspicious_sand.fall");
SoundEvent BLOCK_SUSPICIOUS_GRAVEL_BREAK = SoundEventImpl.get("minecraft:block.suspicious_gravel.break");
SoundEvent BLOCK_SUSPICIOUS_GRAVEL_STEP = SoundEventImpl.get("minecraft:block.suspicious_gravel.step");
SoundEvent BLOCK_SUSPICIOUS_GRAVEL_PLACE = SoundEventImpl.get("minecraft:block.suspicious_gravel.place");
SoundEvent BLOCK_SUSPICIOUS_GRAVEL_HIT = SoundEventImpl.get("minecraft:block.suspicious_gravel.hit");
SoundEvent BLOCK_SUSPICIOUS_GRAVEL_FALL = SoundEventImpl.get("minecraft:block.suspicious_gravel.fall");
SoundEvent BLOCK_FROGLIGHT_BREAK = SoundEventImpl.get("minecraft:block.froglight.break");
SoundEvent BLOCK_FROGLIGHT_FALL = SoundEventImpl.get("minecraft:block.froglight.fall");
@ -1589,6 +1607,8 @@ interface SoundEvents {
SoundEvent MUSIC_DISC_OTHERSIDE = SoundEventImpl.get("minecraft:music_disc.otherside");
SoundEvent MUSIC_DISC_RELIC = SoundEventImpl.get("minecraft:music_disc.relic");
SoundEvent MUSIC_DRAGON = SoundEventImpl.get("minecraft:music.dragon");
SoundEvent MUSIC_END = SoundEventImpl.get("minecraft:music.end");
@ -1613,7 +1633,7 @@ interface SoundEvents {
SoundEvent MUSIC_OVERWORLD_SWAMP = SoundEventImpl.get("minecraft:music.overworld.swamp");
SoundEvent MUSIC_OVERWORLD_JUNGLE_AND_FOREST = SoundEventImpl.get("minecraft:music.overworld.jungle_and_forest");
SoundEvent MUSIC_OVERWORLD_FOREST = SoundEventImpl.get("minecraft:music.overworld.forest");
SoundEvent MUSIC_OVERWORLD_OLD_GROWTH_TAIGA = SoundEventImpl.get("minecraft:music.overworld.old_growth_taiga");
@ -1633,6 +1653,18 @@ interface SoundEvents {
SoundEvent MUSIC_NETHER_WARPED_FOREST = SoundEventImpl.get("minecraft:music.nether.warped_forest");
SoundEvent MUSIC_OVERWORLD_FLOWER_FOREST = SoundEventImpl.get("minecraft:music.overworld.flower_forest");
SoundEvent MUSIC_OVERWORLD_DESERT = SoundEventImpl.get("minecraft:music.overworld.desert");
SoundEvent MUSIC_OVERWORLD_BADLANDS = SoundEventImpl.get("minecraft:music.overworld.badlands");
SoundEvent MUSIC_OVERWORLD_JUNGLE = SoundEventImpl.get("minecraft:music.overworld.jungle");
SoundEvent MUSIC_OVERWORLD_SPARSE_JUNGLE = SoundEventImpl.get("minecraft:music.overworld.sparse_jungle");
SoundEvent MUSIC_OVERWORLD_BAMBOO_JUNGLE = SoundEventImpl.get("minecraft:music.overworld.bamboo_jungle");
SoundEvent MUSIC_UNDER_WATER = SoundEventImpl.get("minecraft:music.under_water");
SoundEvent BLOCK_NETHER_BRICKS_BREAK = SoundEventImpl.get("minecraft:block.nether_bricks.break");
@ -2449,6 +2481,12 @@ interface SoundEvents {
SoundEvent ENTITY_SNIFFER_HAPPY = SoundEventImpl.get("minecraft:entity.sniffer.happy");
SoundEvent BLOCK_SNIFFER_EGG_PLOP = SoundEventImpl.get("minecraft:block.sniffer_egg.plop");
SoundEvent BLOCK_SNIFFER_EGG_CRACK = SoundEventImpl.get("minecraft:block.sniffer_egg.crack");
SoundEvent BLOCK_SNIFFER_EGG_HATCH = SoundEventImpl.get("minecraft:block.sniffer_egg.hatch");
SoundEvent ENTITY_SNOWBALL_THROW = SoundEventImpl.get("minecraft:entity.snowball.throw");
SoundEvent BLOCK_SNOW_BREAK = SoundEventImpl.get("minecraft:block.snow.break");
@ -2753,6 +2791,8 @@ interface SoundEvents {
SoundEvent ENTITY_WARDEN_TENDRIL_CLICKS = SoundEventImpl.get("minecraft:entity.warden.tendril_clicks");
SoundEvent BLOCK_SIGN_WAXED_INTERACT_FAIL = SoundEventImpl.get("minecraft:block.sign.waxed_interact_fail");
SoundEvent BLOCK_WATER_AMBIENT = SoundEventImpl.get("minecraft:block.water.ambient");
SoundEvent WEATHER_RAIN = SoundEventImpl.get("minecraft:weather.rain");

View File

@ -45,8 +45,8 @@ public final class MinecraftServer {
public static final ComponentLogger LOGGER = ComponentLogger.logger(MinecraftServer.class);
public static final String VERSION_NAME = "1.19.4";
public static final int PROTOCOL_VERSION = 762;
public static final String VERSION_NAME = "1.20.1";
public static final int PROTOCOL_VERSION = 763;
// Threads
public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark";

View File

@ -158,6 +158,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
private final PlayerSettings settings;
private float exp;
private int level;
private int portalCooldown = 0;
protected PlayerInventory inventory;
private Inventory openInventory;
@ -281,7 +282,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
final JoinGamePacket joinGamePacket = new JoinGamePacket(getEntityId(), false, gameMode, null,
List.of(dimensionType.getName().asString()), NBT.Compound(registry), dimensionType.toString(), dimensionType.getName().asString(),
0, 0, MinecraftServer.getChunkViewDistance(), MinecraftServer.getChunkViewDistance(),
false, true, false, levelFlat, deathLocation);
false, true, false, levelFlat, deathLocation, portalCooldown);
sendPacket(joinGamePacket);
// Server brand name
@ -449,7 +450,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
// #buildDeathScreenText can return null, check here
if (deathText != null) {
sendPacket(new DeathCombatEventPacket(getEntityId(), -1, deathText));
sendPacket(new DeathCombatEventPacket(getEntityId(), deathText));
}
// #buildDeathMessage can return null, check here
@ -477,7 +478,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
refreshHealth();
sendPacket(new RespawnPacket(getDimensionType().toString(), getDimensionType().getName().asString(),
0, gameMode, gameMode, false, levelFlat, true, deathLocation));
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
EventDispatcher.call(respawnEvent);
@ -1009,7 +1010,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), getDimensionType().getName().asString(),
0, gameMode, gameMode, false, levelFlat, true, deathLocation);
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown);
sendPacket(removePlayerPacket);
sendPacket(destroyEntitiesPacket);
@ -1249,6 +1250,14 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
sendPacket(new SetExperiencePacket(exp, level, 0));
}
public int getPortalCooldown() {
return portalCooldown;
}
public void setPortalCooldown(int portalCooldown) {
this.portalCooldown = portalCooldown;
}
/**
* Gets the player connection.
* <p>
@ -1389,7 +1398,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
"The dimension needs to be different than the current one!");
this.dimensionType = dimensionType;
sendPacket(new RespawnPacket(dimensionType.toString(), getDimensionType().getName().asString(),
0, gameMode, gameMode, false, levelFlat, true, deathLocation));
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
refreshClientStateAfterRespawn();
}

View File

@ -246,10 +246,11 @@ public class DynamicChunk extends Chunk {
emptyBlockMask.set(index);
}
}
return new LightData(true,
return new LightData(
skyMask, blockMask,
emptySkyMask, emptyBlockMask,
skyLights, blockLights);
skyLights, blockLights
);
}
@Override

View File

@ -195,10 +195,11 @@ public class LightingChunk extends DynamicChunk {
sendNeighbours = false;
}
return new LightData(true,
return new LightData(
skyMask, blockMask,
emptySkyMask, emptyBlockMask,
skyLights, blockLights);
skyLights, blockLights
);
}
private static final Set<LightingChunk> sendQueue = ConcurrentHashMap.newKeySet();

View File

@ -7,11 +7,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
import static net.minestom.server.network.NetworkBuffer.STRING;
import static net.minestom.server.network.NetworkBuffer.*;
public record ClientUpdateSignPacket(@NotNull Point blockPosition,
@NotNull List<String> lines) implements ClientPacket {
public record ClientUpdateSignPacket(
@NotNull Point blockPosition,
boolean isFrontText,
@NotNull List<String> lines
) implements ClientPacket {
public ClientUpdateSignPacket {
lines = List.copyOf(lines);
if (lines.size() != 4) {
@ -25,12 +27,13 @@ public record ClientUpdateSignPacket(@NotNull Point blockPosition,
}
public ClientUpdateSignPacket(@NotNull NetworkBuffer reader) {
this(reader.read(BLOCK_POSITION), readLines(reader));
this(reader.read(BLOCK_POSITION), reader.read(BOOLEAN), readLines(reader));
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(BLOCK_POSITION, blockPosition);
writer.write(BOOLEAN, isFrontText);
writer.write(STRING, lines.get(0));
writer.write(STRING, lines.get(1));
writer.write(STRING, lines.get(2));

View File

@ -13,16 +13,14 @@ import java.util.function.UnaryOperator;
import static net.minestom.server.network.NetworkBuffer.*;
public record DeathCombatEventPacket(int playerId, int entityId,
@NotNull Component message) implements ComponentHoldingServerPacket {
public record DeathCombatEventPacket(int playerId, @NotNull Component message) implements ComponentHoldingServerPacket {
public DeathCombatEventPacket(@NotNull NetworkBuffer reader) {
this(reader.read(VAR_INT), reader.read(INT), reader.read(COMPONENT));
this(reader.read(VAR_INT), reader.read(COMPONENT));
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(VAR_INT, playerId);
writer.write(INT, entityId);
writer.write(COMPONENT, message);
}
@ -38,6 +36,6 @@ public record DeathCombatEventPacket(int playerId, int entityId,
@Override
public @NotNull ServerPacket copyWithOperator(@NotNull UnaryOperator<Component> operator) {
return new DeathCombatEventPacket(this.playerId, this.entityId, operator.apply(this.message));
return new DeathCombatEventPacket(this.playerId, operator.apply(this.message));
}
}

View File

@ -5,18 +5,16 @@ import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
import org.jetbrains.annotations.NotNull;
import static net.minestom.server.network.NetworkBuffer.INT;
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
public record EndCombatEventPacket(int duration, int entityId) implements ServerPacket {
public record EndCombatEventPacket(int duration) implements ServerPacket {
public EndCombatEventPacket(@NotNull NetworkBuffer reader) {
this(reader.read(VAR_INT), reader.read(INT));
this(reader.read(VAR_INT));
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(VAR_INT, duration);
writer.write(INT, entityId);
}
@Override

View File

@ -17,7 +17,7 @@ public record JoinGamePacket(int entityId, boolean isHardcore, GameMode gameMode
List<String> worlds, NBTCompound dimensionCodec, String dimensionType, String world,
long hashedSeed, int maxPlayers, int viewDistance, int simulationDistance,
boolean reducedDebugInfo, boolean enableRespawnScreen, boolean isDebug, boolean isFlat,
DeathLocation deathLocation) implements ServerPacket {
DeathLocation deathLocation, int portalCooldown) implements ServerPacket {
public JoinGamePacket {
worlds = List.copyOf(worlds);
}
@ -27,7 +27,7 @@ public record JoinGamePacket(int entityId, boolean isHardcore, GameMode gameMode
reader.readCollection(STRING), (NBTCompound) reader.read(NBT), reader.read(STRING), reader.read(STRING),
reader.read(LONG), reader.read(VAR_INT), reader.read(VAR_INT), reader.read(VAR_INT),
reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(BOOLEAN),
reader.read(DEATH_LOCATION));
reader.read(DEATH_LOCATION), reader.read(VAR_INT));
}
@Override
@ -58,6 +58,8 @@ public record JoinGamePacket(int entityId, boolean isHardcore, GameMode gameMode
writer.write(BOOLEAN, isFlat);
writer.write(DEATH_LOCATION, deathLocation);
writer.write(VAR_INT, portalCooldown);
}
@Override

View File

@ -7,24 +7,19 @@ import org.jetbrains.annotations.NotNull;
import static net.minestom.server.network.NetworkBuffer.*;
public record MultiBlockChangePacket(long chunkSectionPosition,
boolean suppressLightUpdates,
long[] blocks) implements ServerPacket {
public record MultiBlockChangePacket(long chunkSectionPosition, long[] blocks) implements ServerPacket {
public MultiBlockChangePacket(int chunkX, int section, int chunkZ,
boolean suppressLightUpdates,
long[] blocks) {
this(((long) (chunkX & 0x3FFFFF) << 42) | (section & 0xFFFFF) | ((long) (chunkZ & 0x3FFFFF) << 20),
suppressLightUpdates, blocks);
this(((long) (chunkX & 0x3FFFFF) << 42) | (section & 0xFFFFF) | ((long) (chunkZ & 0x3FFFFF) << 20), blocks);
}
public MultiBlockChangePacket(@NotNull NetworkBuffer reader) {
this(reader.read(LONG), reader.read(BOOLEAN), reader.read(VAR_LONG_ARRAY));
this(reader.read(LONG), reader.read(VAR_LONG_ARRAY));
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(LONG, chunkSectionPosition);
writer.write(BOOLEAN, suppressLightUpdates);
writer.write(VAR_LONG_ARRAY, blocks);
}

View File

@ -7,15 +7,17 @@ import net.minestom.server.network.packet.server.ServerPacketIdentifier;
import org.jetbrains.annotations.NotNull;
import static net.minestom.server.network.NetworkBuffer.BLOCK_POSITION;
import static net.minestom.server.network.NetworkBuffer.BOOLEAN;
public record OpenSignEditorPacket(@NotNull Point position) implements ServerPacket {
public record OpenSignEditorPacket(@NotNull Point position, boolean isFrontText) implements ServerPacket {
public OpenSignEditorPacket(@NotNull NetworkBuffer reader) {
this(reader.read(BLOCK_POSITION));
this(reader.read(BLOCK_POSITION), reader.read(BOOLEAN));
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(BLOCK_POSITION, position);
writer.write(BOOLEAN, isFrontText);
}
@Override

View File

@ -12,11 +12,14 @@ import static net.minestom.server.network.NetworkBuffer.*;
public record RespawnPacket(String dimensionType, String worldName,
long hashedSeed, GameMode gameMode, GameMode previousGameMode,
boolean isDebug, boolean isFlat, boolean copyMeta,
DeathLocation deathLocation) implements ServerPacket {
DeathLocation deathLocation, int portalCooldown) implements ServerPacket {
public RespawnPacket(@NotNull NetworkBuffer reader) {
this(reader.read(STRING), reader.read(STRING),
reader.read(LONG), GameMode.fromId(reader.read(BYTE)), GameMode.fromId(reader.read(BYTE)),
reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(BOOLEAN), reader.read(DEATH_LOCATION));
reader.read(LONG), GameMode.fromId(reader.read(BYTE)),
GameMode.fromId(reader.read(BYTE)),
reader.read(BOOLEAN), reader.read(BOOLEAN),
reader.read(BOOLEAN), reader.read(DEATH_LOCATION),
reader.read(VAR_INT));
}
@Override
@ -30,6 +33,7 @@ public record RespawnPacket(String dimensionType, String worldName,
writer.write(BOOLEAN, isFlat);
writer.write(BOOLEAN, copyMeta);
writer.write(DEATH_LOCATION, deathLocation);
writer.write(VAR_INT, portalCooldown);
}
@Override

View File

@ -8,22 +8,22 @@ import java.util.List;
import static net.minestom.server.network.NetworkBuffer.*;
public record LightData(boolean trustEdges,
@NotNull BitSet skyMask, @NotNull BitSet blockMask,
@NotNull BitSet emptySkyMask, @NotNull BitSet emptyBlockMask,
@NotNull List<byte[]> skyLight,
@NotNull List<byte[]> blockLight) implements NetworkBuffer.Writer {
public record LightData(
@NotNull BitSet skyMask, @NotNull BitSet blockMask,
@NotNull BitSet emptySkyMask, @NotNull BitSet emptyBlockMask,
@NotNull List<byte[]> skyLight,
@NotNull List<byte[]> blockLight
) implements NetworkBuffer.Writer {
public LightData(@NotNull NetworkBuffer reader) {
this(reader.read(BOOLEAN),
this(
BitSet.valueOf(reader.read(LONG_ARRAY)), BitSet.valueOf(reader.read(LONG_ARRAY)),
BitSet.valueOf(reader.read(LONG_ARRAY)), BitSet.valueOf(reader.read(LONG_ARRAY)),
reader.readCollection(BYTE_ARRAY), reader.readCollection(BYTE_ARRAY));
reader.readCollection(BYTE_ARRAY), reader.readCollection(BYTE_ARRAY)
);
}
@Override
public void write(@NotNull NetworkBuffer writer) {
writer.write(BOOLEAN, trustEdges);
writer.write(LONG_ARRAY, skyMask.toLongArray());
writer.write(LONG_ARRAY, blockMask.toLongArray());

View File

@ -90,7 +90,7 @@ public class PacketWriteReadTest {
SERVER_PACKETS.add(new CloseWindowPacket((byte) 2));
SERVER_PACKETS.add(new CollectItemPacket(5, 5, 5));
SERVER_PACKETS.add(new CraftRecipeResponse((byte) 2, "recipe"));
SERVER_PACKETS.add(new DeathCombatEventPacket(5, 5, COMPONENT));
SERVER_PACKETS.add(new DeathCombatEventPacket(5, COMPONENT));
SERVER_PACKETS.add(new DeclareRecipesPacket(
List.of(new DeclareRecipesPacket.DeclaredShapelessCraftingRecipe(
"minecraft:sticks",
@ -112,7 +112,7 @@ public class PacketWriteReadTest {
SERVER_PACKETS.add(new DisconnectPacket(COMPONENT));
SERVER_PACKETS.add(new DisplayScoreboardPacket((byte) 5, "scoreboard"));
SERVER_PACKETS.add(new EffectPacket(5, VEC, 5, false));
SERVER_PACKETS.add(new EndCombatEventPacket(5, 5));
SERVER_PACKETS.add(new EndCombatEventPacket(5));
SERVER_PACKETS.add(new EnterCombatEventPacket());
SERVER_PACKETS.add(new EntityAnimationPacket(5, EntityAnimationPacket.Animation.TAKE_DAMAGE));
SERVER_PACKETS.add(new EntityEquipmentPacket(6, Map.of(EquipmentSlot.MAIN_HAND, ItemStack.of(Material.DIAMOND_SWORD))));