Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tag loading and load non-vanilla tags as well #4849

Merged
merged 24 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bad2d03
Work on new tag system, still largely unfinished
eclipseisoffline Jul 10, 2024
5ec330d
Continue work on new tag system, closer to testing now
eclipseisoffline Jul 10, 2024
fbe7020
Add holderset class for geyser
eclipseisoffline Jul 10, 2024
cd1ceaa
My IDE did some stuff it shouldn't have done
eclipseisoffline Jul 10, 2024
dbd062d
Add is method for HolderSets to TagCache
eclipseisoffline Jul 10, 2024
9a40e5d
Add some documentation
eclipseisoffline Jul 10, 2024
8c8c46b
Fix build and slightly adjust documentation
eclipseisoffline Jul 10, 2024
7c9842e
Fix some issues, still broken
eclipseisoffline Jul 10, 2024
444dad7
Fix more issues with registering vanilla tags, works better now
eclipseisoffline Jul 11, 2024
e5bcab1
Fix all issues with vanilla and non-vanilla tags, fix documentation a…
eclipseisoffline Jul 12, 2024
7fa4f27
Small cleanup
eclipseisoffline Jul 12, 2024
1c58193
Use IllegalArgumentException instead of asserting and make TagRegistr…
eclipseisoffline Jul 19, 2024
debec7b
Merge remote-tracking branch 'refs/remotes/upstream/master' into impr…
eclipseisoffline Jul 25, 2024
5d11140
Merge branch 'master' into improvedtags
onebeastchris Aug 14, 2024
5810ea6
Generics - still untested
eclipseisoffline Oct 11, 2024
d32006e
Remove different lookups for vanilla- and non-vanilla tags
eclipseisoffline Oct 21, 2024
062f237
Add toNetworkId and fromNetworkId methods to JavaRegistryKey, simplif…
eclipseisoffline Oct 21, 2024
2efb8d2
More cleanup, add documentation
eclipseisoffline Oct 21, 2024
697f14a
Fix registry loading
eclipseisoffline Oct 21, 2024
b5be37c
Merge remote-tracking branch 'upstream/master' into improvedtags-gene…
eclipseisoffline Oct 21, 2024
3e6bae4
Rename HolderSet to GeyserHolderSet and address reviews by camotoy
eclipseisoffline Oct 22, 2024
585720e
Make holder set reader method not throw an exception, clean up
eclipseisoffline Oct 22, 2024
af9ad52
Make holder set reader warn when failing to read
eclipseisoffline Oct 22, 2024
4909cdc
Add comment to make clearer why a cast is make
eclipseisoffline Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.type.living.AgeableEntity;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
Expand All @@ -48,7 +49,7 @@ public AnimalEntity(GeyserSession session, int entityId, long geyserId, UUID uui
}

protected final boolean canEat(GeyserItemStack itemStack) {
ItemTag tag = getFoodTag();
Tag<Item> tag = getFoodTag();
if (tag == null) {
return false;
}
Expand All @@ -58,7 +59,7 @@ protected final boolean canEat(GeyserItemStack itemStack) {
/**
* @return the tag associated with this animal for eating food. Null for nothing or different behavior.
*/
protected abstract @Nullable ItemTag getFoodTag();
protected abstract @Nullable Tag<Item> getFoodTag();

@NonNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ArmadilloState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;

Expand Down Expand Up @@ -75,7 +77,7 @@ public void onPeeking() {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.ARMADILLO_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
Expand Down Expand Up @@ -62,7 +64,7 @@ public void setPlayingDead(BooleanEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.AXOLOTL_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;

Expand Down Expand Up @@ -69,7 +71,7 @@ public void setAngerTime(IntEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.BEE_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;

import java.util.UUID;

Expand All @@ -41,7 +43,7 @@ public ChickenEntity(GeyserSession session, int entityId, long geyserId, UUID uu

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.CHICKEN_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
Expand Down Expand Up @@ -69,7 +71,7 @@ protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemS

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.COW_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;

Expand All @@ -57,7 +59,7 @@ public void setFoxFlags(ByteEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.FOX_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
Expand Down Expand Up @@ -77,7 +79,7 @@ public void setTongueTarget(ObjectEntityMetadata<OptionalInt> entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.FROG_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
Expand Down Expand Up @@ -99,7 +101,7 @@ private void setHornCount() {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.GOAT_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;

import java.util.UUID;
Expand All @@ -58,7 +60,7 @@ protected boolean isShaking() {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.HOGLIN_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
Expand All @@ -47,7 +49,7 @@ public OcelotEntity(GeyserSession session, int entityId, long geyserId, UUID uui

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.OCELOT_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
Expand Down Expand Up @@ -90,7 +92,7 @@ public void setPandaFlags(ByteEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.PANDA_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
import org.geysermc.geyser.entity.vehicle.ClientVehicle;
import org.geysermc.geyser.entity.vehicle.VehicleComponent;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
Expand All @@ -58,7 +60,7 @@ public PigEntity(GeyserSession session, int entityId, long geyserId, UUID uuid,

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.PIG_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;

import java.util.UUID;

Expand All @@ -41,7 +42,7 @@ public PolarBearEntity(GeyserSession session, int entityId, long geyserId, UUID

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;

Expand Down Expand Up @@ -79,7 +81,7 @@ protected float getBabySize() {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.RABBIT_FOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.DyeItem;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
Expand All @@ -59,7 +61,7 @@ public void setSheepFlags(ByteEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.SHEEP_FOOD;
}

Expand Down Expand Up @@ -103,4 +105,4 @@ protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemS
private boolean canDye(GeyserItemStack item) {
return item.asItem() instanceof DyeItem dyeItem && dyeItem.dyeColor() != this.color && !getFlag(EntityFlag.SHEARED);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.EntityDefinitions;
import org.geysermc.geyser.entity.type.Tickable;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.SnifferState;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
Expand Down Expand Up @@ -73,7 +75,7 @@ protected void setDimensions(Pose pose) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.SNIFFER_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
import org.geysermc.geyser.entity.vehicle.ClientVehicle;
import org.geysermc.geyser.entity.vehicle.VehicleComponent;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag;
Expand Down Expand Up @@ -105,7 +107,7 @@ protected boolean isShaking() {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.STRIDER_FOOD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.tags.ItemTag;
import org.geysermc.geyser.session.cache.tags.Tag;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;

import java.util.UUID;
Expand All @@ -51,7 +53,7 @@ public void setLayingEgg(BooleanEntityMetadata entityMetadata) {

@Override
@Nullable
protected ItemTag getFoodTag() {
protected Tag<Item> getFoodTag() {
return ItemTag.TURTLE_FOOD;
}

Expand Down
Loading