Skip to content

Commit

Permalink
1.21.2-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
basaigh committed Oct 16, 2024
1 parent ca629e2 commit 4c2ecc1
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@

public class MinecraftCodec {
public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion((1 << 30) | 212)
.protocolVersion((1 << 30) | 213)
.helper(MinecraftCodecHelper::new)
.minecraftVersion("24w40a")
.minecraftVersion("1.21.2-pre1")
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SmithingTrimDemoSlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.WithRemainderSlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.statistic.StatisticCategory;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -710,21 +711,15 @@ public ParticleData readParticleData(ByteBuf buf, ParticleType type) {
return switch (type) {
case BLOCK, BLOCK_MARKER, FALLING_DUST, DUST_PILLAR, BLOCK_CRUMBLE -> new BlockParticleData(this.readVarInt(buf));
case DUST -> {
float red = buf.readFloat();
float green = buf.readFloat();
float blue = buf.readFloat();
int color = buf.readInt();
float scale = buf.readFloat();
yield new DustParticleData(red, green, blue, scale);
yield new DustParticleData(color, scale);
}
case DUST_COLOR_TRANSITION -> {
float red = buf.readFloat();
float green = buf.readFloat();
float blue = buf.readFloat();
float newRed = buf.readFloat();
float newGreen = buf.readFloat();
float newBlue = buf.readFloat();
int color = buf.readInt();
int newColor = buf.readInt();
float scale = buf.readFloat();
yield new DustColorTransitionParticleData(red, green, blue, scale, newRed, newGreen, newBlue);
yield new DustColorTransitionParticleData(color, scale, newColor);
}
case ENTITY_EFFECT -> new EntityEffectParticleData(buf.readInt());
case ITEM -> new ItemParticleData(this.readOptionalItemStack(buf));
Expand All @@ -744,19 +739,13 @@ public void writeParticleData(ByteBuf buf, ParticleType type, ParticleData data)
}
case DUST -> {
DustParticleData dustData = (DustParticleData) data;
buf.writeFloat(dustData.getRed());
buf.writeFloat(dustData.getGreen());
buf.writeFloat(dustData.getBlue());
buf.writeInt(dustData.getColor());
buf.writeFloat(dustData.getScale());
}
case DUST_COLOR_TRANSITION -> {
DustColorTransitionParticleData dustData = (DustColorTransitionParticleData) data;
buf.writeFloat(dustData.getRed());
buf.writeFloat(dustData.getGreen());
buf.writeFloat(dustData.getBlue());
buf.writeFloat(dustData.getNewRed());
buf.writeFloat(dustData.getNewGreen());
buf.writeFloat(dustData.getNewBlue());
buf.writeInt(dustData.getColor());
buf.writeInt(dustData.getNewColor());
buf.writeFloat(dustData.getScale());
}
case ENTITY_EFFECT -> {
Expand Down Expand Up @@ -1032,20 +1021,26 @@ public RecipeDisplay readRecipeDisplay(ByteBuf buf) {
SlotDisplay fuel = this.readSlotDisplay(buf);
SlotDisplay result = this.readSlotDisplay(buf);
SlotDisplay craftingStation = this.readSlotDisplay(buf);
int duration = this.readVarInt(buf);
float experience = buf.readFloat();

display = new FurnaceRecipeDisplay(ingredient, fuel, result, craftingStation);
display = new FurnaceRecipeDisplay(ingredient, fuel, result, craftingStation, duration, experience);
}
case STONECUTTER -> {
SlotDisplay input = this.readSlotDisplay(buf);
SlotDisplay result = this.readSlotDisplay(buf);
SlotDisplay craftingStation = this.readSlotDisplay(buf);

display = new StonecutterRecipeDisplay(result, craftingStation);
display = new StonecutterRecipeDisplay(input, result, craftingStation);
}
case SMITHING -> {
SlotDisplay template = this.readSlotDisplay(buf);
SlotDisplay base = this.readSlotDisplay(buf);
SlotDisplay addition = this.readSlotDisplay(buf);
SlotDisplay result = this.readSlotDisplay(buf);
SlotDisplay craftingStation = this.readSlotDisplay(buf);

display = new SmithingRecipeDisplay(result, craftingStation);
display = new SmithingRecipeDisplay(template, base, addition, result, craftingStation);
}
default -> throw new IllegalStateException("Unexpected value: " + type);
}
Expand Down Expand Up @@ -1078,16 +1073,22 @@ public void writeRecipeDisplay(ByteBuf buf, RecipeDisplay display) {
this.writeSlotDisplay(buf, furnaceDisplay.fuel());
this.writeSlotDisplay(buf, furnaceDisplay.result());
this.writeSlotDisplay(buf, furnaceDisplay.craftingStation());
this.writeVarInt(buf, furnaceDisplay.duration());
buf.writeFloat(furnaceDisplay.experience());
}
case STONECUTTER -> {
StonecutterRecipeDisplay stonecutterDisplay = (StonecutterRecipeDisplay) display;

this.writeSlotDisplay(buf, stonecutterDisplay.input());
this.writeSlotDisplay(buf, stonecutterDisplay.result());
this.writeSlotDisplay(buf, stonecutterDisplay.craftingStation());
}
case SMITHING -> {
SmithingRecipeDisplay smithingDisplay = (SmithingRecipeDisplay) display;

this.writeSlotDisplay(buf, smithingDisplay.template());
this.writeSlotDisplay(buf, smithingDisplay.base());
this.writeSlotDisplay(buf, smithingDisplay.addition());
this.writeSlotDisplay(buf, smithingDisplay.result());
this.writeSlotDisplay(buf, smithingDisplay.craftingStation());
}
Expand All @@ -1103,7 +1104,8 @@ public SlotDisplay readSlotDisplay(ByteBuf buf) {
case ITEM -> display = new ItemSlotDisplay(this.readVarInt(buf));
case ITEM_STACK -> display = new ItemStackSlotDisplay(this.readItemStack(buf));
case TAG -> display = new TagSlotDisplay(this.readResourceLocation(buf));
case SMITHING_TRIM -> display = new SmithingTrimDemoSlotDisplay();
case SMITHING_TRIM -> display = new SmithingTrimDemoSlotDisplay(this.readSlotDisplay(buf), this.readSlotDisplay(buf), this.readSlotDisplay(buf));
case WITH_REMAINDER -> display = new WithRemainderSlotDisplay(this.readSlotDisplay(buf), this.readSlotDisplay(buf));
case COMPOSITE -> display = new CompositeSlotDisplay(this.readList(buf, this::readSlotDisplay));
default -> throw new IllegalStateException("Unexpected value: " + type);
}
Expand All @@ -1116,6 +1118,19 @@ public void writeSlotDisplay(ByteBuf buf, SlotDisplay display) {
case ITEM -> this.writeVarInt(buf, ((ItemSlotDisplay)display).item());
case ITEM_STACK -> this.writeItemStack(buf, ((ItemStackSlotDisplay)display).itemStack());
case TAG -> this.writeResourceLocation(buf, ((TagSlotDisplay)display).tag());
case SMITHING_TRIM -> {
SmithingTrimDemoSlotDisplay smithingSlotDisplay = (SmithingTrimDemoSlotDisplay) display;

this.writeSlotDisplay(buf, smithingSlotDisplay.base());
this.writeSlotDisplay(buf, smithingSlotDisplay.material());
this.writeSlotDisplay(buf, smithingSlotDisplay.pattern());
}
case WITH_REMAINDER -> {
WithRemainderSlotDisplay remainderSlotDisplay = (WithRemainderSlotDisplay) display;

this.writeSlotDisplay(buf, remainderSlotDisplay.input());
this.writeSlotDisplay(buf, remainderSlotDisplay.remainder());
}
case COMPOSITE -> this.writeList(buf, ((CompositeSlotDisplay)display).contents(), this::writeSlotDisplay);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import org.geysermc.mcprotocollib.protocol.data.game.entity.EquipmentSlot;
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.Sound;

public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable HolderSet allowedEntities,
boolean dispensable, boolean swappable, boolean damageOnHurt) {
public record Equippable(EquipmentSlot slot, Sound equipSound, @Nullable Key model, @Nullable Key cameraOverlay,
@Nullable HolderSet allowedEntities, boolean dispensable, boolean swappable, boolean damageOnHurt) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ public Equippable readEquippable(ByteBuf buf) {
EquipmentSlot slot = EquipmentSlot.from(this.readVarInt(buf));
Sound equipSound = this.readById(buf, BuiltinSound::from, this::readSoundEvent);
Key model = this.readNullable(buf, this::readResourceLocation);
Key cameraOverlay = this.readNullable(buf, this::readResourceLocation);
HolderSet allowedEntities = this.readNullable(buf, this::readHolderSet);
boolean dispensable = buf.readBoolean();
boolean swappable = buf.readBoolean();
boolean damageOnHurt = buf.readBoolean();
return new Equippable(slot, equipSound, model, allowedEntities, dispensable, swappable, damageOnHurt);
return new Equippable(slot, equipSound, model, cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt);
}

public void writeEquippable(ByteBuf buf, Equippable equippable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

@Getter
public class DustColorTransitionParticleData extends DustParticleData {
private final float newRed;
private final float newGreen;
private final float newBlue;
private final int newColor;

public DustColorTransitionParticleData(float red, float green, float blue, float scale, float newRed, float newGreen, float newBlue) {
super(red, green, blue, scale);
this.newRed = newRed;
this.newGreen = newGreen;
this.newBlue = newBlue;
public DustColorTransitionParticleData(int color, float scale, int newColor) {
super(color, scale);
this.newColor = newColor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
@Data
@AllArgsConstructor
public class DustParticleData implements ParticleData {
private final float red; // 0 - 1
private final float green; // 0 - 1
private final float blue; // 0 - 1
private final int color;
private final float scale; // clamped between 0.01 and 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public enum BuiltinSound implements Sound {
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT("block.bubble_column.whirlpool_ambient"),
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE("block.bubble_column.whirlpool_inside"),
UI_HUD_BUBBLE_POP("ui.hud.bubble_pop"),
ITEM_BUCKET_EMPTY("item.bucket.empty"),
ITEM_BUCKET_EMPTY_AXOLOTL("item.bucket.empty_axolotl"),
ITEM_BUCKET_EMPTY_FISH("item.bucket.empty_fish"),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;

public record FurnaceRecipeDisplay(SlotDisplay ingredient, SlotDisplay fuel, SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay {
public record FurnaceRecipeDisplay(SlotDisplay ingredient, SlotDisplay fuel, SlotDisplay result, SlotDisplay craftingStation,
int duration, float experience) implements RecipeDisplay {
@Override
public RecipeDisplayType getType() {
return RecipeDisplayType.FURNACE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.BasicRecipeBookCategory;

import java.util.List;
import java.util.OptionalInt;

public record RecipeDisplayEntry(int id, RecipeDisplay display, OptionalInt group,
BasicRecipeBookCategory category, @Nullable List<HolderSet> craftingRequirements) {
int category, @Nullable List<HolderSet> craftingRequirements) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;

public record SmithingRecipeDisplay(SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay {
public record SmithingRecipeDisplay(SlotDisplay template, SlotDisplay base, SlotDisplay addition,
SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay {
@Override
public RecipeDisplayType getType() {
return RecipeDisplayType.SMITHING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDisplay;

public record StonecutterRecipeDisplay(SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay {
public record StonecutterRecipeDisplay(SlotDisplay input, SlotDisplay result, SlotDisplay craftingStation) implements RecipeDisplay {
@Override
public RecipeDisplayType getType() {
return RecipeDisplayType.STONECUTTER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot;

import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplayType;

public enum RecipeSlotType {
EMPTY,
ANY_FUEL,
ITEM,
ITEM_STACK,
TAG,
SMITHING_TRIM,
WITH_REMAINDER,
COMPOSITE;

private static final RecipeSlotType[] VALUES = values();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot;

public record SmithingTrimDemoSlotDisplay() implements SlotDisplay {
public record SmithingTrimDemoSlotDisplay(SlotDisplay base, SlotDisplay material, SlotDisplay pattern) implements SlotDisplay {
@Override
public RecipeSlotType getType() {
return RecipeSlotType.SMITHING_TRIM;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot;

public record WithRemainderSlotDisplay(SlotDisplay input, SlotDisplay remainder) implements SlotDisplay {
@Override
public RecipeSlotType getType() {
return RecipeSlotType.WITH_REMAINDER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.HolderSet;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.BasicRecipeBookCategory;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.Ingredient;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.RecipeDisplayEntry;

Expand All @@ -20,6 +18,7 @@
@AllArgsConstructor
public class ClientboundRecipeBookAddPacket implements MinecraftPacket {
private final List<Entry> entries;
private final boolean replace;

public ClientboundRecipeBookAddPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.entries = helper.readList(in, buf -> {
Expand All @@ -28,14 +27,15 @@ public ClientboundRecipeBookAddPacket(ByteBuf in, MinecraftCodecHelper helper) {

int optionalInt = helper.readVarInt(buf);
OptionalInt group = optionalInt == 0 ? OptionalInt.empty() : OptionalInt.of(optionalInt - 1);
BasicRecipeBookCategory category = BasicRecipeBookCategory.from(helper.readVarInt(buf));
int category = helper.readVarInt(buf);
List<HolderSet> craftingRequirements = helper.readNullable(in, buf1 -> helper.readList(buf1, helper::readHolderSet));

byte flags = buf.readByte();
boolean notification = (flags & 1) != 0;
boolean highlight = (flags & 2) != 0;
return new Entry(new RecipeDisplayEntry(id, display, group, category, craftingRequirements), notification, highlight);
});
this.replace = in.readBoolean();
}

@Override
Expand All @@ -44,7 +44,7 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(buf, entry.contents().id());
helper.writeRecipeDisplay(buf, entry.contents().display());
helper.writeVarInt(buf, entry.contents().group().isEmpty() ? 0 : entry.contents().group().getAsInt());
helper.writeVarInt(buf, entry.contents().category().ordinal());
helper.writeVarInt(buf, entry.contents().category());
helper.writeNullable(buf, entry.contents().craftingRequirements(), (buf1, reqs) -> helper.writeList(buf1, reqs, helper::writeHolderSet));

int flags = 0;
Expand All @@ -57,6 +57,7 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
}
buf.writeByte(flags);
});
out.writeBoolean(this.replace);
}

private record Entry(RecipeDisplayEntry contents, boolean notification, boolean highlight) {
Expand Down

0 comments on commit 4c2ecc1

Please sign in to comment.