diff --git a/core/src/main/java/org/geysermc/geyser/entity/ChestBoatEntity.java b/core/src/main/java/org/geysermc/geyser/entity/ChestBoatEntity.java new file mode 100644 index 000000000..76e98d953 --- /dev/null +++ b/core/src/main/java/org/geysermc/geyser/entity/ChestBoatEntity.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.geyser.entity; + +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.geyser.entity.type.BoatEntity; +import org.geysermc.geyser.session.GeyserSession; +import org.geysermc.geyser.util.InteractionResult; +import org.geysermc.geyser.util.InteractiveTag; + +import java.util.UUID; + +public class ChestBoatEntity extends BoatEntity { + public ChestBoatEntity(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); + } + + @Override + protected InteractiveTag testInteraction(Hand hand) { + return passengers.isEmpty() && !session.isSneaking() ? super.testInteraction(hand) : InteractiveTag.OPEN_CONTAINER; + } + + @Override + public InteractionResult interact(Hand hand) { + return passengers.isEmpty() && !session.isSneaking() ? super.interact(hand) : InteractionResult.SUCCESS; + } +} diff --git a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java index 59fde11e1..5d1a00968 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java +++ b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinitions.java @@ -51,6 +51,7 @@ import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.translator.text.MessageTranslator; public final class EntityDefinitions { + public static final EntityDefinition ALLAY; public static final EntityDefinition AREA_EFFECT_CLOUD; public static final EntityDefinition ARMOR_STAND; public static final EntityDefinition ARROW; @@ -63,7 +64,7 @@ public final class EntityDefinitions { public static final EntityDefinition CAVE_SPIDER; public static final EntityDefinition CHEST_MINECART; public static final EntityDefinition CHICKEN; - public static final EntityDefinition CHEST_BOAT; + public static final EntityDefinition CHEST_BOAT; public static final EntityDefinition COD; public static final EntityDefinition COMMAND_BLOCK_MINECART; public static final EntityDefinition COW; @@ -211,7 +212,7 @@ public final class EntityDefinitions { .addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight) .addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything .build(); - CHEST_BOAT = EntityDefinition.inherited(BOAT.factory(), BOAT) + CHEST_BOAT = EntityDefinition.inherited(ChestBoatEntity::new, BOAT) .type(EntityType.CHEST_BOAT) .build(); DRAGON_FIREBALL = EntityDefinition.inherited(FireballEntity::new, entityBase) @@ -447,6 +448,10 @@ public final class EntityDefinitions { // Extends mob { + ALLAY = EntityDefinition.inherited(AllayEntity::new, mobEntityBase) + .type(EntityType.ALLAY) + .height(0.6f).width(0.35f) + .build(); BAT = EntityDefinition.inherited(BatEntity::new, mobEntityBase) .type(EntityType.BAT) .height(0.9f).width(0.5f) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/AbstractFishEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/AbstractFishEntity.java index e6cd13f61..842c94e95 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/AbstractFishEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/AbstractFishEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -49,11 +50,11 @@ public class AbstractFishEntity extends WaterEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (EntityUtils.attemptToBucket(session, itemInHand)) { return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java new file mode 100644 index 000000000..ab444c4ab --- /dev/null +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/AllayEntity.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.geyser.entity.type.living; + +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; +import com.nukkitx.math.vector.Vector3f; +import org.geysermc.geyser.entity.EntityDefinition; +import org.geysermc.geyser.inventory.GeyserItemStack; +import org.geysermc.geyser.session.GeyserSession; +import org.geysermc.geyser.util.InteractionResult; +import org.geysermc.geyser.util.InteractiveTag; + +import javax.annotation.Nonnull; +import java.util.UUID; + +public class AllayEntity extends MobEntity { + public AllayEntity(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); + } + + @Nonnull + @Override + protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { + if (!this.hand.isValid() && !itemInHand.isEmpty()) { + return InteractiveTag.GIVE_ITEM_TO_ALLAY; + } else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) { + // Seems like there isn't a good tag for this yet + return InteractiveTag.GIVE_ITEM_TO_ALLAY; + } else { + return super.testMobInteraction(hand, itemInHand); + } + } + + @Nonnull + @Override + protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { + if (!this.hand.isValid() && !itemInHand.isEmpty()) { + //TODO play sound? + return InteractionResult.SUCCESS; + } else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) { + //TOCHECK also play sound here? + return InteractionResult.SUCCESS; + } else { + return super.mobInteract(hand, itemInHand); + } + } +} diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/DolphinEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/DolphinEntity.java index 7085547f8..5d49f3e85 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/DolphinEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/DolphinEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.inventory.GeyserItemStack; @@ -47,20 +48,20 @@ public class DolphinEntity extends WaterEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) { return InteractiveTag.FEED; } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) { // Feed return InteractionResult.SUCCESS; } - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/IronGolemEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/IronGolemEntity.java index 4ab36b00e..e5cbb2f89 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/IronGolemEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/IronGolemEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -48,7 +49,7 @@ public class IronGolemEntity extends GolemEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().ironIngot()) { if (health < maxHealth) { // Healing the iron golem @@ -57,6 +58,6 @@ public class IronGolemEntity extends GolemEntity { return InteractionResult.PASS; } } - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java index 8734f8bd1..723a9c431 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/MobEntity.java @@ -90,7 +90,7 @@ public class MobEntity extends LivingEntity { } } - InteractiveTag tag = testMobInteraction(itemStack); + InteractiveTag tag = testMobInteraction(hand, itemStack); return tag != InteractiveTag.NONE ? tag : super.testInteraction(hand); } } @@ -109,7 +109,7 @@ public class MobEntity extends LivingEntity { if (result.consumesAction()) { return result; } else { - InteractionResult mobResult = mobInteract(itemInHand); + InteractionResult mobResult = mobInteract(hand, itemInHand); return mobResult.consumesAction() ? mobResult : super.interact(hand); } } @@ -137,12 +137,12 @@ public class MobEntity extends LivingEntity { } @Nonnull - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { return InteractiveTag.NONE; } @Nonnull - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { return InteractionResult.PASS; } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/SnowGolemEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/SnowGolemEntity.java index 794f71c04..b075de882 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/SnowGolemEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/SnowGolemEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -51,7 +52,7 @@ public class SnowGolemEntity extends GolemEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) { // Shearing the snow golem return InteractiveTag.SHEAR; @@ -61,7 +62,7 @@ public class SnowGolemEntity extends GolemEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (session.getItemMappings().getStoredItems().shears() == itemInHand.getJavaId() && isAlive() && !getFlag(EntityFlag.SHEARED)) { // Shearing the snow golem return InteractionResult.SUCCESS; diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AnimalEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AnimalEntity.java index 64f41c5ad..0da53b7c6 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AnimalEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AnimalEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityEventType; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -63,16 +64,16 @@ public class AnimalEntity extends AgeableEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (canEat(itemInHand)) { return InteractiveTag.FEED; } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (canEat(itemInHand)) { // FEED if (getFlag(EntityFlag.BABY)) { @@ -82,6 +83,6 @@ public class AnimalEntity extends AgeableEntity { return InteractionResult.CONSUME; } } - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AxolotlEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AxolotlEntity.java index aafa2b782..446892016 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AxolotlEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AxolotlEntity.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -75,11 +76,11 @@ public class AxolotlEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (EntityUtils.attemptToBucket(session, itemInHand)) { return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/CowEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/CowEntity.java index b5ae48b23..3fd55d073 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/CowEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/CowEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.SoundEvent; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -44,9 +45,9 @@ public class CowEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } return InteractiveTag.MILK; @@ -54,9 +55,9 @@ public class CowEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (getFlag(EntityFlag.BABY) || !itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } session.playSoundEvent(SoundEvent.MILK, position); diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/FrogEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/FrogEntity.java index 95dd54b7a..0a9c5964b 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/FrogEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/FrogEntity.java @@ -33,6 +33,7 @@ import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.type.Entity; +import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.session.GeyserSession; import java.util.OptionalInt; @@ -65,4 +66,9 @@ public class FrogEntity extends AnimalEntity { dirtyMetadata.put(EntityData.TARGET_EID, 0L); } } + + @Override + public boolean canEat(String javaIdentifierStripped, ItemMapping mapping) { + return javaIdentifierStripped.equals("slime_ball"); + } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/GoatEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/GoatEntity.java index 817b466fa..a6f2e268e 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/GoatEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/GoatEntity.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.SoundEvent; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -65,12 +66,12 @@ public class GoatEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!getFlag(EntityFlag.BABY) && itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bucket")) { session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position); return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/MooshroomEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/MooshroomEntity.java index c249663ac..d2b8420fd 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/MooshroomEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/MooshroomEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import org.geysermc.geyser.entity.EntityDefinition; @@ -52,7 +53,7 @@ public class MooshroomEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { StoredItemMappings storedItems = session.getItemMappings().getStoredItems(); if (!isBaby()) { if (itemInHand.getJavaId() == storedItems.bowl()) { @@ -63,12 +64,12 @@ public class MooshroomEntity extends AnimalEntity { return InteractiveTag.MOOSHROOM_SHEAR; } } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { StoredItemMappings storedItems = session.getItemMappings().getStoredItems(); boolean isBaby = isBaby(); if (!isBaby && itemInHand.getJavaId() == storedItems.bowl()) { @@ -81,6 +82,6 @@ public class MooshroomEntity extends AnimalEntity { // ? return InteractionResult.SUCCESS; } - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/OcelotEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/OcelotEntity.java index 4ed2bdce1..af1fe0bad 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/OcelotEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/OcelotEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -50,23 +51,23 @@ public class OcelotEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) { // Attempt to feed return InteractiveTag.FEED; } else { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) { // Attempt to feed return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PandaEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PandaEntity.java index d607f113b..51f595526 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PandaEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PandaEntity.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityEventType; @@ -93,16 +94,16 @@ public class PandaEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (mainGene == Gene.WORRIED && session.isThunder()) { return InteractiveTag.NONE; } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (mainGene == Gene.WORRIED && session.isThunder()) { // Huh! return InteractionResult.PASS; diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PigEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PigEntity.java index 05f628f44..db8a1ccd8 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PigEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/PigEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -51,12 +52,12 @@ public class PigEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { // Mount return InteractiveTag.MOUNT; } else { - InteractiveTag superTag = super.testMobInteraction(itemInHand); + InteractiveTag superTag = super.testMobInteraction(hand, itemInHand); if (superTag != InteractiveTag.NONE) { return superTag; } else { @@ -68,12 +69,12 @@ public class PigEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { // Mount return InteractionResult.SUCCESS; } else { - InteractionResult superResult = super.mobInteract(itemInHand); + InteractionResult superResult = super.mobInteract(hand, itemInHand); if (superResult.consumesAction()) { return superResult; } else { diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/SheepEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/SheepEntity.java index 9481944a7..0febfdb11 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/SheepEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/SheepEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -55,11 +56,11 @@ public class SheepEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().shears()) { return InteractiveTag.SHEAR; } else { - InteractiveTag tag = super.testMobInteraction(itemInHand); + InteractiveTag tag = super.testMobInteraction(hand, itemInHand); if (tag != InteractiveTag.NONE) { return tag; } else { @@ -74,11 +75,11 @@ public class SheepEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().shears()) { return InteractionResult.CONSUME; } else { - InteractionResult superResult = super.mobInteract(itemInHand); + InteractionResult superResult = super.mobInteract(hand, itemInHand); if (superResult.consumesAction()) { return superResult; } else { diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/StriderEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/StriderEntity.java index 5f42b4b67..f8d549299 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/StriderEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/StriderEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living.animal; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.type.Entity; @@ -98,12 +99,12 @@ public class StriderEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { // Mount Strider return InteractiveTag.RIDE_STRIDER; } else { - InteractiveTag tag = super.testMobInteraction(itemInHand); + InteractiveTag tag = super.testMobInteraction(hand, itemInHand); if (tag != InteractiveTag.NONE) { return tag; } else { @@ -115,12 +116,12 @@ public class StriderEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { // Mount Strider return InteractionResult.SUCCESS; } else { - InteractionResult superResult = super.mobInteract(itemInHand); + InteractionResult superResult = super.mobInteract(hand, itemInHand); if (superResult.consumesAction()) { return superResult; } else { diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/AbstractHorseEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/AbstractHorseEntity.java index 9139495b8..867d9f799 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/AbstractHorseEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/AbstractHorseEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living.animal.horse; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.google.common.collect.ImmutableSet; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; @@ -129,12 +130,12 @@ public class AbstractHorseEntity extends AnimalEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { - return testHorseInteraction(itemInHand); + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return testHorseInteraction(hand, itemInHand); } @Nonnull - protected final InteractiveTag testHorseInteraction(@Nonnull GeyserItemStack itemInHand) { + protected final InteractiveTag testHorseInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { boolean isBaby = isBaby(); if (!isBaby) { if (getFlag(EntityFlag.TAMED) && session.isSneaking()) { @@ -142,7 +143,7 @@ public class AbstractHorseEntity extends AnimalEntity { } if (!passengers.isEmpty()) { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } } @@ -171,7 +172,7 @@ public class AbstractHorseEntity extends AnimalEntity { } if (isBaby) { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } else { return InteractiveTag.MOUNT; } @@ -179,12 +180,12 @@ public class AbstractHorseEntity extends AnimalEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { - return mobHorseInteract(itemInHand); + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return mobHorseInteract(hand, itemInHand); } @Nonnull - protected final InteractionResult mobHorseInteract(@Nonnull GeyserItemStack itemInHand) { + protected final InteractionResult mobHorseInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { boolean isBaby = isBaby(); if (!isBaby) { if (getFlag(EntityFlag.TAMED) && session.isSneaking()) { @@ -193,7 +194,7 @@ public class AbstractHorseEntity extends AnimalEntity { } if (!passengers.isEmpty()) { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } @@ -227,7 +228,7 @@ public class AbstractHorseEntity extends AnimalEntity { } if (isBaby) { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } else { // Attempt to mount // TODO client-set flags sitting standing? @@ -249,15 +250,15 @@ public class AbstractHorseEntity extends AnimalEntity { /* Just a place to stuff common code for the undead variants without having duplicate code */ - protected final InteractiveTag testUndeadHorseInteraction(@Nonnull GeyserItemStack itemInHand) { + protected final InteractiveTag testUndeadHorseInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!getFlag(EntityFlag.TAMED)) { return InteractiveTag.NONE; } else if (isBaby()) { - return testHorseInteraction(itemInHand); + return testHorseInteraction(hand, itemInHand); } else if (session.isSneaking()) { return InteractiveTag.OPEN_CONTAINER; } else if (!passengers.isEmpty()) { - return testHorseInteraction(itemInHand); + return testHorseInteraction(hand, itemInHand); } else { if (session.getItemMappings().getStoredItems().saddle() == itemInHand.getJavaId()) { return InteractiveTag.OPEN_CONTAINER; @@ -271,16 +272,16 @@ public class AbstractHorseEntity extends AnimalEntity { } } - protected final InteractionResult undeadHorseInteract(@Nonnull GeyserItemStack itemInHand) { + protected final InteractionResult undeadHorseInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { if (!getFlag(EntityFlag.TAMED)) { return InteractionResult.PASS; } else if (isBaby()) { - return mobHorseInteract(itemInHand); + return mobHorseInteract(hand, itemInHand); } else if (session.isSneaking()) { // Opens inventory return InteractionResult.SUCCESS; } else if (!passengers.isEmpty()) { - return mobHorseInteract(itemInHand); + return mobHorseInteract(hand, itemInHand); } else { // The client tests for saddle but it doesn't matter for us at this point. return InteractionResult.SUCCESS; diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/SkeletonHorseEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/SkeletonHorseEntity.java index c9f95f507..4d07c7d13 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/SkeletonHorseEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/SkeletonHorseEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal.horse; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.inventory.GeyserItemStack; @@ -42,13 +43,13 @@ public class SkeletonHorseEntity extends AbstractHorseEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { - return testUndeadHorseInteraction(itemInHand); + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return testUndeadHorseInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { - return undeadHorseInteract(itemInHand); + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return undeadHorseInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/ZombieHorseEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/ZombieHorseEntity.java index ddde11c5d..659a8bad8 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/ZombieHorseEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/horse/ZombieHorseEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal.horse; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.inventory.GeyserItemStack; @@ -42,13 +43,13 @@ public class ZombieHorseEntity extends AbstractHorseEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { - return testUndeadHorseInteraction(itemInHand); + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return testUndeadHorseInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { - return undeadHorseInteract(itemInHand); + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { + return undeadHorseInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/CatEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/CatEntity.java index c17503606..022535592 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/CatEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/CatEntity.java @@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal.tameable; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -105,7 +106,7 @@ public class CatEntity extends TameableEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { boolean tamed = getFlag(EntityFlag.TAMED); if (tamed && ownerBedrockId == session.getPlayerEntity().getGeyserId()) { // Toggle sitting @@ -117,7 +118,7 @@ public class CatEntity extends TameableEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { boolean tamed = getFlag(EntityFlag.TAMED); if (tamed && ownerBedrockId == session.getPlayerEntity().getGeyserId()) { return InteractionResult.SUCCESS; diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/ParrotEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/ParrotEntity.java index b7aca99e5..2b49168dd 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/ParrotEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/ParrotEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.animal.tameable; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -58,7 +59,7 @@ public class ParrotEntity extends TameableEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { String javaIdentifierStripped = itemInHand.getMapping(session).getJavaIdentifier().replace("minecraft:", ""); boolean tame = getFlag(EntityFlag.TAMED); if (!tame && isTameFood(javaIdentifierStripped)) { @@ -69,12 +70,12 @@ public class ParrotEntity extends TameableEntity { // Sitting/standing return getFlag(EntityFlag.SITTING) ? InteractiveTag.STAND : InteractiveTag.SIT; } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { String javaIdentifierStripped = itemInHand.getMapping(session).getJavaIdentifier().replace("minecraft:", ""); boolean tame = getFlag(EntityFlag.TAMED); if (!tame && isTameFood(javaIdentifierStripped)) { @@ -85,6 +86,6 @@ public class ParrotEntity extends TameableEntity { // Sitting/standing return InteractionResult.SUCCESS; } - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java index 8b900f071..bc5209bcb 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal.tameable; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.google.common.collect.ImmutableSet; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; @@ -103,7 +104,7 @@ public class WolfEntity extends TameableEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (getFlag(EntityFlag.ANGRY)) { return InteractiveTag.NONE; } @@ -122,12 +123,12 @@ public class WolfEntity extends TameableEntity { return getFlag(EntityFlag.SITTING) ? InteractiveTag.STAND : InteractiveTag.SIT; } } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (ownerBedrockId == session.getPlayerEntity().getGeyserId() || getFlag(EntityFlag.TAMED) || itemInHand.getMapping(session).getJavaIdentifier().equals("minecraft:bone") && !getFlag(EntityFlag.ANGRY)) { // Sitting toggle or feeding; not angry diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/merchant/AbstractMerchantEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/merchant/AbstractMerchantEntity.java index 633ba707f..e6538ebad 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/merchant/AbstractMerchantEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/merchant/AbstractMerchantEntity.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.entity.type.living.merchant; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import org.geysermc.geyser.entity.EntityDefinition; @@ -51,7 +52,7 @@ public class AbstractMerchantEntity extends AgeableEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { String javaIdentifier = itemInHand.getMapping(session).getJavaIdentifier(); if (!javaIdentifier.equals("minecraft:villager_spawn_egg") && (definition != EntityDefinitions.VILLAGER || !getFlag(EntityFlag.SLEEPING) && ((VillagerEntity) this).isCanTradeWith())) { @@ -60,12 +61,12 @@ public class AbstractMerchantEntity extends AgeableEntity { return InteractiveTag.TRADE; } } - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { String javaIdentifier = itemInHand.getMapping(session).getJavaIdentifier(); if (!javaIdentifier.equals("minecraft:villager_spawn_egg") && (definition != EntityDefinitions.VILLAGER || !getFlag(EntityFlag.SLEEPING)) @@ -73,7 +74,7 @@ public class AbstractMerchantEntity extends AgeableEntity { // Trading time return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreeperEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreeperEntity.java index cf9393410..f73ab257a 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreeperEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreeperEntity.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.SoundEvent; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -63,23 +64,23 @@ public class CreeperEntity extends MonsterEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().flintAndSteel()) { return InteractiveTag.IGNITE_CREEPER; } else { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().flintAndSteel()) { // Ignite creeper session.playSoundEvent(SoundEvent.IGNITE, position); return InteractionResult.SUCCESS; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/PiglinEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/PiglinEntity.java index f0577ee20..4eb0baa6c 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/PiglinEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/PiglinEntity.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.entity.type.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -71,8 +72,8 @@ public class PiglinEntity extends BasePiglinEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { - InteractiveTag tag = super.testMobInteraction(itemInHand); + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { + InteractiveTag tag = super.testMobInteraction(hand, itemInHand); if (tag != InteractiveTag.NONE) { return tag; } else { @@ -82,8 +83,8 @@ public class PiglinEntity extends BasePiglinEntity { @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { - InteractionResult superResult = super.mobInteract(itemInHand); + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { + InteractionResult superResult = super.mobInteract(hand, itemInHand); if (superResult.consumesAction()) { return superResult; } else { diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/ZombieVillagerEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/ZombieVillagerEntity.java index 1ec0fc26b..bf5180e36 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/ZombieVillagerEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/ZombieVillagerEntity.java @@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.monster; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; @@ -67,22 +68,22 @@ public class ZombieVillagerEntity extends ZombieEntity { @Nonnull @Override - protected InteractiveTag testMobInteraction(@Nonnull GeyserItemStack itemInHand) { + protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().goldenApple()) { return InteractiveTag.CURE; } else { - return super.testMobInteraction(itemInHand); + return super.testMobInteraction(hand, itemInHand); } } @Nonnull @Override - protected InteractionResult mobInteract(@Nonnull GeyserItemStack itemInHand) { + protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { if (itemInHand.getJavaId() == session.getItemMappings().getStoredItems().goldenApple()) { // The client doesn't know if the entity has weakness as that's not usually sent over the network return InteractionResult.CONSUME; } else { - return super.mobInteract(itemInHand); + return super.mobInteract(hand, itemInHand); } } } diff --git a/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java b/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java index 1e8795478..9607ac61e 100644 --- a/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java +++ b/core/src/main/java/org/geysermc/geyser/util/InteractiveTag.java @@ -69,7 +69,8 @@ public enum InteractiveTag { EQUIP_ARMOR_STAND("armorstand.equip"), READ, WAKE_VILLAGER("wakevillager"), - BARTER; + BARTER, + GIVE_ITEM_TO_ALLAY("allay"); /** * The full string that should be passed on to the client.