Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Use item tags for all animal loved food
Dieser Commit ist enthalten in:
Ursprung
aff7d2cf35
Commit
59a2c0dc02
@ -964,7 +964,7 @@ public final class EntityDefinitions {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityDefinition<TameableEntity> tameableEntityBase = EntityDefinition.inherited(TameableEntity::new, ageableEntityBase)
|
EntityDefinition<TameableEntity> tameableEntityBase = EntityDefinition.<TameableEntity>inherited(null, ageableEntityBase) // No factory, is abstract
|
||||||
.addTranslator(MetadataType.BYTE, TameableEntity::setTameableFlags)
|
.addTranslator(MetadataType.BYTE, TameableEntity::setTameableFlags)
|
||||||
.addTranslator(MetadataType.OPTIONAL_UUID, TameableEntity::setOwner)
|
.addTranslator(MetadataType.OPTIONAL_UUID, TameableEntity::setOwner)
|
||||||
.build();
|
.build();
|
||||||
|
@ -29,8 +29,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
@ -62,6 +62,6 @@ public class TadpoleEntity extends AbstractFishEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFood(GeyserItemStack itemStack) {
|
private boolean isFood(GeyserItemStack itemStack) {
|
||||||
return itemStack.asItem() == Items.SLIME_BALL;
|
return session.getTagCache().is(ItemTag.FROG_FOOD, itemStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,38 +26,39 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.living.AgeableEntity;
|
import org.geysermc.geyser.entity.type.living.AgeableEntity;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AnimalEntity extends AgeableEntity {
|
public abstract class AnimalEntity extends AgeableEntity {
|
||||||
|
|
||||||
public AnimalEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public AnimalEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canEat(GeyserItemStack itemStack) {
|
protected final boolean canEat(GeyserItemStack itemStack) {
|
||||||
return canEat(itemStack.asItem());
|
ItemTag tag = getFoodTag();
|
||||||
|
if (tag == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return session.getTagCache().is(tag, itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if this is a valid item to breed with for this animal.
|
* @return the tag associated with this animal for eating food. Null for nothing or different behavior.
|
||||||
*/
|
*/
|
||||||
public boolean canEat(Item item) {
|
protected abstract @Nullable ItemTag getFoodTag();
|
||||||
// This is what it defaults to. OK.
|
|
||||||
return item == Items.WHEAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,9 +25,11 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ArmadilloState;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ArmadilloState;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||||
|
|
||||||
@ -70,4 +72,10 @@ public class ArmadilloEntity extends AnimalEntity {
|
|||||||
}, 250, TimeUnit.MILLISECONDS);
|
}, 250, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.ARMADILLO_FOOD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.EntityUtils;
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
@ -61,8 +61,9 @@ public class AxolotlEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return session.getTagCache().is(ItemTag.AXOLOTL_FOOD, item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.AXOLOTL_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -68,7 +68,8 @@ public class BeeEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return session.getTagCache().is(ItemTag.FLOWERS, item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.BEE_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,24 +25,23 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ChickenEntity extends AnimalEntity {
|
public class ChickenEntity extends AnimalEntity {
|
||||||
private static final Set<Item> VALID_FOOD = Set.of(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS);
|
|
||||||
|
|
||||||
public ChickenEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public ChickenEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return VALID_FOOD.contains(item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.CHICKEN_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
@ -33,6 +34,7 @@ import org.geysermc.geyser.entity.EntityDefinition;
|
|||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
@ -64,4 +66,10 @@ public class CowEntity extends AnimalEntity {
|
|||||||
session.playSoundEvent(SoundEvent.MILK, position);
|
session.playSoundEvent(SoundEvent.MILK, position);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.COW_FOOD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -56,7 +56,8 @@ public class FoxEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return session.getTagCache().is(ItemTag.FOX_FOOD, item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.FOX_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
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.IntEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
|
||||||
@ -76,7 +76,8 @@ public class FrogEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.SLIME_BALL;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.FROG_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
@ -34,6 +35,7 @@ import org.geysermc.geyser.entity.EntityDefinition;
|
|||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
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.Pose;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
@ -94,4 +96,10 @@ public class GoatEntity extends AnimalEntity {
|
|||||||
private void setHornCount() {
|
private void setHornCount() {
|
||||||
dirtyMetadata.put(EntityDataTypes.GOAT_HORN_COUNT, (hasLeftHorn ? 1 : 0) + (hasRightHorn ? 1 : 0));
|
dirtyMetadata.put(EntityDataTypes.GOAT_HORN_COUNT, (hasLeftHorn ? 1 : 0) + (hasRightHorn ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.GOAT_FOOD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -54,8 +54,9 @@ public class HoglinEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.CRIMSON_FUNGUS;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.HOGLIN_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,7 +40,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MooshroomEntity extends AnimalEntity {
|
public class MooshroomEntity extends CowEntity {
|
||||||
private boolean isBrown = false;
|
private boolean isBrown = false;
|
||||||
|
|
||||||
public MooshroomEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public MooshroomEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||||
|
@ -26,13 +26,13 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
@ -46,8 +46,9 @@ public class OcelotEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.COD || item == Items.SALMON;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.OCELOT_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -34,9 +34,8 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
|||||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -89,8 +88,9 @@ public class PandaEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.BAMBOO;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.PANDA_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -26,13 +26,13 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.EntityUtils;
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -47,8 +47,9 @@ public class PigEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.PIG_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ public class PolarBearEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return false;
|
protected ItemTag getFoodTag() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -67,7 +67,8 @@ public class RabbitEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.DANDELION || item == Items.CARROT || item == Items.GOLDEN_CARROT;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.RABBIT_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
@ -34,6 +35,7 @@ import org.geysermc.geyser.inventory.GeyserItemStack;
|
|||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.item.type.DyeItem;
|
import org.geysermc.geyser.item.type.DyeItem;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -55,6 +57,12 @@ public class SheepEntity extends AnimalEntity {
|
|||||||
dirtyMetadata.put(EntityDataTypes.COLOR, (byte) color);
|
dirtyMetadata.put(EntityDataTypes.COLOR, (byte) color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.SHEEP_FOOD;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
|
protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
|
||||||
@ -34,7 +35,6 @@ import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket;
|
|||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.entity.type.Tickable;
|
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.GeyserSession;
|
||||||
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
||||||
@ -72,8 +72,9 @@ public class SnifferEntity extends AnimalEntity implements Tickable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return session.getTagCache().is(ItemTag.SNIFFER_FOOD, item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.SNIFFER_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSnifferState(ObjectEntityMetadata<SnifferState> entityMetadata) {
|
public void setSnifferState(ObjectEntityMetadata<SnifferState> entityMetadata) {
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.EntityUtils;
|
import org.geysermc.geyser.util.EntityUtils;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
@ -94,8 +94,9 @@ public class StriderEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.WARPED_FUNGUS;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.STRIDER_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal;
|
package org.geysermc.geyser.entity.type.living.animal;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -50,8 +50,9 @@ public class TurtleEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return item == Items.SEAGRASS;
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.TURTLE_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal.horse;
|
package org.geysermc.geyser.entity.type.living.animal.horse;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
@ -38,23 +39,16 @@ import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
|
|||||||
import org.geysermc.geyser.entity.type.living.animal.AnimalEntity;
|
import org.geysermc.geyser.entity.type.living.animal.AnimalEntity;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AbstractHorseEntity extends AnimalEntity {
|
public class AbstractHorseEntity extends AnimalEntity {
|
||||||
/**
|
|
||||||
* A list of all foods a horse/donkey can eat on Java Edition.
|
|
||||||
* Used to display interactive tag if needed.
|
|
||||||
*/
|
|
||||||
private static final Set<Item> DONKEY_AND_HORSE_FOODS = Set.of(Items.GOLDEN_APPLE, Items.ENCHANTED_GOLDEN_APPLE,
|
|
||||||
Items.GOLDEN_CARROT, Items.SUGAR, Items.APPLE, Items.WHEAT, Items.HAY_BLOCK);
|
|
||||||
|
|
||||||
public AbstractHorseEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
public AbstractHorseEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||||
@ -124,8 +118,9 @@ public class AbstractHorseEntity extends AnimalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return DONKEY_AND_HORSE_FOODS.contains(item);
|
protected ItemTag getFoodTag() {
|
||||||
|
return ItemTag.HORSE_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.entity.type.living.animal.horse;
|
package org.geysermc.geyser.entity.type.living.animal.horse;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
|
||||||
@ -32,9 +33,8 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
|
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||||
@ -90,8 +90,8 @@ public class CamelEntity extends AbstractHorseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
protected @Nullable ItemTag getFoodTag() {
|
||||||
return item == Items.CACTUS;
|
return ItemTag.CAMEL_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal.horse;
|
package org.geysermc.geyser.entity.type.living.animal.horse;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.MathUtils;
|
import org.geysermc.geyser.util.MathUtils;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public class LlamaEntity extends ChestedHorseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
protected @Nullable ItemTag getFoodTag() {
|
||||||
return item == Items.WHEAT || item == Items.HAY_BLOCK;
|
return ItemTag.LLAMA_FOOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal.tameable;
|
package org.geysermc.geyser.entity.type.living.animal.tameable;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
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.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||||
@ -109,8 +109,8 @@ public class CatEntity extends TameableEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
protected @Nullable ItemTag getFoodTag() {
|
||||||
return item == Items.COD || item == Items.SALMON;
|
return ItemTag.CAT_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.geyser.entity.type.living.animal.tameable;
|
package org.geysermc.geyser.entity.type.living.animal.tameable;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
import org.geysermc.geyser.entity.EntityDefinition;
|
||||||
@ -33,6 +34,7 @@ import org.geysermc.geyser.inventory.GeyserItemStack;
|
|||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
|
||||||
@ -49,16 +51,17 @@ public class ParrotEntity extends TameableEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
return false;
|
protected ItemTag getFoodTag() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTameFood(Item item) {
|
private boolean isTameFood(Item item) {
|
||||||
return TAMING_FOOD.contains(item);
|
return session.getTagCache().is(ItemTag.PARROT_FOOD, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPoisonousFood(Item item) {
|
private boolean isPoisonousFood(Item item) {
|
||||||
return item == Items.COOKIE;
|
return session.getTagCache().is(ItemTag.PARROT_POISONOUS_FOOD, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -39,7 +39,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEn
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TameableEntity extends AnimalEntity {
|
public abstract class TameableEntity extends AnimalEntity {
|
||||||
/**
|
/**
|
||||||
* Used in the interactive tag manager to track if the session player owns this entity
|
* Used in the interactive tag manager to track if the session player owns this entity
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +38,7 @@ import org.geysermc.geyser.item.Items;
|
|||||||
import org.geysermc.geyser.item.type.DyeItem;
|
import org.geysermc.geyser.item.type.DyeItem;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.cache.tags.ItemTag;
|
||||||
import org.geysermc.geyser.util.InteractionResult;
|
import org.geysermc.geyser.util.InteractionResult;
|
||||||
import org.geysermc.geyser.util.InteractiveTag;
|
import org.geysermc.geyser.util.InteractiveTag;
|
||||||
import org.geysermc.geyser.util.ItemUtils;
|
import org.geysermc.geyser.util.ItemUtils;
|
||||||
@ -120,9 +121,9 @@ public class WolfEntity extends TameableEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canEat(Item item) {
|
@Nullable
|
||||||
// Cannot be a baby to eat these foods
|
protected ItemTag getFoodTag() {
|
||||||
return WOLF_FOODS.contains(item) && !isBaby();
|
return ItemTag.WOLF_FOOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,7 +115,7 @@ public class FireworkRocketItem extends Item {
|
|||||||
newExplosionData.putByteArray("FireworkFade", colors);
|
newExplosionData.putByteArray("FireworkFade", colors);
|
||||||
|
|
||||||
newExplosionData.putBoolean("FireworkTrail", explosion.isHasTrail());
|
newExplosionData.putBoolean("FireworkTrail", explosion.isHasTrail());
|
||||||
newExplosionData.putBoolean("FireworkFlicker", explosion.isHasTwinkle()); // TODO verify
|
newExplosionData.putBoolean("FireworkFlicker", explosion.isHasTwinkle());
|
||||||
|
|
||||||
return newExplosionData.build();
|
return newExplosionData.build();
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,32 @@ public enum ItemTag {
|
|||||||
AXOLOTL_FOOD("axolotl_food"),
|
AXOLOTL_FOOD("axolotl_food"),
|
||||||
CREEPER_IGNITERS("creeper_igniters"),
|
CREEPER_IGNITERS("creeper_igniters"),
|
||||||
FISHES("fishes"),
|
FISHES("fishes"),
|
||||||
FLOWERS("flowers"),
|
|
||||||
FOX_FOOD("fox_food"),
|
FOX_FOOD("fox_food"),
|
||||||
PIGLIN_LOVED("piglin_loved"),
|
PIGLIN_LOVED("piglin_loved"),
|
||||||
SMALL_FLOWERS("small_flowers"),
|
SMALL_FLOWERS("small_flowers"),
|
||||||
SNIFFER_FOOD("sniffer_food");
|
SNIFFER_FOOD("sniffer_food"),
|
||||||
|
PIGLIN_FOOD("piglin_food"),
|
||||||
|
COW_FOOD("cow_food"),
|
||||||
|
GOAT_FOOD("goat_food"),
|
||||||
|
SHEEP_FOOD("sheep_food"),
|
||||||
|
WOLF_FOOD("wolf_food"),
|
||||||
|
CAT_FOOD("cat_food"),
|
||||||
|
HORSE_FOOD("horse_food"),
|
||||||
|
CAMEL_FOOD("camel_food"),
|
||||||
|
ARMADILLO_FOOD("armadillo_food"),
|
||||||
|
BEE_FOOD("bee_food"),
|
||||||
|
CHICKEN_FOOD("chicken_food"),
|
||||||
|
FROG_FOOD("frog_food"),
|
||||||
|
HOGLIN_FOOD("hoglin_food"),
|
||||||
|
LLAMA_FOOD("llama_food"),
|
||||||
|
OCELOT_FOOD("ocelot_food"),
|
||||||
|
PANDA_FOOD("panda_food"),
|
||||||
|
PIG_FOOD("pig_food"),
|
||||||
|
RABBIT_FOOD("rabbit_food"),
|
||||||
|
STRIDER_FOOD("strider_food"),
|
||||||
|
TURTLE_FOOD("turtle_food"),
|
||||||
|
PARROT_FOOD("parrot_food"),
|
||||||
|
PARROT_POISONOUS_FOOD("parrot_poisonous_food");
|
||||||
|
|
||||||
ItemTag(String identifier) {
|
ItemTag(String identifier) {
|
||||||
register(identifier, this);
|
register(identifier, this);
|
||||||
|
@ -249,19 +249,17 @@ public final class ItemTranslator {
|
|||||||
String name = modifier.getName().replace("minecraft:", "");
|
String name = modifier.getName().replace("minecraft:", "");
|
||||||
// the namespace does not need to be present, but if it is, the java client ignores it as of pre-1.20.5
|
// the namespace does not need to be present, but if it is, the java client ignores it as of pre-1.20.5
|
||||||
|
|
||||||
String operationTotal;
|
|
||||||
ModifierOperation operation = modifier.getOperation();
|
ModifierOperation operation = modifier.getOperation();
|
||||||
if (operation == ModifierOperation.ADD) {
|
String operationTotal = switch (operation) {
|
||||||
|
case ADD -> {
|
||||||
if (name.equals("generic.knockback_resistance")) {
|
if (name.equals("generic.knockback_resistance")) {
|
||||||
amount *= 10;
|
amount *= 10;
|
||||||
}
|
}
|
||||||
operationTotal = ATTRIBUTE_FORMAT.format(amount);
|
yield ATTRIBUTE_FORMAT.format(amount);
|
||||||
} else if (operation == ModifierOperation.ADD_MULTIPLIED_BASE || operation == ModifierOperation.ADD_MULTIPLIED_TOTAL) {
|
|
||||||
operationTotal = ATTRIBUTE_FORMAT.format(amount * 100) + "%";
|
|
||||||
} else {
|
|
||||||
GeyserImpl.getInstance().getLogger().warning("Unhandled ModifierOperation while adding item attributes: " + operation);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
case ADD_MULTIPLIED_BASE, ADD_MULTIPLIED_TOTAL ->
|
||||||
|
ATTRIBUTE_FORMAT.format(amount * 100) + "%";
|
||||||
|
};
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
operationTotal = "+" + operationTotal;
|
operationTotal = "+" + operationTotal;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren