Merge branch '2.0' into refactor/eliminate-static-ProtocolManager-USERS-&-CHANNELS-use

This commit is contained in:
booky10 committed 2025-04-18 19:01:42 +02:00
commit b635dcbe54
281 files changed
+209796 -1265

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
distribution: 'temurin'
cache: 'gradle'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
+3
View File
@@ -123,3 +123,6 @@ run/
.project
.settings/
.classpath
# Build Source Kotlin
/buildSrc/.kotlin/
+2 -2
View File
@@ -1,7 +1,7 @@
<!--suppress HtmlDeprecatedAttribute -->
<div align="center">
<h2><i>packetevents</i></h2>
<h3><i>Precision meets performance—a powerful tool for mastering Minecraft packet manipulation with speed and finesse.</i></h3>
<h2><i>PacketEvents</i></h2>
<h3><i>A powerful networking library for Minecraft packet processing and manipulation.</i></h3>
<a href="https://github.com/retrooper/packetevents/actions"><img src="https://img.shields.io/github/actions/workflow/status/retrooper/packetevents/gradle-publish.yml?style=for-the-badge&logo=github"></a>
<a href="https://discord.gg/DVHxPPxHZc"><img src="https://img.shields.io/discord/721686193061888071?color=5562e9&logo=discord&logoColor=white&style=for-the-badge"></a>
<img src="https://img.shields.io/github/license/retrooper/packetevents?style=for-the-badge&logo=github">
@@ -0,0 +1,28 @@
package com.github.retrooper.packetevents.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.Documented;
/**
* Marks an API element as obsolete and makes this information available
* at runtime via reflection. Use in conjunction with an IDE-recognized
* annotation like @ApiStatus.Obsolete if IDE warnings are also desired.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD}) // Adjust targets as needed
public @interface RuntimeObsolete {
/**
* Specifies in which version the API became obsolete.
* Should generally match the value in the corresponding @ApiStatus.Obsolete annotation.
*/
String since() default "";
/**
* Optional: Add a reason or replacement suggestion.
*/
String reason() default "";
}
@@ -35,6 +35,8 @@ public interface ChannelInjector {
void setPlayer(Object channel, Object player);
boolean isPlayerSet(Object channel);
boolean isProxy();
default PacketSide getPacketSide() {
@@ -50,7 +50,7 @@ public enum ServerVersion {
//1.20 and 1.20.1 have the same protocol version. 1.20.3 and 1.20.4 have the same protocol version. 1.20.5 and 1.20.6 have the same protocol version
V_1_20(763), V_1_20_1(763), V_1_20_2(764), V_1_20_3(765), V_1_20_4(765), V_1_20_5(766), V_1_20_6(766),
//1.21 and 1.21.1 have the same protocol version. 1.21.2 and 1.21.3 have the same protocol version
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769),
V_1_21(767), V_1_21_1(767), V_1_21_2(768), V_1_21_3(768), V_1_21_4(769), V_1_21_5(770),
//TODO UPDATE Add server version constant
ERROR(-1, true);
@@ -239,6 +239,19 @@ public class ByteBufHelper {
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().resetWriterIndex(buffer);
}
public static Object allocateNewBuffer(Object buffer) {
return PacketEvents.getAPI().getNettyManager().getByteBufOperator().allocateNewBuffer(buffer);
}
public static int getByteSize(int value) {
for (int i = 1; i < 5; ++i) {
if ((value & -1 << i * 7) == 0) {
return i;
}
}
return 5;
}
public static int readVarInt(Object buffer) {
int value = 0;
int length = 0;
@@ -74,6 +74,8 @@ public interface ByteBufOperator {
Object markWriterIndex(Object buffer);
Object resetWriterIndex(Object buffer);
Object allocateNewBuffer(Object buffer);
default float readFloat(Object buffer) {
return Float.intBitsToFloat(readInt(buffer));
}
@@ -49,7 +49,7 @@ public final class Attributes {
if (normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":generic.")
|| normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":player.")
|| normedName.startsWith(ResourceLocation.VANILLA_NAMESPACE + ":zombie.")) {
normedName = normedName.substring(name.indexOf('.') + 1);
normedName = normedName.substring(normedName.indexOf('.') + 1);
}
return REGISTRY.getByName(normedName);
}
@@ -90,7 +90,7 @@ public class ChatTypeDecoration {
}
NBTCompound styleTag = compound.getCompoundTagOrNull("style");
Style style = styleTag == null ? empty() :
AdventureSerializer.getNBTSerializer().deserializeStyle(styleTag);
AdventureSerializer.serializer(version).nbt().deserializeStyle(styleTag);
return new ChatTypeDecoration(translationKey, params, style);
}
@@ -104,8 +104,8 @@ public class ChatTypeDecoration {
compound.setTag("translation_key", new NBTString(decoration.translationKey));
compound.setTag("parameters", paramsTag);
if (!decoration.style.isEmpty()) {
compound.setTag("style", AdventureSerializer.getNBTSerializer()
.serializeStyle(decoration.style));
compound.setTag("style", AdventureSerializer.serializer(version)
.nbt().serializeStyle(decoration.style));
}
return compound;
}
@@ -1,5 +1,6 @@
package com.github.retrooper.packetevents.protocol.chat;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.io.DataOutput;
@@ -86,12 +87,23 @@ public class LastSeenMessages {
}
public static class Update {
private final int offset;
private final BitSet acknowledged;
private final byte checksum;
/**
* Checksum has been added with 1.21.5
*/
@ApiStatus.Obsolete
public Update(int offset, BitSet acknowledged) {
this(offset, acknowledged, (byte) 0);
}
public Update(int offset, BitSet acknowledged, byte checksum) {
this.offset = offset;
this.acknowledged = acknowledged;
this.checksum = checksum;
}
public int getOffset() {
@@ -101,5 +113,12 @@ public class LastSeenMessages {
public BitSet getAcknowledged() {
return acknowledged;
}
/**
* Added with 1.21.5
*/
public byte getChecksum() {
return this.checksum;
}
}
}
@@ -148,8 +148,8 @@ public final class Parsers {
public static final Parser STYLE = define("style", null, null);
public static final Parser MESSAGE = define("message", null, null);
public static final Parser NBT_COMPOUND_TAG = define("nbt_compound_tag", null, null);
@Deprecated
public static final Parser NBT = NBT_COMPOUND_TAG;
@ApiStatus.Obsolete
public static final Parser NBT = define("nbt", null, null);
public static final Parser NBT_TAG = define("nbt_tag", null, null);
public static final Parser NBT_PATH = define("nbt_path", null, null);
public static final Parser OBJECTIVE = define("objective", null, null);
@@ -210,6 +210,14 @@ public final class Parsers {
public static final Parser LOOT_MODIFIER = define("loot_modifier", null, null);
public static final Parser UUID = define("uuid", null, null);
/**
* Added with 1.21.5
*/
public static final Parser RESOURCE_SELECTOR = define("resource_selector",
wrapper -> Collections.singletonList(wrapper.readIdentifier()),
(wrapper, value) -> wrapper.writeIdentifier((ResourceLocation) value.get(0))
);
static {
REGISTRY.unloadMappings();
}
@@ -10,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
import java.time.Instant;
import java.util.Optional;
import java.util.UUID;
//We'll extend ChatMessage_v1_16 for now, hopefully no breaking changes in the future
public class ChatMessage_v1_19_3 extends ChatMessage_v1_16 {
int index;
byte[] signature;
@@ -0,0 +1,49 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.chat.message;
import com.github.retrooper.packetevents.protocol.chat.ChatType;
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
import java.time.Instant;
import java.util.UUID;
//We'll extend ChatMessage_v1_19_3 for now, hopefully no breaking changes in the future
public class ChatMessage_v1_21_5 extends ChatMessage_v1_19_3 {
int globalIndex;
public ChatMessage_v1_21_5(int globalIndex, UUID senderUUID, int index, byte[] signature, String plainContent,
Instant timestamp, long salt, LastSeenMessages.Packed lastSeenMessagesPacked, @Nullable Component unsignedChatContent,
FilterMask filterMask, ChatType.Bound chatFormatting) {
super(senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatFormatting);
this.globalIndex = globalIndex;
}
public int getGlobalIndex() {
return this.globalIndex;
}
public void setGlobalIndex(int globalIndex) {
this.globalIndex = globalIndex;
}
}
@@ -0,0 +1,68 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.chat.message.reader.impl;
import com.github.retrooper.packetevents.protocol.chat.ChatType;
import com.github.retrooper.packetevents.protocol.chat.LastSeenMessages;
import com.github.retrooper.packetevents.protocol.chat.filter.FilterMask;
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage;
import com.github.retrooper.packetevents.protocol.chat.message.ChatMessage_v1_21_5;
import com.github.retrooper.packetevents.protocol.chat.message.reader.ChatMessageProcessor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
import java.util.UUID;
public class ChatMessageProcessor_v1_21_5 implements ChatMessageProcessor {
@Override
public ChatMessage readChatMessage(@NotNull PacketWrapper<?> wrapper) {
int globalIndex = wrapper.readVarInt();
UUID senderUUID = wrapper.readUUID();
int index = wrapper.readVarInt();
byte[] signature = wrapper.readOptional((w) -> w.readBytes(256));
String plainContent = wrapper.readString(256);
Instant timestamp = wrapper.readTimestamp();
long salt = wrapper.readLong();
LastSeenMessages.Packed lastSeenMessagesPacked = wrapper.readLastSeenMessagesPacked();
Component unsignedChatContent = wrapper.readOptional(PacketWrapper::readComponent);
FilterMask filterMask = wrapper.readFilterMask();
ChatType.Bound chatType = wrapper.readChatTypeBoundNetwork();
return new ChatMessage_v1_21_5(globalIndex, senderUUID, index, signature, plainContent, timestamp, salt, lastSeenMessagesPacked, unsignedChatContent, filterMask, chatType);
}
@Override
public void writeChatMessage(@NotNull PacketWrapper<?> wrapper, @NotNull ChatMessage data) {
ChatMessage_v1_21_5 newData = (ChatMessage_v1_21_5) data;
wrapper.writeVarInt(newData.getGlobalIndex());
wrapper.writeUUID(newData.getSenderUUID());
wrapper.writeVarInt(newData.getIndex());
wrapper.writeOptional(newData.getSignature(), PacketWrapper::writeBytes);
wrapper.writeString(newData.getPlainContent());
wrapper.writeTimestamp(newData.getTimestamp());
wrapper.writeLong(newData.getSalt());
wrapper.writeLastSeenMessagesPacked(newData.getLastSeenMessagesPacked());
wrapper.writeOptional(newData.getUnsignedChatContent().orElse(null), PacketWrapper::writeComponent);
wrapper.writeFilterMask(newData.getFilterMask());
wrapper.writeChatTypeBoundNetwork(newData.getChatFormatting());
}
}
@@ -18,6 +18,7 @@
package com.github.retrooper.packetevents.protocol.color;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.RGBLike;
import org.jetbrains.annotations.NotNull;
@@ -54,6 +55,8 @@ public enum DyeColor implements RGBLike {
BLACK(new Color(0x1d1d21), new Color(0x0), new Color(0x1e1b1b), 29);
private static final DyeColor[] COLORS = values();
private final Color textureDiffuseColor;
private final Color textColor;
@@ -70,6 +73,14 @@ public enum DyeColor implements RGBLike {
this.mapColorId = mapColorId;
}
public static DyeColor read(PacketWrapper<?> wrapper) {
return wrapper.readEnum(COLORS);
}
public static void write(PacketWrapper<?> wrapper, DyeColor color) {
wrapper.writeEnum(color);
}
public @NotNull Color color() {
return this.textureDiffuseColor;
}
@@ -100,4 +111,4 @@ public enum DyeColor implements RGBLike {
public int mapColorId() {
return this.mapColorId;
}
}
}
@@ -31,6 +31,10 @@ public class ComponentPredicate implements Predicate<IComponentMap> {
private List<ComponentValue<?>> requiredComponents;
public ComponentPredicate() {
this(new ArrayList<>());
}
public ComponentPredicate(List<ComponentValue<?>> requiredComponents) {
this.requiredComponents = requiredComponents;
}
@@ -19,6 +19,30 @@
package com.github.retrooper.packetevents.protocol.component;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.protocol.component.builtin.AxolotlVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.CatCollarComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.CatVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.ChickenVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.CowVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.FoxVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.FrogVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.HorseVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.LlamaVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.MooshroomVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.PaintingVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.ParrotVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.PigVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.RabbitVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.SalmonSizeComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.SheepColorComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.ShulkerColorComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishBaseColorComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternColorComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.TropicalFishPatternComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.VillagerVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.WolfCollarComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.WolfSoundVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.WolfVariantComponent;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ArmorTrim;
import com.github.retrooper.packetevents.protocol.component.builtin.item.BannerLayers;
import com.github.retrooper.packetevents.protocol.component.builtin.item.BundleContents;
@@ -31,6 +55,8 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAdv
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemAttributeModifiers;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBees;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlockStateProperties;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBlocksAttacks;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemBreakSound;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemConsumable;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerContents;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemContainerLoot;
@@ -42,6 +68,7 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnc
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEquippable;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemFireworks;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemInstrument;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemJukeboxPlayable;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLock;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemLore;
@@ -49,20 +76,27 @@ import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMap
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemMapPostProcessingState;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemModel;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionContents;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemPotionDurationScale;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProvidesBannerPatterns;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProvidesTrimMaterial;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRarity;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRecipes;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemRepairable;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTool;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipDisplay;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemTooltipStyle;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUnbreakable;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseCooldown;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemUseRemainder;
import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemWeapon;
import com.github.retrooper.packetevents.protocol.component.builtin.item.LodestoneTracker;
import com.github.retrooper.packetevents.protocol.component.builtin.item.PotDecorations;
import com.github.retrooper.packetevents.protocol.component.builtin.item.SuspiciousStewEffects;
import com.github.retrooper.packetevents.protocol.component.builtin.item.WritableBookContent;
import com.github.retrooper.packetevents.protocol.component.builtin.item.WrittenBookContent;
import com.github.retrooper.packetevents.protocol.item.instrument.Instrument;
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
@@ -121,8 +155,14 @@ public final class ComponentTypes {
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
public static final ComponentType<Integer> DAMAGE = define("damage",
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
public static final ComponentType<Boolean> UNBREAKABLE = define("unbreakable",
PacketWrapper::readBoolean, PacketWrapper::writeBoolean);
public static final ComponentType<ItemUnbreakable> UNBREAKABLE_MODERN = define("unbreakable",
ItemUnbreakable::read, ItemUnbreakable::write);
/**
* Changed in 1.21.5
*/
@Deprecated
public static final ComponentType<Boolean> UNBREAKABLE = UNBREAKABLE_MODERN.legacyMap(
ItemUnbreakable::isShowInTooltip, ItemUnbreakable::new);
public static final ComponentType<Component> CUSTOM_NAME = define("custom_name",
PacketWrapper::readComponent, PacketWrapper::writeComponent);
public static final ComponentType<Component> ITEM_NAME = define("item_name",
@@ -147,8 +187,16 @@ public final class ComponentTypes {
@Deprecated
public static final ComponentType<Integer> CUSTOM_MODEL_DATA = CUSTOM_MODEL_DATA_LISTS.legacyMap(
ItemCustomModelData::getLegacyId, ItemCustomModelData::new);
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public static final ComponentType<Dummy> HIDE_ADDITIONAL_TOOLTIP = define("hide_additional_tooltip",
Dummy::dummyRead, Dummy::dummyWrite);
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public static final ComponentType<Dummy> HIDE_TOOLTIP = define("hide_tooltip",
Dummy::dummyRead, Dummy::dummyWrite);
public static final ComponentType<Integer> REPAIR_COST = define("repair_cost",
@@ -203,8 +251,12 @@ public final class ComponentTypes {
PacketWrapper::readNBT, PacketWrapper::writeNBT);
public static final ComponentType<NBTCompound> BLOCK_ENTITY_DATA = define("block_entity_data",
PacketWrapper::readNBT, PacketWrapper::writeNBT);
public static final ComponentType<Instrument> INSTRUMENT = define("instrument",
Instrument::read, Instrument::write);
public static final ComponentType<ItemInstrument> ITEM_INSTRUMENT = define("instrument",
ItemInstrument::read, ItemInstrument::write);
@Deprecated
public static final ComponentType<Instrument> INSTRUMENT = ITEM_INSTRUMENT.legacyMap(
inst -> inst.getInstrument().getValue(),
inst -> new ItemInstrument(new MaybeMappedEntity<>(inst)));
public static final ComponentType<Integer> OMINOUS_BOTTLE_AMPLIFIER = define("ominous_bottle_amplifier",
PacketWrapper::readVarInt, PacketWrapper::writeVarInt);
public static final ComponentType<ItemRecipes> RECIPES = define("recipes",
@@ -264,6 +316,162 @@ public final class ComponentTypes {
public static final ComponentType<ItemTooltipStyle> TOOLTIP_STYLE = define("tooltip_style",
ItemTooltipStyle::read, ItemTooltipStyle::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemTooltipDisplay> TOOLTIP_DISPLAY = define("tooltip_display",
ItemTooltipDisplay::read, ItemTooltipDisplay::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemWeapon> WEAPON = define("weapon",
ItemWeapon::read, ItemWeapon::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemBlocksAttacks> BLOCKS_ATTACKS = define("blocks_attacks",
ItemBlocksAttacks::read, ItemBlocksAttacks::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemPotionDurationScale> POTION_DURATION_SCALE = define("potion_duration_scale",
ItemPotionDurationScale::read, ItemPotionDurationScale::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemProvidesTrimMaterial> PROVIDES_TRIM_MATERIAL = define("provides_trim_material",
ItemProvidesTrimMaterial::read, ItemProvidesTrimMaterial::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemProvidesBannerPatterns> PROVIDES_BANNER_PATTERNS = define("provides_banner_patterns",
ItemProvidesBannerPatterns::read, ItemProvidesBannerPatterns::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ItemBreakSound> BREAK_SOUND = define("break_sound",
ItemBreakSound::read, ItemBreakSound::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<VillagerVariantComponent> VILLAGER_VARIANT = define("villager/variant",
VillagerVariantComponent::read, VillagerVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<WolfVariantComponent> WOLF_VARIANT = define("wolf/variant",
WolfVariantComponent::read, WolfVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<WolfSoundVariantComponent> WOLF_SOUND_VARIANT = define("wolf/sound_variant",
WolfSoundVariantComponent::read, WolfSoundVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<WolfCollarComponent> WOLF_COLLAR = define("wolf/collar",
WolfCollarComponent::read, WolfCollarComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<FoxVariantComponent> FOX_VARIANT = define("fox/variant",
FoxVariantComponent::read, FoxVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<SalmonSizeComponent> SALMON_SIZE = define("salmon/size",
SalmonSizeComponent::read, SalmonSizeComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ParrotVariantComponent> PARROT_VARIANT = define("parrot/variant",
ParrotVariantComponent::read, ParrotVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<TropicalFishPatternComponent> TROPICAL_FISH_PATTERN = define("tropical_fish/pattern",
TropicalFishPatternComponent::read, TropicalFishPatternComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<TropicalFishBaseColorComponent> TROPICAL_FISH_BASE_COLOR = define("tropical_fish/base_color",
TropicalFishBaseColorComponent::read, TropicalFishBaseColorComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<TropicalFishPatternColorComponent> TROPICAL_FISH_PATTERN_COLOR = define("tropical_fish/pattern_color",
TropicalFishPatternColorComponent::read, TropicalFishPatternColorComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<MooshroomVariantComponent> MOOSHROOM_VARIANT = define("mooshroom/variant",
MooshroomVariantComponent::read, MooshroomVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<RabbitVariantComponent> RABBIT_VARIANT = define("rabbit/variant",
RabbitVariantComponent::read, RabbitVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<PigVariantComponent> PIG_VARIANT = define("pig/variant",
PigVariantComponent::read, PigVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<CowVariantComponent> COW_VARIANT = define("cow/variant",
CowVariantComponent::read, CowVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ChickenVariantComponent> CHICKEN_VARIANT = define("chicken/variant",
ChickenVariantComponent::read, ChickenVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<FrogVariantComponent> FROG_VARIANT = define("frog/variant",
FrogVariantComponent::read, FrogVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<HorseVariantComponent> HORSE_VARIANT = define("horse/variant",
HorseVariantComponent::read, HorseVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<PaintingVariantComponent> PAINTING_VARIANT = define("painting/variant",
PaintingVariantComponent::read, PaintingVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<LlamaVariantComponent> LLAMA_VARIANT = define("llama/variant",
LlamaVariantComponent::read, LlamaVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<AxolotlVariantComponent> AXOLOTL_VARIANT = define("axolotl/variant",
AxolotlVariantComponent::read, AxolotlVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<CatVariantComponent> CAT_VARIANT = define("cat/variant",
CatVariantComponent::read, CatVariantComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<CatCollarComponent> CAT_COLLAR = define("cat/collar",
CatCollarComponent::read, CatCollarComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<SheepColorComponent> SHEEP_COLOR = define("sheep/color",
SheepColorComponent::read, SheepColorComponent::write);
/**
* Added with 1.21.5
*/
public static final ComponentType<ShulkerColorComponent> SHULKER_COLOR = define("shulker/color",
ShulkerColorComponent::read, ShulkerColorComponent::write);
/**
* Returns an immutable view of the component types.
*
@@ -0,0 +1,57 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public final class HashedComponentPatchMap {
private final Map<ComponentType<?>, Integer> addedComponents;
private final Set<ComponentType<?>> removedComponents;
public HashedComponentPatchMap(Map<ComponentType<?>, Integer> addedComponents, Set<ComponentType<?>> removedComponents) {
this.addedComponents = addedComponents;
this.removedComponents = removedComponents;
}
public static HashedComponentPatchMap read(PacketWrapper<?> wrapper) {
Map<ComponentType<?>, Integer> addedComponents = wrapper.readMap(ew ->
ew.readMappedEntity(ComponentTypes.getRegistry()), PacketWrapper::readInt);
Set<ComponentType<?>> removedComponents = wrapper.readCollection(HashSet::new, ew ->
ew.readMappedEntity(ComponentTypes.getRegistry()));
return new HashedComponentPatchMap(addedComponents, removedComponents);
}
public static void write(PacketWrapper<?> wrapper, HashedComponentPatchMap map) {
wrapper.writeMap(map.addedComponents, PacketWrapper::writeMappedEntity, PacketWrapper::writeInt);
wrapper.writeCollection(map.removedComponents, PacketWrapper::writeMappedEntity);
}
public Map<ComponentType<?>, Integer> getAddedComponents() {
return this.addedComponents;
}
public Set<ComponentType<?>> getRemovedComponents() {
return this.removedComponents;
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.axolotl.AxolotlVariant;
import com.github.retrooper.packetevents.protocol.entity.axolotl.AxolotlVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class AxolotlVariantComponent {
private AxolotlVariant variant;
public AxolotlVariantComponent(AxolotlVariant variant) {
this.variant = variant;
}
public static AxolotlVariantComponent read(PacketWrapper<?> wrapper) {
AxolotlVariant type = wrapper.readMappedEntity(AxolotlVariants.getRegistry());
return new AxolotlVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, AxolotlVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public AxolotlVariant getVariant() {
return this.variant;
}
public void setVariant(AxolotlVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AxolotlVariantComponent)) return false;
AxolotlVariantComponent that = (AxolotlVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class CatCollarComponent {
private DyeColor color;
public CatCollarComponent(DyeColor color) {
this.color = color;
}
public static CatCollarComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new CatCollarComponent(type);
}
public static void write(PacketWrapper<?> wrapper, CatCollarComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CatCollarComponent)) return false;
CatCollarComponent that = (CatCollarComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariant;
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class CatVariantComponent {
private CatVariant variant;
public CatVariantComponent(CatVariant variant) {
this.variant = variant;
}
public static CatVariantComponent read(PacketWrapper<?> wrapper) {
CatVariant type = wrapper.readMappedEntity(CatVariants.getRegistry());
return new CatVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, CatVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public CatVariant getVariant() {
return this.variant;
}
public void setVariant(CatVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CatVariantComponent)) return false;
CatVariantComponent that = (CatVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant;
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariants;
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ChickenVariantComponent {
private MaybeMappedEntity<ChickenVariant> variant;
public ChickenVariantComponent(MaybeMappedEntity<ChickenVariant> variant) {
this.variant = variant;
}
public static ChickenVariantComponent read(PacketWrapper<?> wrapper) {
MaybeMappedEntity<ChickenVariant> variant = MaybeMappedEntity.read(wrapper,
ChickenVariants.getRegistry(), ChickenVariant::read);
return new ChickenVariantComponent(variant);
}
public static void write(PacketWrapper<?> wrapper, ChickenVariantComponent component) {
MaybeMappedEntity.write(wrapper, component.variant, ChickenVariant::write);
}
public MaybeMappedEntity<ChickenVariant> getVariant() {
return this.variant;
}
public void setVariant(MaybeMappedEntity<ChickenVariant> variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ChickenVariantComponent)) return false;
ChickenVariantComponent that = (ChickenVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant;
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class CowVariantComponent {
private CowVariant variant;
public CowVariantComponent(CowVariant variant) {
this.variant = variant;
}
public static CowVariantComponent read(PacketWrapper<?> wrapper) {
CowVariant type = wrapper.readMappedEntity(CowVariants.getRegistry());
return new CowVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, CowVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public CowVariant getVariant() {
return this.variant;
}
public void setVariant(CowVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CowVariantComponent)) return false;
CowVariantComponent that = (CowVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.fox.FoxVariant;
import com.github.retrooper.packetevents.protocol.entity.fox.FoxVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class FoxVariantComponent {
private FoxVariant variant;
public FoxVariantComponent(FoxVariant variant) {
this.variant = variant;
}
public static FoxVariantComponent read(PacketWrapper<?> wrapper) {
FoxVariant type = wrapper.readMappedEntity(FoxVariants.getRegistry());
return new FoxVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, FoxVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public FoxVariant getVariant() {
return this.variant;
}
public void setVariant(FoxVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof FoxVariantComponent)) return false;
FoxVariantComponent that = (FoxVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariant;
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class FrogVariantComponent {
private FrogVariant variant;
public FrogVariantComponent(FrogVariant variant) {
this.variant = variant;
}
public static FrogVariantComponent read(PacketWrapper<?> wrapper) {
FrogVariant variant = wrapper.readMappedEntity(FrogVariants.getRegistry());
return new FrogVariantComponent(variant);
}
public static void write(PacketWrapper<?> wrapper, FrogVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public FrogVariant getVariant() {
return this.variant;
}
public void setVariant(FrogVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof FrogVariantComponent)) return false;
FrogVariantComponent that = (FrogVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.horse.HorseVariant;
import com.github.retrooper.packetevents.protocol.entity.horse.HorseVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class HorseVariantComponent {
private HorseVariant variant;
public HorseVariantComponent(HorseVariant variant) {
this.variant = variant;
}
public static HorseVariantComponent read(PacketWrapper<?> wrapper) {
HorseVariant variant = wrapper.readMappedEntity(HorseVariants.getRegistry());
return new HorseVariantComponent(variant);
}
public static void write(PacketWrapper<?> wrapper, HorseVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public HorseVariant getVariant() {
return this.variant;
}
public void setVariant(HorseVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof HorseVariantComponent)) return false;
HorseVariantComponent that = (HorseVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.llama.LlamaVariant;
import com.github.retrooper.packetevents.protocol.entity.llama.LlamaVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class LlamaVariantComponent {
private LlamaVariant variant;
public LlamaVariantComponent(LlamaVariant variant) {
this.variant = variant;
}
public static LlamaVariantComponent read(PacketWrapper<?> wrapper) {
LlamaVariant type = wrapper.readMappedEntity(LlamaVariants.getRegistry());
return new LlamaVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, LlamaVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public LlamaVariant getVariant() {
return this.variant;
}
public void setVariant(LlamaVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof LlamaVariantComponent)) return false;
LlamaVariantComponent that = (LlamaVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.mooshroom.MooshroomVariant;
import com.github.retrooper.packetevents.protocol.entity.mooshroom.MooshroomVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class MooshroomVariantComponent {
private MooshroomVariant variant;
public MooshroomVariantComponent(MooshroomVariant variant) {
this.variant = variant;
}
public static MooshroomVariantComponent read(PacketWrapper<?> wrapper) {
MooshroomVariant type = wrapper.readMappedEntity(MooshroomVariants.getRegistry());
return new MooshroomVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, MooshroomVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public MooshroomVariant getVariant() {
return this.variant;
}
public void setVariant(MooshroomVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof MooshroomVariantComponent)) return false;
MooshroomVariantComponent that = (MooshroomVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.world.painting.PaintingVariant;
import com.github.retrooper.packetevents.protocol.world.painting.PaintingVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class PaintingVariantComponent {
private PaintingVariant variant;
public PaintingVariantComponent(PaintingVariant variant) {
this.variant = variant;
}
public static PaintingVariantComponent read(PacketWrapper<?> wrapper) {
PaintingVariant variant = wrapper.readMappedEntity(PaintingVariants.getRegistry());
return new PaintingVariantComponent(variant);
}
public static void write(PacketWrapper<?> wrapper, PaintingVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public PaintingVariant getVariant() {
return this.variant;
}
public void setVariant(PaintingVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PaintingVariantComponent)) return false;
PaintingVariantComponent that = (PaintingVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.parrot.ParrotVariant;
import com.github.retrooper.packetevents.protocol.entity.parrot.ParrotVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ParrotVariantComponent {
private ParrotVariant variant;
public ParrotVariantComponent(ParrotVariant variant) {
this.variant = variant;
}
public static ParrotVariantComponent read(PacketWrapper<?> wrapper) {
ParrotVariant type = wrapper.readMappedEntity(ParrotVariants.getRegistry());
return new ParrotVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, ParrotVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public ParrotVariant getVariant() {
return this.variant;
}
public void setVariant(ParrotVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ParrotVariantComponent)) return false;
ParrotVariantComponent that = (ParrotVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.pig.PigVariant;
import com.github.retrooper.packetevents.protocol.entity.pig.PigVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class PigVariantComponent {
private PigVariant variant;
public PigVariantComponent(PigVariant variant) {
this.variant = variant;
}
public static PigVariantComponent read(PacketWrapper<?> wrapper) {
PigVariant type = wrapper.readMappedEntity(PigVariants.getRegistry());
return new PigVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, PigVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public PigVariant getVariant() {
return this.variant;
}
public void setVariant(PigVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PigVariantComponent)) return false;
PigVariantComponent that = (PigVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.rabbit.RabbitVariant;
import com.github.retrooper.packetevents.protocol.entity.rabbit.RabbitVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class RabbitVariantComponent {
private RabbitVariant variant;
public RabbitVariantComponent(RabbitVariant variant) {
this.variant = variant;
}
public static RabbitVariantComponent read(PacketWrapper<?> wrapper) {
RabbitVariant type = wrapper.readMappedEntity(RabbitVariants.getRegistry());
return new RabbitVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, RabbitVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public RabbitVariant getVariant() {
return this.variant;
}
public void setVariant(RabbitVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof RabbitVariantComponent)) return false;
RabbitVariantComponent that = (RabbitVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.salmon.SalmonVariant;
import com.github.retrooper.packetevents.protocol.entity.salmon.SalmonVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class SalmonSizeComponent {
private SalmonVariant variant;
public SalmonSizeComponent(SalmonVariant variant) {
this.variant = variant;
}
public static SalmonSizeComponent read(PacketWrapper<?> wrapper) {
SalmonVariant type = wrapper.readMappedEntity(SalmonVariants.getRegistry());
return new SalmonSizeComponent(type);
}
public static void write(PacketWrapper<?> wrapper, SalmonSizeComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public SalmonVariant getVariant() {
return this.variant;
}
public void setVariant(SalmonVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SalmonSizeComponent)) return false;
SalmonSizeComponent that = (SalmonSizeComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class SheepColorComponent {
private DyeColor color;
public SheepColorComponent(DyeColor color) {
this.color = color;
}
public static SheepColorComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new SheepColorComponent(type);
}
public static void write(PacketWrapper<?> wrapper, SheepColorComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SheepColorComponent)) return false;
SheepColorComponent that = (SheepColorComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ShulkerColorComponent {
private DyeColor color;
public ShulkerColorComponent(DyeColor color) {
this.color = color;
}
public static ShulkerColorComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new ShulkerColorComponent(type);
}
public static void write(PacketWrapper<?> wrapper, ShulkerColorComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ShulkerColorComponent)) return false;
ShulkerColorComponent that = (ShulkerColorComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class TropicalFishBaseColorComponent {
private DyeColor color;
public TropicalFishBaseColorComponent(DyeColor color) {
this.color = color;
}
public static TropicalFishBaseColorComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new TropicalFishBaseColorComponent(type);
}
public static void write(PacketWrapper<?> wrapper, TropicalFishBaseColorComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof TropicalFishBaseColorComponent)) return false;
TropicalFishBaseColorComponent that = (TropicalFishBaseColorComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class TropicalFishPatternColorComponent {
private DyeColor color;
public TropicalFishPatternColorComponent(DyeColor color) {
this.color = color;
}
public static TropicalFishPatternColorComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new TropicalFishPatternColorComponent(type);
}
public static void write(PacketWrapper<?> wrapper, TropicalFishPatternColorComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof TropicalFishPatternColorComponent)) return false;
TropicalFishPatternColorComponent that = (TropicalFishPatternColorComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.tropicalfish.TropicalFishPattern;
import com.github.retrooper.packetevents.protocol.entity.tropicalfish.TropicalFishPatterns;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class TropicalFishPatternComponent {
private TropicalFishPattern variant;
public TropicalFishPatternComponent(TropicalFishPattern variant) {
this.variant = variant;
}
public static TropicalFishPatternComponent read(PacketWrapper<?> wrapper) {
TropicalFishPattern type = wrapper.readMappedEntity(TropicalFishPatterns.getRegistry());
return new TropicalFishPatternComponent(type);
}
public static void write(PacketWrapper<?> wrapper, TropicalFishPatternComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public TropicalFishPattern getVariant() {
return this.variant;
}
public void setVariant(TropicalFishPattern variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof TropicalFishPatternComponent)) return false;
TropicalFishPatternComponent that = (TropicalFishPatternComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerType;
import com.github.retrooper.packetevents.protocol.entity.villager.type.VillagerTypes;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class VillagerVariantComponent {
private VillagerType villagerType;
public VillagerVariantComponent(VillagerType villagerType) {
this.villagerType = villagerType;
}
public static VillagerVariantComponent read(PacketWrapper<?> wrapper) {
VillagerType type = wrapper.readMappedEntity(VillagerTypes.getRegistry());
return new VillagerVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, VillagerVariantComponent component) {
wrapper.writeMappedEntity(component.villagerType);
}
public VillagerType getVillagerType() {
return this.villagerType;
}
public void setVillagerType(VillagerType villagerType) {
this.villagerType = villagerType;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof VillagerVariantComponent)) return false;
VillagerVariantComponent that = (VillagerVariantComponent) obj;
return this.villagerType.equals(that.villagerType);
}
@Override
public int hashCode() {
return Objects.hashCode(this.villagerType);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.color.DyeColor;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class WolfCollarComponent {
private DyeColor color;
public WolfCollarComponent(DyeColor color) {
this.color = color;
}
public static WolfCollarComponent read(PacketWrapper<?> wrapper) {
DyeColor type = DyeColor.read(wrapper);
return new WolfCollarComponent(type);
}
public static void write(PacketWrapper<?> wrapper, WolfCollarComponent component) {
DyeColor.write(wrapper, component.color);
}
public DyeColor getDyeColor() {
return this.color;
}
public void setDyeColor(DyeColor color) {
this.color = color;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WolfCollarComponent)) return false;
WolfCollarComponent that = (WolfCollarComponent) obj;
return this.color.equals(that.color);
}
@Override
public int hashCode() {
return Objects.hashCode(this.color);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfSoundVariant;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfSoundVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class WolfSoundVariantComponent {
private WolfSoundVariant soundVariant;
public WolfSoundVariantComponent(WolfSoundVariant soundVariant) {
this.soundVariant = soundVariant;
}
public static WolfSoundVariantComponent read(PacketWrapper<?> wrapper) {
WolfSoundVariant type = wrapper.readMappedEntity(WolfSoundVariants.getRegistry());
return new WolfSoundVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, WolfSoundVariantComponent component) {
wrapper.writeMappedEntity(component.soundVariant);
}
public WolfSoundVariant getSoundVariant() {
return this.soundVariant;
}
public void setSoundVariant(WolfSoundVariant soundVariant) {
this.soundVariant = soundVariant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WolfSoundVariantComponent)) return false;
WolfSoundVariantComponent that = (WolfSoundVariantComponent) obj;
return this.soundVariant.equals(that.soundVariant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.soundVariant);
}
}
@@ -0,0 +1,63 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfVariant;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfVariants;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class WolfVariantComponent {
private WolfVariant variant;
public WolfVariantComponent(WolfVariant variant) {
this.variant = variant;
}
public static WolfVariantComponent read(PacketWrapper<?> wrapper) {
WolfVariant type = wrapper.readMappedEntity(WolfVariants.getRegistry());
return new WolfVariantComponent(type);
}
public static void write(PacketWrapper<?> wrapper, WolfVariantComponent component) {
wrapper.writeMappedEntity(component.variant);
}
public WolfVariant getVariant() {
return this.variant;
}
public void setVariant(WolfVariant variant) {
this.variant = variant;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WolfVariantComponent)) return false;
WolfVariantComponent that = (WolfVariantComponent) obj;
return this.variant.equals(that.variant);
}
@Override
public int hashCode() {
return Objects.hashCode(this.variant);
}
}
@@ -18,9 +18,11 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.item.trimmaterial.TrimMaterial;
import com.github.retrooper.packetevents.protocol.item.trimpattern.TrimPattern;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import java.util.Objects;
@@ -28,8 +30,20 @@ public class ArmorTrim {
private TrimMaterial material;
private TrimPattern pattern;
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ArmorTrim(TrimMaterial material, TrimPattern pattern) {
this(material, pattern, true);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ArmorTrim(TrimMaterial material, TrimPattern pattern, boolean showInTooltip) {
this.material = material;
this.pattern = pattern;
@@ -39,14 +53,16 @@ public class ArmorTrim {
public static ArmorTrim read(PacketWrapper<?> wrapper) {
TrimMaterial material = TrimMaterial.read(wrapper);
TrimPattern pattern = TrimPattern.read(wrapper);
boolean showInTooltip = wrapper.readBoolean();
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ArmorTrim(material, pattern, showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ArmorTrim trim) {
TrimMaterial.write(wrapper, trim.material);
TrimPattern.write(wrapper, trim.pattern);
wrapper.writeBoolean(trim.showInTooltip);
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(trim.showInTooltip);
}
}
public TrimMaterial getMaterial() {
@@ -65,10 +81,18 @@ public class ArmorTrim {
this.pattern = pattern;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -81,13 +81,13 @@ public class BannerLayers {
public static Layer read(PacketWrapper<?> wrapper) {
BannerPattern pattern = wrapper.readMappedEntityOrDirect(
BannerPatterns.getRegistry(), BannerPattern::readDirect);
DyeColor color = wrapper.readEnum(DyeColor.values());
DyeColor color = DyeColor.read(wrapper);
return new Layer(pattern, color);
}
public static void write(PacketWrapper<?> wrapper, Layer layer) {
wrapper.writeMappedEntityOrDirect(layer.pattern, BannerPattern::writeDirect);
wrapper.writeEnum(layer.color);
DyeColor.write(wrapper, layer.color);
}
public BannerPattern getPattern() {
@@ -18,23 +18,37 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.component.predicates.ComponentMatchers;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
// why do I have to implement this mess, I just want to deserialize items
public class ItemAdventurePredicate {
private List<BlockPredicate> predicates;
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemAdventurePredicate(List<BlockPredicate> predicates) {
this(predicates, true);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemAdventurePredicate(List<BlockPredicate> predicates, boolean showInTooltip) {
this.predicates = predicates;
this.showInTooltip = showInTooltip;
@@ -42,13 +56,15 @@ public class ItemAdventurePredicate {
public static ItemAdventurePredicate read(PacketWrapper<?> wrapper) {
List<BlockPredicate> predicates = wrapper.readList(BlockPredicate::read);
boolean showInTooltip = wrapper.readBoolean();
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemAdventurePredicate(predicates, showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ItemAdventurePredicate predicate) {
wrapper.writeList(predicate.predicates, BlockPredicate::write);
wrapper.writeBoolean(predicate.showInTooltip);
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(predicate.showInTooltip);
}
}
public void addPredicate(BlockPredicate predicate) {
@@ -63,10 +79,18 @@ public class ItemAdventurePredicate {
this.predicates = predicates;
}
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -90,15 +114,29 @@ public class ItemAdventurePredicate {
private @Nullable MappedEntitySet<StateType.Mapped> blocks;
private @Nullable List<PropertyMatcher> properties;
private @Nullable NBTCompound nbt;
/**
* Added with 1.21.5
*/
private ComponentMatchers matchers;
public BlockPredicate(
@Nullable MappedEntitySet<StateType.Mapped> blocks,
@Nullable List<PropertyMatcher> properties,
@Nullable NBTCompound nbt
) {
this(blocks, properties, nbt, new ComponentMatchers());
}
public BlockPredicate(
@Nullable MappedEntitySet<StateType.Mapped> blocks,
@Nullable List<PropertyMatcher> properties,
@Nullable NBTCompound nbt,
ComponentMatchers matchers
) {
this.blocks = blocks;
this.properties = properties;
this.nbt = nbt;
this.matchers = matchers;
}
public static BlockPredicate read(PacketWrapper<?> wrapper) {
@@ -107,7 +145,9 @@ public class ItemAdventurePredicate {
List<PropertyMatcher> properties = wrapper.readOptional(
ew -> wrapper.readList(PropertyMatcher::read));
NBTCompound nbt = wrapper.readOptional(PacketWrapper::readNBT);
return new BlockPredicate(blocks, properties, nbt);
ComponentMatchers matchers = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)
? ComponentMatchers.read(wrapper) : new ComponentMatchers();
return new BlockPredicate(blocks, properties, nbt, matchers);
}
public static void write(PacketWrapper<?> wrapper, BlockPredicate predicate) {
@@ -115,6 +155,9 @@ public class ItemAdventurePredicate {
wrapper.writeOptional(predicate.properties,
(ew, val) -> ew.writeList(val, PropertyMatcher::write));
wrapper.writeOptional(predicate.nbt, PacketWrapper::writeNBT);
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
ComponentMatchers.write(wrapper, predicate.matchers);
}
}
public @Nullable MappedEntitySet<StateType.Mapped> getBlocks() {
@@ -148,6 +191,20 @@ public class ItemAdventurePredicate {
this.nbt = nbt;
}
/**
* Added with 1.21.5
*/
public ComponentMatchers getMatchers() {
return this.matchers;
}
/**
* Added with 1.21.5
*/
public void setMatchers(ComponentMatchers matchers) {
this.matchers = matchers;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
@@ -155,12 +212,13 @@ public class ItemAdventurePredicate {
BlockPredicate that = (BlockPredicate) obj;
if (!Objects.equals(this.blocks, that.blocks)) return false;
if (!Objects.equals(this.properties, that.properties)) return false;
return Objects.equals(this.nbt, that.nbt);
if (!Objects.equals(this.nbt, that.nbt)) return false;
return this.matchers.equals(that.matchers);
}
@Override
public int hashCode() {
return Objects.hash(this.blocks, this.properties, this.nbt);
return Objects.hash(this.blocks, this.properties, this.nbt, this.matchers);
}
}
@@ -37,6 +37,11 @@ public class ItemAttributeModifiers {
public static final ItemAttributeModifiers EMPTY = new ItemAttributeModifiers(
Collections.emptyList(), true) {
@Override
public void setModifiers(List<ModifierEntry> modifiers) {
throw new UnsupportedOperationException();
}
@Override
public void setShowInTooltip(boolean showInTooltip) {
throw new UnsupportedOperationException();
@@ -44,8 +49,20 @@ public class ItemAttributeModifiers {
};
private List<ModifierEntry> modifiers;
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemAttributeModifiers(List<ModifierEntry> modifiers) {
this(modifiers, true);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemAttributeModifiers(List<ModifierEntry> modifiers, boolean showInTooltip) {
this.modifiers = modifiers;
this.showInTooltip = showInTooltip;
@@ -53,13 +70,15 @@ public class ItemAttributeModifiers {
public static ItemAttributeModifiers read(PacketWrapper<?> wrapper) {
List<ModifierEntry> modifiers = wrapper.readList(ModifierEntry::read);
boolean showInTooltip = wrapper.readBoolean();
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemAttributeModifiers(modifiers, showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ItemAttributeModifiers modifiers) {
wrapper.writeList(modifiers.modifiers, ModifierEntry::write);
wrapper.writeBoolean(modifiers.showInTooltip);
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(modifiers.showInTooltip);
}
}
public void addModifier(ModifierEntry modifier) {
@@ -74,10 +93,18 @@ public class ItemAttributeModifiers {
this.modifiers = modifiers;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -0,0 +1,294 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageType;
import com.github.retrooper.packetevents.protocol.world.damagetype.DamageTypes;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Objects;
public class ItemBlocksAttacks {
private float blockDelaySeconds;
private float disableCooldownScale;
private List<DamageReduction> damageReductions;
private ItemDamageFunction itemDamage;
private @Nullable ResourceLocation bypassedBy;
private @Nullable Sound blockSound;
private @Nullable Sound disableSound;
public ItemBlocksAttacks(
float blockDelaySeconds, float disableCooldownScale, List<DamageReduction> damageReductions,
ItemDamageFunction itemDamage, @Nullable ResourceLocation bypassedBy,
@Nullable Sound blockSound, @Nullable Sound disableSound
) {
this.blockDelaySeconds = blockDelaySeconds;
this.disableCooldownScale = disableCooldownScale;
this.damageReductions = damageReductions;
this.itemDamage = itemDamage;
this.bypassedBy = bypassedBy;
this.blockSound = blockSound;
this.disableSound = disableSound;
}
public static ItemBlocksAttacks read(PacketWrapper<?> wrapper) {
float blockDelaySeconds = wrapper.readFloat();
float disableCooldownScale = wrapper.readFloat();
List<DamageReduction> damageReductions = wrapper.readList(DamageReduction::read);
ItemDamageFunction itemDamage = ItemDamageFunction.read(wrapper);
ResourceLocation bypassedBy = wrapper.readOptional(PacketWrapper::readIdentifier);
Sound blockSound = wrapper.readOptional(Sound::read);
Sound disableSound = wrapper.readOptional(Sound::read);
return new ItemBlocksAttacks(
blockDelaySeconds, disableCooldownScale, damageReductions,
itemDamage, bypassedBy, blockSound, disableSound);
}
public static void write(PacketWrapper<?> wrapper, ItemBlocksAttacks attack) {
wrapper.writeFloat(attack.blockDelaySeconds);
wrapper.writeFloat(attack.disableCooldownScale);
wrapper.writeList(attack.damageReductions, DamageReduction::write);
ItemDamageFunction.write(wrapper, attack.itemDamage);
wrapper.writeOptional(attack.bypassedBy, PacketWrapper::writeIdentifier);
wrapper.writeOptional(attack.blockSound, Sound::write);
wrapper.writeOptional(attack.disableSound, Sound::write);
}
public float getBlockDelaySeconds() {
return this.blockDelaySeconds;
}
public void setBlockDelaySeconds(float blockDelaySeconds) {
this.blockDelaySeconds = blockDelaySeconds;
}
public float getDisableCooldownScale() {
return this.disableCooldownScale;
}
public void setDisableCooldownScale(float disableCooldownScale) {
this.disableCooldownScale = disableCooldownScale;
}
public List<DamageReduction> getDamageReductions() {
return this.damageReductions;
}
public void setDamageReductions(List<DamageReduction> damageReductions) {
this.damageReductions = damageReductions;
}
public ItemDamageFunction getItemDamage() {
return this.itemDamage;
}
public void setItemDamage(ItemDamageFunction itemDamage) {
this.itemDamage = itemDamage;
}
public @Nullable ResourceLocation getBypassedBy() {
return this.bypassedBy;
}
public void setBypassedBy(@Nullable ResourceLocation bypassedBy) {
this.bypassedBy = bypassedBy;
}
public @Nullable Sound getBlockSound() {
return this.blockSound;
}
public void setBlockSound(@Nullable Sound blockSound) {
this.blockSound = blockSound;
}
public @Nullable Sound getDisableSound() {
return this.disableSound;
}
public void setDisableSound(@Nullable Sound disableSound) {
this.disableSound = disableSound;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemBlocksAttacks)) return false;
ItemBlocksAttacks that = (ItemBlocksAttacks) obj;
if (Float.compare(that.blockDelaySeconds, this.blockDelaySeconds) != 0) return false;
if (Float.compare(that.disableCooldownScale, this.disableCooldownScale) != 0) return false;
if (!this.damageReductions.equals(that.damageReductions)) return false;
if (!this.itemDamage.equals(that.itemDamage)) return false;
if (!Objects.equals(this.bypassedBy, that.bypassedBy)) return false;
if (!Objects.equals(this.blockSound, that.blockSound)) return false;
return Objects.equals(this.disableSound, that.disableSound);
}
@Override
public int hashCode() {
return Objects.hash(this.blockDelaySeconds, this.disableCooldownScale, this.damageReductions, this.itemDamage, this.bypassedBy, this.blockSound, this.disableSound);
}
public static final class DamageReduction {
private float horizontalBlockingAngle;
private @Nullable MappedEntitySet<DamageType> type;
private float base;
private float factor;
public DamageReduction(float horizontalBlockingAngle, @Nullable MappedEntitySet<DamageType> type, float base, float factor) {
this.horizontalBlockingAngle = horizontalBlockingAngle;
this.type = type;
this.base = base;
this.factor = factor;
}
public static DamageReduction read(PacketWrapper<?> wrapper) {
float horizontalBlockingAngle = wrapper.readFloat();
MappedEntitySet<DamageType> type = wrapper.readOptional(ew ->
MappedEntitySet.read(ew, DamageTypes.getRegistry()));
float base = wrapper.readFloat();
float factor = wrapper.readFloat();
return new DamageReduction(horizontalBlockingAngle, type, base, factor);
}
public static void write(PacketWrapper<?> wrapper, DamageReduction reduction) {
wrapper.writeFloat(reduction.horizontalBlockingAngle);
wrapper.writeOptional(reduction.type, MappedEntitySet::write);
wrapper.writeFloat(reduction.base);
wrapper.writeFloat(reduction.factor);
}
public float getHorizontalBlockingAngle() {
return this.horizontalBlockingAngle;
}
public void setHorizontalBlockingAngle(float horizontalBlockingAngle) {
this.horizontalBlockingAngle = horizontalBlockingAngle;
}
public @Nullable MappedEntitySet<DamageType> getType() {
return this.type;
}
public void setType(@Nullable MappedEntitySet<DamageType> type) {
this.type = type;
}
public float getBase() {
return this.base;
}
public void setBase(float base) {
this.base = base;
}
public float getFactor() {
return this.factor;
}
public void setFactor(float factor) {
this.factor = factor;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DamageReduction)) return false;
DamageReduction that = (DamageReduction) obj;
if (Float.compare(that.horizontalBlockingAngle, this.horizontalBlockingAngle) != 0) return false;
if (Float.compare(that.base, this.base) != 0) return false;
if (Float.compare(that.factor, this.factor) != 0) return false;
return Objects.equals(this.type, that.type);
}
@Override
public int hashCode() {
return Objects.hash(this.horizontalBlockingAngle, this.type, this.base, this.factor);
}
}
public static final class ItemDamageFunction {
private float threshold;
private float base;
private float factor;
public ItemDamageFunction(float threshold, float base, float factor) {
this.threshold = threshold;
this.base = base;
this.factor = factor;
}
public static ItemDamageFunction read(PacketWrapper<?> wrapper) {
float threshold = wrapper.readFloat();
float base = wrapper.readFloat();
float factor = wrapper.readFloat();
return new ItemDamageFunction(threshold, base, factor);
}
public static void write(PacketWrapper<?> wrapper, ItemDamageFunction function) {
wrapper.writeFloat(function.threshold);
wrapper.writeFloat(function.base);
wrapper.writeFloat(function.factor);
}
public float getThreshold() {
return this.threshold;
}
public void setThreshold(float threshold) {
this.threshold = threshold;
}
public float getBase() {
return this.base;
}
public void setBase(float base) {
this.base = base;
}
public float getFactor() {
return this.factor;
}
public void setFactor(float factor) {
this.factor = factor;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemDamageFunction)) return false;
ItemDamageFunction that = (ItemDamageFunction) obj;
if (Float.compare(that.threshold, this.threshold) != 0) return false;
if (Float.compare(that.base, this.base) != 0) return false;
return Float.compare(that.factor, this.factor) == 0;
}
@Override
public int hashCode() {
return Objects.hash(this.threshold, this.base, this.factor);
}
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemBreakSound {
private Sound sound;
public ItemBreakSound(Sound sound) {
this.sound = sound;
}
public static ItemBreakSound read(PacketWrapper<?> wrapper) {
Sound sound = Sound.read(wrapper);
return new ItemBreakSound(sound);
}
public static void write(PacketWrapper<?> wrapper, ItemBreakSound sound) {
Sound.write(wrapper, sound.sound);
}
public Sound getSound() {
return this.sound;
}
public void setSound(Sound sound) {
this.sound = sound;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemBreakSound)) return false;
ItemBreakSound that = (ItemBreakSound) obj;
return this.sound.equals(that.sound);
}
@Override
public int hashCode() {
return Objects.hashCode(this.sound);
}
}
@@ -18,15 +18,29 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import java.util.Objects;
public class ItemDyeColor {
private int rgb;
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemDyeColor(int rgb) {
this(rgb, true);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemDyeColor(int rgb, boolean showInTooltip) {
this.rgb = rgb;
this.showInTooltip = showInTooltip;
@@ -34,13 +48,15 @@ public class ItemDyeColor {
public static ItemDyeColor read(PacketWrapper<?> wrapper) {
int rgb = wrapper.readInt();
boolean showInTooltip = wrapper.readBoolean();
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemDyeColor(rgb, showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ItemDyeColor color) {
wrapper.writeInt(color.rgb);
wrapper.writeBoolean(color.showInTooltip);
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(color.showInTooltip);
}
}
public int getRgb() {
@@ -51,10 +67,18 @@ public class ItemDyeColor {
this.rgb = rgb;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -18,10 +18,12 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.item.enchantment.type.EnchantmentType;
import com.github.retrooper.packetevents.protocol.item.enchantment.type.EnchantmentTypes;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import java.util.Collections;
import java.util.Iterator;
@@ -32,6 +34,11 @@ public class ItemEnchantments implements Iterable<Map.Entry<EnchantmentType, Int
public static final ItemEnchantments EMPTY = new ItemEnchantments(
Collections.emptyMap(), true) {
@Override
public void setEnchantments(Map<EnchantmentType, Integer> enchantments) {
throw new UnsupportedOperationException();
}
@Override
public void setShowInTooltip(boolean showInTooltip) {
throw new UnsupportedOperationException();
@@ -39,8 +46,20 @@ public class ItemEnchantments implements Iterable<Map.Entry<EnchantmentType, Int
};
private Map<EnchantmentType, Integer> enchantments;
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemEnchantments(Map<EnchantmentType, Integer> enchantments) {
this(enchantments, true);
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemEnchantments(Map<EnchantmentType, Integer> enchantments, boolean showInTooltip) {
this.enchantments = Collections.unmodifiableMap(enchantments);
this.showInTooltip = showInTooltip;
@@ -51,7 +70,7 @@ public class ItemEnchantments implements Iterable<Map.Entry<EnchantmentType, Int
ew -> wrapper.readMappedEntity(EnchantmentTypes.getRegistry()),
PacketWrapper::readVarInt
);
boolean showInTooltip = wrapper.readBoolean();
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemEnchantments(enchantments, showInTooltip);
}
@@ -61,7 +80,9 @@ public class ItemEnchantments implements Iterable<Map.Entry<EnchantmentType, Int
(ew, enchantment) -> ew.writeVarInt(enchantment.getId(version)),
PacketWrapper::writeVarInt
);
wrapper.writeBoolean(enchantments.isShowInTooltip());
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(enchantments.isShowInTooltip());
}
}
public int getEnchantmentLevel(EnchantmentType enchantment) {
@@ -92,10 +113,18 @@ public class ItemEnchantments implements Iterable<Map.Entry<EnchantmentType, Int
this.enchantments = enchantments;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -18,6 +18,7 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
@@ -25,6 +26,7 @@ import com.github.retrooper.packetevents.protocol.player.EquipmentSlot;
import com.github.retrooper.packetevents.protocol.sound.Sound;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@@ -39,7 +41,9 @@ public class ItemEquippable {
private boolean dispensable;
private boolean swappable;
private boolean damageOnHurt;
private boolean equipOnInteract;
@ApiStatus.Obsolete
public ItemEquippable(
EquipmentSlot slot,
Sound equipSound,
@@ -49,6 +53,21 @@ public class ItemEquippable {
boolean dispensable,
boolean swappable,
boolean damageOnHurt
) {
this(slot, equipSound, assetId, cameraOverlay, allowedEntities,
dispensable, swappable, damageOnHurt, false);
}
public ItemEquippable(
EquipmentSlot slot,
Sound equipSound,
@Nullable ResourceLocation assetId,
@Nullable ResourceLocation cameraOverlay,
@Nullable MappedEntitySet<EntityType> allowedEntities,
boolean dispensable,
boolean swappable,
boolean damageOnHurt,
boolean equipOnInteract
) {
this.slot = slot;
this.equipSound = equipSound;
@@ -58,20 +77,22 @@ public class ItemEquippable {
this.dispensable = dispensable;
this.swappable = swappable;
this.damageOnHurt = damageOnHurt;
this.equipOnInteract = equipOnInteract;
}
public static ItemEquippable read(PacketWrapper<?> wrapper) {
EquipmentSlot slot = wrapper.readEnum(EquipmentSlot.values());
Sound equipSound = Sound.read(wrapper);
ResourceLocation model = wrapper.readOptional(PacketWrapper::readIdentifier);
ResourceLocation assetId = wrapper.readOptional(PacketWrapper::readIdentifier);
ResourceLocation cameraOverlay = wrapper.readOptional(PacketWrapper::readIdentifier);
MappedEntitySet<EntityType> allowedEntities = wrapper.readOptional(
ew -> MappedEntitySet.read(ew, EntityTypes::getById));
boolean dispensable = wrapper.readBoolean();
boolean swappable = wrapper.readBoolean();
boolean damageOnHurt = wrapper.readBoolean();
return new ItemEquippable(slot, equipSound, model,
cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt);
boolean equipOnInteract = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) && wrapper.readBoolean();
return new ItemEquippable(slot, equipSound, assetId,
cameraOverlay, allowedEntities, dispensable, swappable, damageOnHurt, equipOnInteract);
}
public static void write(PacketWrapper<?> wrapper, ItemEquippable equippable) {
@@ -83,6 +104,9 @@ public class ItemEquippable {
wrapper.writeBoolean(equippable.dispensable);
wrapper.writeBoolean(equippable.swappable);
wrapper.writeBoolean(equippable.damageOnHurt);
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(equippable.equipOnInteract);
}
}
public EquipmentSlot getSlot() {
@@ -149,6 +173,20 @@ public class ItemEquippable {
this.damageOnHurt = damageOnHurt;
}
/**
* Added with 1.21.5
*/
public boolean isEquipOnInteract() {
return this.equipOnInteract;
}
/**
* Added with 1.21.5
*/
public void setEquipOnInteract(boolean equipOnInteract) {
this.equipOnInteract = equipOnInteract;
}
@Deprecated
public @Nullable ResourceLocation getModel() {
return this.assetId;
@@ -171,16 +209,17 @@ public class ItemEquippable {
if (!Objects.equals(this.equipSound, that.equipSound)) return false;
if (!Objects.equals(this.assetId, that.assetId)) return false;
if (!Objects.equals(this.cameraOverlay, that.cameraOverlay)) return false;
return Objects.equals(this.allowedEntities, that.allowedEntities);
if (!Objects.equals(this.allowedEntities, that.allowedEntities)) return false;
return Objects.equals(this.equipOnInteract, that.equipOnInteract);
}
@Override
public int hashCode() {
return Objects.hash(this.slot, this.equipSound, this.assetId, this.cameraOverlay, this.allowedEntities, this.dispensable, this.swappable, this.damageOnHurt);
return Objects.hash(this.slot, this.equipSound, this.assetId, this.cameraOverlay, this.allowedEntities, this.dispensable, this.swappable, this.damageOnHurt, this.equipOnInteract);
}
@Override
public String toString() {
return "ItemEquippable{slot=" + this.slot + ", equipSound=" + this.equipSound + ", model=" + this.assetId + ", cameraOverlay=" + this.cameraOverlay + ", allowedEntities=" + this.allowedEntities + ", dispensable=" + this.dispensable + ", swappable=" + this.swappable + ", damageOnHurt=" + this.damageOnHurt + '}';
return "ItemEquippable{slot=" + this.slot + ", equipSound=" + this.equipSound + ", assetId=" + this.assetId + ", cameraOverlay=" + this.cameraOverlay + ", allowedEntities=" + this.allowedEntities + ", dispensable=" + this.dispensable + ", swappable=" + this.swappable + ", damageOnHurt=" + this.damageOnHurt + ", equipOnInteract=" + this.equipOnInteract + '}';
}
}
@@ -0,0 +1,74 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.item.instrument.Instrument;
import com.github.retrooper.packetevents.protocol.item.instrument.Instruments;
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemInstrument {
private MaybeMappedEntity<Instrument> instrument;
public ItemInstrument(MaybeMappedEntity<Instrument> instrument) {
this.instrument = instrument;
}
public static ItemInstrument read(PacketWrapper<?> wrapper) {
MaybeMappedEntity<Instrument> instrument;
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
instrument = MaybeMappedEntity.read(wrapper, Instruments.getRegistry(), Instrument::read);
} else {
instrument = new MaybeMappedEntity<>(Instrument.read(wrapper));
}
return new ItemInstrument(instrument);
}
public static void write(PacketWrapper<?> wrapper, ItemInstrument instrument) {
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
MaybeMappedEntity.write(wrapper, instrument.instrument, Instrument::write);
} else {
Instrument.write(wrapper, instrument.instrument.getValueOrThrow());
}
}
public MaybeMappedEntity<Instrument> getInstrument() {
return this.instrument;
}
public void setInstrument(MaybeMappedEntity<Instrument> instrument) {
this.instrument = instrument;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemInstrument)) return false;
ItemInstrument that = (ItemInstrument) obj;
return this.instrument.equals(that.instrument);
}
@Override
public int hashCode() {
return Objects.hashCode(this.instrument);
}
}
@@ -18,20 +18,35 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.item.jukebox.IJukeboxSong;
import com.github.retrooper.packetevents.protocol.item.jukebox.JukeboxSong;
import com.github.retrooper.packetevents.protocol.item.jukebox.JukeboxSongs;
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class ItemJukeboxPlayable {
private @Nullable IJukeboxSong song;
private @Nullable ResourceLocation songKey;
private MaybeMappedEntity<IJukeboxSong> song;
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemJukeboxPlayable(MaybeMappedEntity<IJukeboxSong> song) {
this(song, true);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemJukeboxPlayable(
@Nullable JukeboxSong song,
@Nullable ResourceLocation songKey,
@@ -40,85 +55,99 @@ public class ItemJukeboxPlayable {
this((IJukeboxSong) song, songKey, showInTooltip);
}
/**
* use {@link #ItemJukeboxPlayable(MaybeMappedEntity, boolean)}
*/
@Deprecated
public ItemJukeboxPlayable(
@Nullable IJukeboxSong song,
@Nullable ResourceLocation songKey,
boolean showInTooltip
) {
if ((song == null) == (songKey == null)) {
throw new IllegalStateException("Illegal state of both song and "
+ "song key combined: " + song + " / " + songKey);
}
this(new MaybeMappedEntity<>(song, songKey), showInTooltip);
}
/**
* {@link #showInTooltip} has been removed in 1.21.5
*/
@ApiStatus.Obsolete
public ItemJukeboxPlayable(
MaybeMappedEntity<IJukeboxSong> song,
boolean showInTooltip
) {
this.song = song;
this.songKey = songKey;
this.showInTooltip = showInTooltip;
}
public static ItemJukeboxPlayable read(PacketWrapper<?> wrapper) {
IJukeboxSong song;
ResourceLocation songKey;
if (wrapper.readBoolean()) {
song = IJukeboxSong.read(wrapper);
songKey = null;
} else {
song = null;
songKey = wrapper.readIdentifier();
}
boolean showInTooltip = wrapper.readBoolean();
return new ItemJukeboxPlayable(song, songKey, showInTooltip);
MaybeMappedEntity<IJukeboxSong> song = MaybeMappedEntity.read(wrapper, JukeboxSongs.getRegistry(), IJukeboxSong::read);
boolean showInTooltip = wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemJukeboxPlayable(song, showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ItemJukeboxPlayable jukeboxPlayable) {
if (jukeboxPlayable.song != null) {
wrapper.writeBoolean(true);
IJukeboxSong.write(wrapper, jukeboxPlayable.song);
} else {
assert jukeboxPlayable.songKey != null;
wrapper.writeBoolean(false);
wrapper.writeIdentifier(jukeboxPlayable.songKey);
MaybeMappedEntity.write(wrapper, jukeboxPlayable.song, IJukeboxSong::write);
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(jukeboxPlayable.showInTooltip);
}
wrapper.writeBoolean(jukeboxPlayable.showInTooltip);
}
public @Nullable IJukeboxSong getJukeboxSong() {
public MaybeMappedEntity<IJukeboxSong> getSongHolder() {
return this.song;
}
public void setSongHolder(MaybeMappedEntity<IJukeboxSong> songHolder) {
this.song = songHolder;
}
public @Nullable IJukeboxSong getJukeboxSong() {
return this.song.getValue();
}
public void setJukeboxSong(@Nullable IJukeboxSong song) {
this.song = new MaybeMappedEntity<>(song);
}
public void setJukeboxSong(@Nullable JukeboxSong song) {
this.song = song;
this.songKey = null;
this.setJukeboxSong((IJukeboxSong) song);
}
@Deprecated
public @Nullable JukeboxSong getSong() {
if (this.song == null) {
IJukeboxSong song = this.getJukeboxSong();
if (song == null) {
return null;
} else if (this.song instanceof JukeboxSong) {
return (JukeboxSong) this.song;
} else if (song instanceof JukeboxSong) {
return (JukeboxSong) song;
}
return (JukeboxSong) this.song.copy(null);
return (JukeboxSong) song.copy(null);
}
@Deprecated
public void setSong(JukeboxSong song) {
this.song = song;
this.songKey = null;
this.setJukeboxSong((IJukeboxSong) song);
}
public @Nullable ResourceLocation getSongKey() {
return this.songKey;
return this.song.getName();
}
public void setSongKey(ResourceLocation songKey) {
this.song = null;
this.songKey = songKey;
this.song = new MaybeMappedEntity<>(songKey);
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed in 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@@ -130,11 +159,11 @@ public class ItemJukeboxPlayable {
ItemJukeboxPlayable that = (ItemJukeboxPlayable) obj;
if (this.showInTooltip != that.showInTooltip) return false;
if (!Objects.equals(this.song, that.song)) return false;
return Objects.equals(this.songKey, that.songKey);
return Objects.equals(this.song, that.song);
}
@Override
public int hashCode() {
return Objects.hash(this.song, this.songKey, this.showInTooltip);
return Objects.hash(this.song, this.song, this.showInTooltip);
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemPotionDurationScale {
private float scale;
public ItemPotionDurationScale(float scale) {
this.scale = scale;
}
public static ItemPotionDurationScale read(PacketWrapper<?> wrapper) {
float scale = wrapper.readFloat();
return new ItemPotionDurationScale(scale);
}
public static void write(PacketWrapper<?> wrapper, ItemPotionDurationScale scale) {
wrapper.writeFloat(scale.scale);
}
public float getScale() {
return this.scale;
}
public void setScale(float scale) {
this.scale = scale;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemPotionDurationScale)) return false;
ItemPotionDurationScale that = (ItemPotionDurationScale) obj;
return Float.compare(that.scale, this.scale) == 0;
}
@Override
public int hashCode() {
return Objects.hashCode(this.scale);
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemProvidesBannerPatterns {
private ResourceLocation tagKey;
public ItemProvidesBannerPatterns(ResourceLocation tagKey) {
this.tagKey = tagKey;
}
public static ItemProvidesBannerPatterns read(PacketWrapper<?> wrapper) {
ResourceLocation tagKey = wrapper.readIdentifier();
return new ItemProvidesBannerPatterns(tagKey);
}
public static void write(PacketWrapper<?> wrapper, ItemProvidesBannerPatterns patterns) {
wrapper.writeIdentifier(patterns.tagKey);
}
public ResourceLocation getTagKey() {
return this.tagKey;
}
public void setTagKey(ResourceLocation tagKey) {
this.tagKey = tagKey;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemProvidesBannerPatterns)) return false;
ItemProvidesBannerPatterns that = (ItemProvidesBannerPatterns) obj;
return this.tagKey.equals(that.tagKey);
}
@Override
public int hashCode() {
return Objects.hashCode(this.tagKey);
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.protocol.item.trimmaterial.TrimMaterial;
import com.github.retrooper.packetevents.protocol.item.trimmaterial.TrimMaterials;
import com.github.retrooper.packetevents.protocol.mapper.MaybeMappedEntity;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemProvidesTrimMaterial {
private MaybeMappedEntity<TrimMaterial> material;
public ItemProvidesTrimMaterial(MaybeMappedEntity<TrimMaterial> material) {
this.material = material;
}
public static ItemProvidesTrimMaterial read(PacketWrapper<?> wrapper) {
MaybeMappedEntity<TrimMaterial> material = MaybeMappedEntity.read(wrapper, TrimMaterials.getRegistry(), TrimMaterial::read);
return new ItemProvidesTrimMaterial(material);
}
public static void write(PacketWrapper<?> wrapper, ItemProvidesTrimMaterial material) {
MaybeMappedEntity.write(wrapper, material.material, TrimMaterial::write);
}
public MaybeMappedEntity<TrimMaterial> getMaterial() {
return this.material;
}
public void setMaterial(MaybeMappedEntity<TrimMaterial> material) {
this.material = material;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemProvidesTrimMaterial)) return false;
ItemProvidesTrimMaterial that = (ItemProvidesTrimMaterial) obj;
return this.material.equals(that.material);
}
@Override
public int hashCode() {
return Objects.hashCode(this.material);
}
}
@@ -18,6 +18,7 @@
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
@@ -32,24 +33,37 @@ public class ItemTool {
private List<Rule> rules;
private float defaultMiningSpeed;
private int damagePerBlock;
/**
* Added with 1.21.5
*/
private boolean canDestroyBlocksInCreative;
public ItemTool(List<Rule> rules, float defaultMiningSpeed, int damagePerBlock) {
this(rules, defaultMiningSpeed, damagePerBlock, true);
}
public ItemTool(List<Rule> rules, float defaultMiningSpeed, int damagePerBlock, boolean canDestroyBlocksInCreative) {
this.rules = rules;
this.defaultMiningSpeed = defaultMiningSpeed;
this.damagePerBlock = damagePerBlock;
this.canDestroyBlocksInCreative = canDestroyBlocksInCreative;
}
public static ItemTool read(PacketWrapper<?> wrapper) {
List<Rule> rules = wrapper.readList(Rule::read);
float defaultMiningSpeed = wrapper.readFloat();
int damagePerBlock = wrapper.readVarInt();
return new ItemTool(rules, defaultMiningSpeed, damagePerBlock);
boolean canDestroyBlocksInCreative = wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5) || wrapper.readBoolean();
return new ItemTool(rules, defaultMiningSpeed, damagePerBlock, canDestroyBlocksInCreative);
}
public static void write(PacketWrapper<?> wrapper, ItemTool tool) {
wrapper.writeList(tool.rules, Rule::write);
wrapper.writeFloat(tool.defaultMiningSpeed);
wrapper.writeVarInt(tool.damagePerBlock);
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(tool.canDestroyBlocksInCreative);
}
}
public void addRule(Rule rule) {
@@ -80,6 +94,20 @@ public class ItemTool {
this.damagePerBlock = damagePerBlock;
}
/**
* Added with 1.21.5
*/
public boolean isCanDestroyBlocksInCreative() {
return this.canDestroyBlocksInCreative;
}
/**
* Added with 1.21.5
*/
public void setCanDestroyBlocksInCreative(boolean canDestroyBlocksInCreative) {
this.canDestroyBlocksInCreative = canDestroyBlocksInCreative;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
@@ -87,12 +115,13 @@ public class ItemTool {
ItemTool itemTool = (ItemTool) obj;
if (Float.compare(itemTool.defaultMiningSpeed, this.defaultMiningSpeed) != 0) return false;
if (this.damagePerBlock != itemTool.damagePerBlock) return false;
return this.rules.equals(itemTool.rules);
if (!this.rules.equals(itemTool.rules)) return false;
return this.canDestroyBlocksInCreative == itemTool.canDestroyBlocksInCreative;
}
@Override
public int hashCode() {
return Objects.hash(this.rules, this.defaultMiningSpeed, this.damagePerBlock);
return Objects.hash(this.rules, this.defaultMiningSpeed, this.damagePerBlock, this.canDestroyBlocksInCreative);
}
public static class Rule {
@@ -0,0 +1,79 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.protocol.component.ComponentType;
import com.github.retrooper.packetevents.protocol.component.ComponentTypes;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
public class ItemTooltipDisplay {
private boolean hideTooltip;
private Set<ComponentType<?>> hiddenComponents;
public ItemTooltipDisplay(boolean hideTooltip, Set<ComponentType<?>> hiddenComponents) {
this.hideTooltip = hideTooltip;
this.hiddenComponents = hiddenComponents;
}
public static ItemTooltipDisplay read(PacketWrapper<?> wrapper) {
boolean hideTooltip = wrapper.readBoolean();
Set<ComponentType<?>> hiddenComponents = wrapper.readCollection(LinkedHashSet::new,
ew -> ew.readMappedEntity(ComponentTypes.getRegistry()));
return new ItemTooltipDisplay(hideTooltip, hiddenComponents);
}
public static void write(PacketWrapper<?> wrapper, ItemTooltipDisplay tooltipDisplay) {
wrapper.writeBoolean(tooltipDisplay.hideTooltip);
wrapper.writeCollection(tooltipDisplay.hiddenComponents, PacketWrapper::writeMappedEntity);
}
public boolean isHideTooltip() {
return this.hideTooltip;
}
public void setHideTooltip(boolean hideTooltip) {
this.hideTooltip = hideTooltip;
}
public Set<ComponentType<?>> getHiddenComponents() {
return this.hiddenComponents;
}
public void setHiddenComponents(Set<ComponentType<?>> hiddenComponents) {
this.hiddenComponents = hiddenComponents;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemTooltipDisplay)) return false;
ItemTooltipDisplay that = (ItemTooltipDisplay) obj;
if (this.hideTooltip != that.hideTooltip) return false;
return this.hiddenComponents.equals(that.hiddenComponents);
}
@Override
public int hashCode() {
return Objects.hash(this.hideTooltip, this.hiddenComponents);
}
}
@@ -0,0 +1,88 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import java.util.Objects;
public class ItemUnbreakable {
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
private boolean showInTooltip;
public ItemUnbreakable() {
this(true);
}
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public ItemUnbreakable(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
public static ItemUnbreakable read(PacketWrapper<?> wrapper) {
if (wrapper.getServerVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5)) {
return new ItemUnbreakable();
}
boolean showInTooltip = wrapper.readBoolean();
return new ItemUnbreakable(showInTooltip);
}
public static void write(PacketWrapper<?> wrapper, ItemUnbreakable value) {
if (wrapper.getServerVersion().isOlderThan(ServerVersion.V_1_21_5)) {
wrapper.writeBoolean(value.showInTooltip);
}
}
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public boolean isShowInTooltip() {
return this.showInTooltip;
}
/**
* Removed with 1.21.5
*/
@ApiStatus.Obsolete
public void setShowInTooltip(boolean showInTooltip) {
this.showInTooltip = showInTooltip;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemUnbreakable)) return false;
ItemUnbreakable that = (ItemUnbreakable) obj;
return this.showInTooltip == that.showInTooltip;
}
@Override
public int hashCode() {
return Objects.hashCode(this.showInTooltip);
}
}
@@ -0,0 +1,74 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.builtin.item;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class ItemWeapon {
private int itemDamagePerAttack;
private float disableBlockingForSeconds;
public ItemWeapon(int itemDamagePerAttack, float disableBlockingForSeconds) {
this.itemDamagePerAttack = itemDamagePerAttack;
this.disableBlockingForSeconds = disableBlockingForSeconds;
}
public static ItemWeapon read(PacketWrapper<?> wrapper) {
int itemDamagePerAttack = wrapper.readVarInt();
float disableBlockingForSeconds = wrapper.readFloat();
return new ItemWeapon(itemDamagePerAttack, disableBlockingForSeconds);
}
public static void write(PacketWrapper<?> wrapper, ItemWeapon weapon) {
wrapper.writeVarInt(weapon.itemDamagePerAttack);
wrapper.writeFloat(weapon.disableBlockingForSeconds);
}
public int getItemDamagePerAttack() {
return this.itemDamagePerAttack;
}
public void setItemDamagePerAttack(int itemDamagePerAttack) {
this.itemDamagePerAttack = itemDamagePerAttack;
}
public float getDisableBlockingForSeconds() {
return this.disableBlockingForSeconds;
}
public void setDisableBlockingForSeconds(float disableBlockingForSeconds) {
this.disableBlockingForSeconds = disableBlockingForSeconds;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ItemWeapon)) return false;
ItemWeapon that = (ItemWeapon) obj;
if (this.itemDamagePerAttack != that.itemDamagePerAttack) return false;
return Float.compare(that.disableBlockingForSeconds, this.disableBlockingForSeconds) == 0;
}
@Override
public int hashCode() {
return Objects.hash(this.itemDamagePerAttack, this.disableBlockingForSeconds);
}
}
@@ -0,0 +1,81 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.protocol.component.ComponentPredicate;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ComponentMatchers {
private ComponentPredicate components;
private List<TypedComponentPredicate<?>> predicates;
public ComponentMatchers() {
this(new ComponentPredicate(), new ArrayList<>());
}
public ComponentMatchers(ComponentPredicate components, List<TypedComponentPredicate<?>> predicates) {
this.components = components;
this.predicates = predicates;
}
public static ComponentMatchers read(PacketWrapper<?> wrapper) {
ComponentPredicate components = ComponentPredicate.read(wrapper);
List<TypedComponentPredicate<?>> predicates = wrapper.readList(TypedComponentPredicate::read);
return new ComponentMatchers(components, predicates);
}
public static void write(PacketWrapper<?> wrapper, ComponentMatchers matchers) {
ComponentPredicate.write(wrapper, matchers.components);
wrapper.writeList(matchers.predicates, TypedComponentPredicate::write);
}
public ComponentPredicate getComponents() {
return this.components;
}
public void setComponents(ComponentPredicate components) {
this.components = components;
}
public List<TypedComponentPredicate<?>> getPredicates() {
return this.predicates;
}
public void setPredicates(List<TypedComponentPredicate<?>> predicates) {
this.predicates = predicates;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ComponentMatchers)) return false;
ComponentMatchers that = (ComponentMatchers) obj;
if (!this.components.equals(that.components)) return false;
return this.predicates.equals(that.predicates);
}
@Override
public int hashCode() {
return Objects.hash(this.components, this.predicates);
}
}
@@ -0,0 +1,29 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
public interface ComponentPredicateType<T extends IComponentPredicate> extends MappedEntity {
T read(PacketWrapper<?> wrapper);
void write(PacketWrapper<?> wrapper, T predicate);
}
@@ -0,0 +1,96 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
/**
* This implementation is experimental and not done yet. As I don't expect
* component predicates to be used in packetevents at all, it is currently not
* read from/to NBT; if you want/need this though, feel free to mention it
* via GitHub/Discord - or open a PR!
*/
public final class ComponentPredicateTypes {
private static final VersionedRegistry<ComponentPredicateType<?>> REGISTRY =
new VersionedRegistry<>("data_component_predicate_type");
private ComponentPredicateTypes() {
}
@ApiStatus.Internal
public static <T extends IComponentPredicate> ComponentPredicateType<T> define(
String key, PacketWrapper.Reader<T> reader, PacketWrapper.Writer<T> writer) {
return REGISTRY.define(key, data ->
new StaticComponentPredicateType<>(data, reader, writer));
}
public static VersionedRegistry<ComponentPredicateType<?>> getRegistry() {
return REGISTRY;
}
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> DAMAGE =
define("damage", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> ENCHANTMENTS =
define("enchantments", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> STORED_ENCHANTMENTS =
define("stored_enchantments", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> POTION_CONTENTS =
define("potion_contents", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> CUSTOM_DATA =
define("custom_data", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> CONTAINER =
define("container", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> BUNDLE_CONTENTS =
define("bundle_contents", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> FIREWORK_EXPLOSION =
define("firework_explosion", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> FIREWORKS =
define("fireworks", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> WRITABLE_BOOK_CONTENT =
define("writable_book_content", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> WRITTEN_BOOK_CONTENT =
define("written_book_content", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> ATTRIBUTE_MODIFIERS =
define("attribute_modifiers", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> TRIM =
define("trim", NbtComponentPredicate::read, NbtComponentPredicate::write);
@ApiStatus.Experimental
public static final ComponentPredicateType<NbtComponentPredicate> JUKEBOX_PLAYABLE =
define("jukebox_playable", NbtComponentPredicate::read, NbtComponentPredicate::write);
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,22 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
public interface IComponentPredicate {
}
@@ -0,0 +1,60 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import java.util.Objects;
@ApiStatus.Experimental
public class NbtComponentPredicate implements IComponentPredicate {
private final NBT tag;
public NbtComponentPredicate(NBT tag) {
this.tag = tag;
}
public static NbtComponentPredicate read(PacketWrapper<?> wrapper) {
NBT tag = wrapper.readNBTRaw();
return new NbtComponentPredicate(tag);
}
public static void write(PacketWrapper<?> wrapper, NbtComponentPredicate predicate) {
wrapper.writeNBTRaw(predicate.tag);
}
public NBT getTag() {
return this.tag;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof NbtComponentPredicate)) return false;
NbtComponentPredicate that = (NbtComponentPredicate) obj;
return this.tag.equals(that.tag);
}
@Override
public int hashCode() {
return Objects.hashCode(this.tag);
}
}
@@ -0,0 +1,56 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticComponentPredicateType<T extends IComponentPredicate> extends AbstractMappedEntity implements ComponentPredicateType<T> {
private final PacketWrapper.Reader<T> reader;
private final PacketWrapper.Writer<T> writer;
public StaticComponentPredicateType(PacketWrapper.Reader<T> reader, PacketWrapper.Writer<T> writer) {
this(null, reader, writer);
}
@ApiStatus.Internal
public StaticComponentPredicateType(
@Nullable TypesBuilderData data,
PacketWrapper.Reader<T> reader,
PacketWrapper.Writer<T> writer
) {
super(data);
this.reader = reader;
this.writer = writer;
}
@Override
public T read(PacketWrapper<?> wrapper) {
return this.reader.apply(wrapper);
}
@Override
public void write(PacketWrapper<?> wrapper, T predicate) {
this.writer.accept(wrapper, predicate);
}
}
@@ -0,0 +1,67 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.component.predicates;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import java.util.Objects;
public class TypedComponentPredicate<T extends IComponentPredicate> {
private final ComponentPredicateType<T> type;
private final T predicate;
public TypedComponentPredicate(ComponentPredicateType<T> type, T predicate) {
this.type = type;
this.predicate = predicate;
}
@SuppressWarnings("unchecked")
public static TypedComponentPredicate<?> read(PacketWrapper<?> wrapper) {
ComponentPredicateType<?> type = wrapper.readMappedEntity(ComponentPredicateTypes.getRegistry());
IComponentPredicate predicate = type.read(wrapper);
return new TypedComponentPredicate<>((ComponentPredicateType<IComponentPredicate>) type, predicate);
}
public static <T extends IComponentPredicate> void write(PacketWrapper<?> wrapper, TypedComponentPredicate<T> predicate) {
wrapper.writeMappedEntity(predicate.type);
predicate.type.write(wrapper, predicate.predicate);
}
public ComponentPredicateType<T> getType() {
return this.type;
}
public T getPredicate() {
return this.predicate;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof TypedComponentPredicate)) return false;
TypedComponentPredicate<?> that = (TypedComponentPredicate<?>) obj;
if (!this.type.equals(that.type)) return false;
return this.predicate.equals(that.predicate);
}
@Override
public int hashCode() {
return Objects.hash(this.type, this.predicate);
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.axolotl;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface AxolotlVariant extends MappedEntity {
}
@@ -0,0 +1,50 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.axolotl;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class AxolotlVariants {
private static final VersionedRegistry<AxolotlVariant> REGISTRY =
new VersionedRegistry<>("axolotl_variant");
private AxolotlVariants() {
}
@ApiStatus.Internal
public static AxolotlVariant define(String name) {
return REGISTRY.define(name, StaticAxolotlVariant::new);
}
public static VersionedRegistry<AxolotlVariant> getRegistry() {
return REGISTRY;
}
public static final AxolotlVariant LUCY = define("lucy");
public static final AxolotlVariant WILD = define("wild");
public static final AxolotlVariant GOLD = define("gold");
public static final AxolotlVariant CYAN = define("cyan");
public static final AxolotlVariant BLUE = define("blue");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.axolotl;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticAxolotlVariant extends AbstractMappedEntity implements AxolotlVariant {
@ApiStatus.Internal
public StaticAxolotlVariant(@Nullable TypesBuilderData data) {
super(data);
}
}
@@ -0,0 +1,56 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cat;
import com.github.retrooper.packetevents.protocol.mapper.CopyableEntity;
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
public interface CatVariant extends MappedEntity, CopyableEntity<CatVariant>, DeepComparableEntity {
ResourceLocation getAssetId();
static CatVariant read(PacketWrapper<?> wrapper) {
return wrapper.readMappedEntity(CatVariants.getRegistry());
}
static void write(PacketWrapper<?> wrapper, CatVariant variant) {
wrapper.writeMappedEntity(variant);
}
static CatVariant decode(NBT nbt, ClientVersion version, @Nullable TypesBuilderData data) {
NBTCompound compound = (NBTCompound) nbt;
ResourceLocation assetId = new ResourceLocation(compound.getStringTagValueOrThrow("asset_id"));
return new StaticCatVariant(data, assetId);
}
static NBT encode(CatVariant variant, ClientVersion version) {
NBTCompound compound = new NBTCompound();
compound.setTag("asset_id", new NBTString(variant.getAssetId().toString()));
return compound;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cat;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class CatVariants {
private static final VersionedRegistry<CatVariant> REGISTRY =
new VersionedRegistry<>("cat_variant");
private CatVariants() {
}
@ApiStatus.Internal
public static CatVariant define(String name) {
ResourceLocation assetId = new ResourceLocation("entity/cat/" + name);
return REGISTRY.define(name, data ->
new StaticCatVariant(data, assetId));
}
public static VersionedRegistry<CatVariant> getRegistry() {
return REGISTRY;
}
public static final CatVariant ALL_BLACK = define("all_black");
public static final CatVariant BLACK = define("black");
public static final CatVariant BRITISH_SHORTHAIR = define("british_shorthair");
public static final CatVariant CALICO = define("calico");
public static final CatVariant JELLIE = define("jellie");
public static final CatVariant PERSIAN = define("persian");
public static final CatVariant RAGDOLL = define("ragdoll");
public static final CatVariant RED = define("red");
public static final CatVariant SIAMESE = define("siamese");
public static final CatVariant TABBY = define("tabby");
public static final CatVariant WHITE = define("white");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cat;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class StaticCatVariant extends AbstractMappedEntity implements CatVariant {
private final ResourceLocation assetId;
public StaticCatVariant(ResourceLocation assetId) {
this(null, assetId);
}
@ApiStatus.Internal
public StaticCatVariant(@Nullable TypesBuilderData data, ResourceLocation assetId) {
super(data);
this.assetId = assetId;
}
@Override
public CatVariant copy(@Nullable TypesBuilderData newData) {
return new StaticCatVariant(newData, this.assetId);
}
@Override
public ResourceLocation getAssetId() {
return this.assetId;
}
@Override
public boolean deepEquals(Object obj) {
if (!(obj instanceof StaticCatVariant)) return false;
if (!super.equals(obj)) return false;
StaticCatVariant that = (StaticCatVariant) obj;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId);
}
}
@@ -0,0 +1,87 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.chicken;
import com.github.retrooper.packetevents.protocol.mapper.CopyableEntity;
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
public interface ChickenVariant extends MappedEntity, CopyableEntity<ChickenVariant>, DeepComparableEntity {
ModelType getModelType();
ResourceLocation getAssetId();
static ChickenVariant read(PacketWrapper<?> wrapper) {
return wrapper.readMappedEntity(ChickenVariants.getRegistry());
}
static void write(PacketWrapper<?> wrapper, ChickenVariant variant) {
wrapper.writeMappedEntity(variant);
}
static ChickenVariant decode(NBT nbt, ClientVersion version, @Nullable TypesBuilderData data) {
NBTCompound compound = (NBTCompound) nbt;
String modelTypeString = compound.getStringTagValueOrNull("model");
ModelType modelType = modelTypeString != null ? ModelType.getByName(modelTypeString) : ModelType.NORMAL;
ResourceLocation assetId = new ResourceLocation(compound.getStringTagValueOrThrow("asset_id"));
return new StaticChickenVariant(data, modelType, assetId);
}
static NBT encode(ChickenVariant variant, ClientVersion version) {
NBTCompound compound = new NBTCompound();
compound.setTag("model", new NBTString(variant.getModelType().getName()));
compound.setTag("asset_id", new NBTString(variant.getAssetId().toString()));
return compound;
}
enum ModelType {
NORMAL("normal"),
COLD("cold"),
;
private static final Index<String, ModelType> NAME_INDEX = Index.create(
ModelType.class, ModelType::getName);
private final String name;
ModelType(String name) {
this.name = name;
}
public static ModelType getByName(String name) {
return AdventureIndexUtil.indexValueOrThrow(NAME_INDEX, name);
}
public String getName() {
return this.name;
}
}
}
@@ -0,0 +1,52 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.chicken;
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant.ModelType;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class ChickenVariants {
private static final VersionedRegistry<ChickenVariant> REGISTRY =
new VersionedRegistry<>("chicken_variant");
private ChickenVariants() {
}
@ApiStatus.Internal
public static ChickenVariant define(String name, ModelType modelType, String texture) {
ResourceLocation assetId = new ResourceLocation("entity/chicken/" + texture);
return REGISTRY.define(name, data ->
new StaticChickenVariant(data, modelType, assetId));
}
public static VersionedRegistry<ChickenVariant> getRegistry() {
return REGISTRY;
}
public static final ChickenVariant COLD = define("cold", ModelType.COLD, "cold_chicken");
public static final ChickenVariant TEMPERATE = define("temperate", ModelType.NORMAL, "temperate_chicken");
public static final ChickenVariant WARM = define("warm", ModelType.NORMAL, "warm_chicken");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.chicken;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class StaticChickenVariant extends AbstractMappedEntity implements ChickenVariant {
private final ModelType modelType;
private final ResourceLocation assetId;
public StaticChickenVariant(ModelType modelType, ResourceLocation assetId) {
this(null, modelType, assetId);
}
@ApiStatus.Internal
public StaticChickenVariant(@Nullable TypesBuilderData data, ModelType modelType, ResourceLocation assetId) {
super(data);
this.modelType = modelType;
this.assetId = assetId;
}
@Override
public ChickenVariant copy(@Nullable TypesBuilderData newData) {
return new StaticChickenVariant(newData, this.modelType, this.assetId);
}
@Override
public ModelType getModelType() {
return this.modelType;
}
@Override
public ResourceLocation getAssetId() {
return this.assetId;
}
@Override
public boolean deepEquals(Object obj) {
if (!(obj instanceof StaticChickenVariant)) return false;
if (!super.equals(obj)) return false;
StaticChickenVariant that = (StaticChickenVariant) obj;
if (!this.modelType.equals(that.modelType)) return false;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
}
}
@@ -0,0 +1,88 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cow;
import com.github.retrooper.packetevents.protocol.mapper.CopyableEntity;
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.adventure.AdventureIndexUtil;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import net.kyori.adventure.util.Index;
import org.jetbrains.annotations.Nullable;
public interface CowVariant extends MappedEntity, CopyableEntity<CowVariant>, DeepComparableEntity {
ModelType getModelType();
ResourceLocation getAssetId();
static CowVariant read(PacketWrapper<?> wrapper) {
return wrapper.readMappedEntity(CowVariants.getRegistry());
}
static void write(PacketWrapper<?> wrapper, CowVariant variant) {
wrapper.writeMappedEntity(variant);
}
static CowVariant decode(NBT nbt, ClientVersion version, @Nullable TypesBuilderData data) {
NBTCompound compound = (NBTCompound) nbt;
String modelTypeString = compound.getStringTagValueOrNull("model");
ModelType modelType = modelTypeString != null ? ModelType.getByName(modelTypeString) : ModelType.NORMAL;
ResourceLocation assetId = new ResourceLocation(compound.getStringTagValueOrThrow("asset_id"));
return new StaticCowVariant(data, modelType, assetId);
}
static NBT encode(CowVariant variant, ClientVersion version) {
NBTCompound compound = new NBTCompound();
compound.setTag("model", new NBTString(variant.getModelType().getName()));
compound.setTag("asset_id", new NBTString(variant.getAssetId().toString()));
return compound;
}
enum ModelType {
NORMAL("normal"),
COLD("cold"),
WARM("warm"),
;
private static final Index<String, ModelType> NAME_INDEX = Index.create(
ModelType.class, ModelType::getName);
private final String name;
ModelType(String name) {
this.name = name;
}
public static ModelType getByName(String name) {
return AdventureIndexUtil.indexValueOrThrow(NAME_INDEX, name);
}
public String getName() {
return this.name;
}
}
}
@@ -0,0 +1,52 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cow;
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant.ModelType;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class CowVariants {
private static final VersionedRegistry<CowVariant> REGISTRY =
new VersionedRegistry<>("cow_variant");
private CowVariants() {
}
@ApiStatus.Internal
public static CowVariant define(String name, ModelType modelType, String texture) {
ResourceLocation assetId = new ResourceLocation("entity/cow/" + texture);
return REGISTRY.define(name, data ->
new StaticCowVariant(data, modelType, assetId));
}
public static VersionedRegistry<CowVariant> getRegistry() {
return REGISTRY;
}
public static final CowVariant COLD = define("cold", ModelType.COLD, "cold_cow");
public static final CowVariant TEMPERATE = define("temperate", ModelType.NORMAL, "temperate_cow");
public static final CowVariant WARM = define("warm", ModelType.WARM, "warm_cow");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,73 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.cow;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class StaticCowVariant extends AbstractMappedEntity implements CowVariant {
private final ModelType modelType;
private final ResourceLocation assetId;
public StaticCowVariant(ModelType modelType, ResourceLocation assetId) {
this(null, modelType, assetId);
}
@ApiStatus.Internal
public StaticCowVariant(@Nullable TypesBuilderData data, ModelType modelType, ResourceLocation assetId) {
super(data);
this.modelType = modelType;
this.assetId = assetId;
}
@Override
public CowVariant copy(@Nullable TypesBuilderData newData) {
return new StaticCowVariant(newData, this.modelType, this.assetId);
}
@Override
public ModelType getModelType() {
return this.modelType;
}
@Override
public ResourceLocation getAssetId() {
return this.assetId;
}
@Override
public boolean deepEquals(Object obj) {
if (!(obj instanceof StaticCowVariant)) return false;
if (!super.equals(obj)) return false;
StaticCowVariant that = (StaticCowVariant) obj;
if (!this.modelType.equals(that.modelType)) return false;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.modelType, this.assetId);
}
}
@@ -18,38 +18,39 @@
package com.github.retrooper.packetevents.protocol.entity.data;
public class EntityData {
private int index;
private EntityDataType<?> type;
private Object value;
public class EntityData<T> {
public EntityData(int index, EntityDataType<?> type, Object value) {
private int index;
private EntityDataType<T> type;
private T value;
public EntityData(int index, EntityDataType<T> type, T value) {
this.index = index;
this.type = type;
this.value = value;
}
public int getIndex() {
return index;
return this.index;
}
public void setIndex(int index) {
this.index = index;
}
public EntityDataType<?> getType() {
return type;
public EntityDataType<T> getType() {
return this.type;
}
public void setType(EntityDataType<?> type) {
public void setType(EntityDataType<T> type) {
this.type = type;
}
public Object getValue() {
return value;
public T getValue() {
return this.value;
}
public void setValue(Object value) {
public void setValue(T value) {
this.value = value;
}
}
}
@@ -20,15 +20,23 @@ package com.github.retrooper.packetevents.protocol.entity.data;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.armadillo.ArmadilloState;
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariant;
import com.github.retrooper.packetevents.protocol.entity.chicken.ChickenVariant;
import com.github.retrooper.packetevents.protocol.entity.cow.CowVariant;
import com.github.retrooper.packetevents.protocol.entity.frog.FrogVariant;
import com.github.retrooper.packetevents.protocol.entity.pig.PigVariant;
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
import com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState;
import com.github.retrooper.packetevents.protocol.entity.villager.VillagerData;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfSoundVariant;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfVariant;
import com.github.retrooper.packetevents.protocol.item.ItemStack;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.particle.Particle;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.world.BlockFace;
import com.github.retrooper.packetevents.protocol.world.WorldBlockPosition;
import com.github.retrooper.packetevents.protocol.world.painting.PaintingVariant;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.Quaternion4f;
import com.github.retrooper.packetevents.util.Vector3f;
@@ -72,10 +80,16 @@ public final class EntityDataTypes {
public static final EntityDataType<String> STRING = define("string", PacketWrapper::readString, PacketWrapper::writeString);
/**
* @deprecated use {@link #ADV_COMPONENT} instead
*/
@Deprecated
public static final EntityDataType<String> COMPONENT = define("component", PacketWrapper::readComponentJSON, PacketWrapper::writeComponentJSON);
public static final EntityDataType<Component> ADV_COMPONENT = define("component", PacketWrapper::readComponent, PacketWrapper::writeComponent);
/**
* @deprecated use {@link #OPTIONAL_ADV_COMPONENT} instead
*/
@Deprecated
public static final EntityDataType<Optional<String>> OPTIONAL_COMPONENT = define("optional_component", readOptionalComponentJSONDeserializer(), writeOptionalComponentJSONSerializer());
public static final EntityDataType<Optional<Component>> OPTIONAL_ADV_COMPONENT = define("optional_component", readOptionalComponentDeserializer(), writeOptionalComponentSerializer());
@@ -155,9 +169,23 @@ public final class EntityDataTypes {
return EntityPose.getById(wrapper.getServerVersion().toClientVersion(), id);
}, (PacketWrapper<?> wrapper, EntityPose value) -> wrapper.writeVarInt(value.getId(wrapper.getServerVersion().toClientVersion())));
public static final EntityDataType<Integer> CAT_VARIANT = define("cat_variant_type", readIntDeserializer(), writeIntSerializer());
/**
* @deprecated use {@link #TYPED_CAT_VARIANT} instead
*/
@Deprecated
public static final EntityDataType<Integer> CAT_VARIANT =
define("cat_variant_type", readIntDeserializer(), writeIntSerializer());
public static final EntityDataType<CatVariant> TYPED_CAT_VARIANT =
define("cat_variant_type", CatVariant::read, CatVariant::write);
public static final EntityDataType<Integer> FROG_VARIANT = define("frog_variant_type", readIntDeserializer(), writeIntSerializer());
/**
* @deprecated use {@link #TYPED_FROG_VARIANT} instead
*/
@Deprecated
public static final EntityDataType<Integer> FROG_VARIANT =
define("frog_variant_type", readIntDeserializer(), writeIntSerializer());
public static final EntityDataType<FrogVariant> TYPED_FROG_VARIANT =
define("frog_variant_type", FrogVariant::read, FrogVariant::write);
public static final EntityDataType<Optional<WorldBlockPosition>> OPTIONAL_GLOBAL_POSITION = define("optional_global_position",
(PacketWrapper<?> wrapper) -> Optional.ofNullable(wrapper.readOptional(w -> new WorldBlockPosition(new ResourceLocation(w.readString(32767)), w.readBlockPosition()))),
@@ -166,7 +194,14 @@ public final class EntityDataTypes {
w.writeBlockPosition(globalPos.getBlockPosition());
}));
public static final EntityDataType<Integer> PAINTING_VARIANT_TYPE = define("painting_variant_type", readIntDeserializer(), writeIntSerializer());
/**
* @deprecated use {@link #PAINTING_VARIANT} instead
*/
@Deprecated
public static final EntityDataType<Integer> PAINTING_VARIANT_TYPE =
define("painting_variant_type", readIntDeserializer(), writeIntSerializer());
public static final EntityDataType<PaintingVariant> PAINTING_VARIANT =
define("painting_variant_type", PaintingVariant::read, PaintingVariant::write);
public static final EntityDataType<SnifferState> SNIFFER_STATE = define("sniffer_state", (PacketWrapper<?> wrapper) -> {
int id = wrapper.readVarInt();
@@ -190,19 +225,53 @@ public final class EntityDataTypes {
wrapper.writeFloat(value.getW());
});
// Added in 1.20.5
/**
* Added with 1.20.5
*/
public static final EntityDataType<ArmadilloState> ARMADILLO_STATE = define("armadillo_state",
(PacketWrapper<?> wrapper) -> ArmadilloState.values()[wrapper.readVarInt()],
(PacketWrapper<?> wrapper, ArmadilloState value) -> wrapper.writeVarInt(value.ordinal())
);
/**
* Added with 1.20.5
*/
public static final EntityDataType<List<Particle<?>>> PARTICLES = define("particles",
wrapper -> wrapper.readList(Particle::read),
(wrapper, particles) -> wrapper.writeList(particles, Particle::write)
);
/**
* Added with 1.20.5
*
* @deprecated use {@link #TYPED_WOLF_VARIANT} instead
*/
@Deprecated
public static final EntityDataType<Integer> WOLF_VARIANT =
define("wolf_variant_type", readIntDeserializer(), writeIntSerializer());
/**
* Added with 1.20.5
*/
public static final EntityDataType<WolfVariant> TYPED_WOLF_VARIANT =
define("wolf_variant_type", WolfVariant::read, WolfVariant::write);
/**
* Added with 1.21.5
*/
public static final EntityDataType<CowVariant> COW_VARIANT =
define("cow_variant_type", CowVariant::read, CowVariant::write);
/**
* Added with 1.21.5
*/
public static final EntityDataType<WolfSoundVariant> WOLF_SOUND_VARIANT =
define("wolf_sound_variant_type", WolfSoundVariant::read, WolfSoundVariant::write);
/**
* Added with 1.21.5
*/
public static final EntityDataType<PigVariant> PIG_VARIANT =
define("pig_variant_type", PigVariant::read, PigVariant::write);
/**
* Added with 1.21.5
*/
public static final EntityDataType<ChickenVariant> CHICKEN_VARIANT =
define("chicken_variant_type", ChickenVariant::read, ChickenVariant::write);
private EntityDataTypes() {
}
@@ -19,7 +19,7 @@ public interface EntityMetadataProvider {
* @param version The protocol version of the format we expect the metadata to be in.
* @return Metadata (list of entity data)
*/
List<EntityData> entityData(ClientVersion version);
List<EntityData<?>> entityData(ClientVersion version);
/**
* Similar to {@link #entityData(ClientVersion)} but does not provide a protocol version.
@@ -29,7 +29,7 @@ public interface EntityMetadataProvider {
* @deprecated Does not specify format of metadata, therefore not advised to use this. It will assume the current latest version.
*/
@Deprecated
default List<EntityData> entityData() {
default List<EntityData<?>> entityData() {
return entityData(ClientVersion.getLatest());
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.fox;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface FoxVariant extends MappedEntity {
}
@@ -0,0 +1,47 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.fox;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class FoxVariants {
private static final VersionedRegistry<FoxVariant> REGISTRY =
new VersionedRegistry<>("fox_variant");
private FoxVariants() {
}
@ApiStatus.Internal
public static FoxVariant define(String name) {
return REGISTRY.define(name, StaticFoxVariant::new);
}
public static VersionedRegistry<FoxVariant> getRegistry() {
return REGISTRY;
}
public static final FoxVariant RED = define("red");
public static final FoxVariant SNOW = define("snow");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.fox;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticFoxVariant extends AbstractMappedEntity implements FoxVariant {
@ApiStatus.Internal
public StaticFoxVariant(@Nullable TypesBuilderData data) {
super(data);
}
}
@@ -0,0 +1,56 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.frog;
import com.github.retrooper.packetevents.protocol.mapper.CopyableEntity;
import com.github.retrooper.packetevents.protocol.mapper.DeepComparableEntity;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import org.jetbrains.annotations.Nullable;
public interface FrogVariant extends MappedEntity, CopyableEntity<FrogVariant>, DeepComparableEntity {
ResourceLocation getAssetId();
static FrogVariant read(PacketWrapper<?> wrapper) {
return wrapper.readMappedEntity(FrogVariants.getRegistry());
}
static void write(PacketWrapper<?> wrapper, FrogVariant variant) {
wrapper.writeMappedEntity(variant);
}
static FrogVariant decode(NBT nbt, ClientVersion version, @Nullable TypesBuilderData data) {
NBTCompound compound = (NBTCompound) nbt;
ResourceLocation assetId = new ResourceLocation(compound.getStringTagValueOrThrow("asset_id"));
return new StaticFrogVariant(data, assetId);
}
static NBT encode(FrogVariant variant, ClientVersion version) {
NBTCompound compound = new NBTCompound();
compound.setTag("asset_id", new NBTString(variant.getAssetId().toString()));
return compound;
}
}
@@ -0,0 +1,51 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.frog;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class FrogVariants {
private static final VersionedRegistry<FrogVariant> REGISTRY =
new VersionedRegistry<>("frog_variant");
private FrogVariants() {
}
@ApiStatus.Internal
public static FrogVariant define(String name, String texture) {
ResourceLocation assetId = new ResourceLocation("entity/frog/" + texture);
return REGISTRY.define(name, data ->
new StaticFrogVariant(data, assetId));
}
public static VersionedRegistry<FrogVariant> getRegistry() {
return REGISTRY;
}
public static final FrogVariant COLD = define("cold", "cold_frog");
public static final FrogVariant TEMPERATE = define("temperate", "temperate_frog");
public static final FrogVariant WARM = define("warm", "warm_frog");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,65 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.frog;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class StaticFrogVariant extends AbstractMappedEntity implements FrogVariant {
private final ResourceLocation assetId;
public StaticFrogVariant(ResourceLocation assetId) {
this(null, assetId);
}
@ApiStatus.Internal
public StaticFrogVariant(@Nullable TypesBuilderData data, ResourceLocation assetId) {
super(data);
this.assetId = assetId;
}
@Override
public FrogVariant copy(@Nullable TypesBuilderData newData) {
return new StaticFrogVariant(newData, this.assetId);
}
@Override
public ResourceLocation getAssetId() {
return this.assetId;
}
@Override
public boolean deepEquals(Object obj) {
if (!(obj instanceof StaticFrogVariant)) return false;
if (!super.equals(obj)) return false;
StaticFrogVariant that = (StaticFrogVariant) obj;
return this.assetId.equals(that.assetId);
}
@Override
public int deepHashCode() {
return Objects.hash(super.hashCode(), this.assetId);
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.horse;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface HorseVariant extends MappedEntity {
}
@@ -0,0 +1,52 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.horse;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class HorseVariants {
private static final VersionedRegistry<HorseVariant> REGISTRY =
new VersionedRegistry<>("horse_variant");
private HorseVariants() {
}
@ApiStatus.Internal
public static HorseVariant define(String name) {
return REGISTRY.define(name, StaticHorseVariant::new);
}
public static VersionedRegistry<HorseVariant> getRegistry() {
return REGISTRY;
}
public static final HorseVariant WHITE = define("white");
public static final HorseVariant CREAMY = define("creamy");
public static final HorseVariant CHESTNUT = define("chestnut");
public static final HorseVariant BROWN = define("brown");
public static final HorseVariant BLACK = define("black");
public static final HorseVariant GRAY = define("gray");
public static final HorseVariant DARK_BROWN = define("dark_brown");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.horse;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticHorseVariant extends AbstractMappedEntity implements HorseVariant {
@ApiStatus.Internal
public StaticHorseVariant(@Nullable TypesBuilderData data) {
super(data);
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.llama;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface LlamaVariant extends MappedEntity {
}
@@ -0,0 +1,49 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.llama;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class LlamaVariants {
private static final VersionedRegistry<LlamaVariant> REGISTRY =
new VersionedRegistry<>("llama_variant");
private LlamaVariants() {
}
@ApiStatus.Internal
public static LlamaVariant define(String name) {
return REGISTRY.define(name, StaticLlamaVariant::new);
}
public static VersionedRegistry<LlamaVariant> getRegistry() {
return REGISTRY;
}
public static final LlamaVariant CREAMY = define("creamy");
public static final LlamaVariant WHITE = define("white");
public static final LlamaVariant BROWN = define("brown");
public static final LlamaVariant GRAY = define("gray");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.llama;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticLlamaVariant extends AbstractMappedEntity implements LlamaVariant {
@ApiStatus.Internal
public StaticLlamaVariant(@Nullable TypesBuilderData data) {
super(data);
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.mooshroom;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface MooshroomVariant extends MappedEntity {
}
@@ -0,0 +1,51 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.mooshroom;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class MooshroomVariants {
private static final VersionedRegistry<MooshroomVariant> REGISTRY =
new VersionedRegistry<>("mooshroom_variant");
private MooshroomVariants() {
}
@ApiStatus.Internal
public static MooshroomVariant define(String name) {
return REGISTRY.define(name, StaticMooshroomVariant::new);
}
public static VersionedRegistry<MooshroomVariant> getRegistry() {
return REGISTRY;
}
public static final MooshroomVariant RED = define("red");
/**
* Added with 1.14
*/
public static final MooshroomVariant BROWN = define("brown");
static {
REGISTRY.unloadMappings();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.mooshroom;
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public class StaticMooshroomVariant extends AbstractMappedEntity implements MooshroomVariant {
@ApiStatus.Internal
public StaticMooshroomVariant(@Nullable TypesBuilderData data) {
super(data);
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.parrot;
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
public interface ParrotVariant extends MappedEntity {
}
@@ -0,0 +1,50 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.retrooper.packetevents.protocol.entity.parrot;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
import org.jetbrains.annotations.ApiStatus;
public final class ParrotVariants {
private static final VersionedRegistry<ParrotVariant> REGISTRY =
new VersionedRegistry<>("parrot_variant");
private ParrotVariants() {
}
@ApiStatus.Internal
public static ParrotVariant define(String name) {
return REGISTRY.define(name, StaticParrotVariant::new);
}
public static VersionedRegistry<ParrotVariant> getRegistry() {
return REGISTRY;
}
public static final ParrotVariant RED_BLUE = define("red_blue");
public static final ParrotVariant BLUE = define("blue");
public static final ParrotVariant GREEN = define("green");
public static final ParrotVariant YELLOW_BLUE = define("yellow_blue");
public static final ParrotVariant GRAY = define("gray");
static {
REGISTRY.unloadMappings();
}
}
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff. Show more