diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/AnimalEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/AnimalEntity.java
index fc5bc722c..075690662 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/AnimalEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/AnimalEntity.java
@@ -34,4 +34,14 @@ public class AnimalEntity extends AgeableEntity {
public AnimalEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
}
+
+ /**
+ * @param javaIdentifierStripped the stripped Java identifier of the item that is potential breeding food. For example,
+ * wheat
.
+ * @return true if this is a valid item to breed with for this animal.
+ */
+ public boolean canEat(String javaIdentifierStripped) {
+ // This is what it defaults to. OK.
+ return javaIdentifierStripped.equals("wheat");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/BeeEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/BeeEntity.java
index bdffbbcd5..d076b8a6f 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/BeeEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/BeeEntity.java
@@ -26,6 +26,7 @@
package org.geysermc.connector.entity.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.google.common.collect.ImmutableSet;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
@@ -34,7 +35,15 @@ import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
+import java.util.Set;
+
public class BeeEntity extends AnimalEntity {
+ /**
+ * A list of all flowers. Used for feeding bees.
+ */
+ private static final Set FLOWERS = ImmutableSet.of("dandelion", "poppy", "blue_orchid", "allium", "azure_bluet",
+ "red_tulip", "pink_tulip", "white_tulip", "orange_tulip", "cornflower", "lily_of_the_valley", "wither_rose",
+ "sunflower", "lilac", "rose_bush", "peony");
public BeeEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
@@ -63,4 +72,9 @@ public class BeeEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return FLOWERS.contains(javaIdentifierStripped);
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/ChickenEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/ChickenEntity.java
new file mode 100644
index 000000000..66e8f9ac8
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/ChickenEntity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019-2021 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.connector.entity.living.animal;
+
+import com.nukkitx.math.vector.Vector3f;
+import org.geysermc.connector.entity.type.EntityType;
+
+public class ChickenEntity extends AnimalEntity {
+
+ public ChickenEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
+ super(entityId, geyserId, entityType, position, motion, rotation);
+ }
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.contains("seeds");
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/FoxEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/FoxEntity.java
index 90514cf12..bfa376272 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/FoxEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/FoxEntity.java
@@ -52,4 +52,9 @@ public class FoxEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("sweet_berries");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/HoglinEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/HoglinEntity.java
index 1878648b4..b915c07de 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/HoglinEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/HoglinEntity.java
@@ -47,4 +47,9 @@ public class HoglinEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("crimson_fungus");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/OcelotEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/OcelotEntity.java
index 87320838a..7c7d74770 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/OcelotEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/OcelotEntity.java
@@ -44,4 +44,9 @@ public class OcelotEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PandaEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PandaEntity.java
index eec07af50..9431d66a0 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PandaEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PandaEntity.java
@@ -79,6 +79,11 @@ public class PandaEntity extends AnimalEntity {
super.updateBedrockMetadata(entityMetadata, session);
}
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("bamboo");
+ }
+
/**
* Update the panda's appearance, and take into consideration the recessive brown and weak traits that only show up
* when both main and hidden genes match
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PigEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PigEntity.java
index e747405b2..551e1c345 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PigEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PigEntity.java
@@ -46,6 +46,11 @@ public class PigEntity extends AnimalEntity {
super.updateBedrockMetadata(entityMetadata, session);
}
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("potato") || javaIdentifierStripped.equals("beetroot");
+ }
+
@Override
protected float getDefaultMaxHealth() {
return 10f;
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PolarBearEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PolarBearEntity.java
index db658dd8e..7b5d42f35 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/PolarBearEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/PolarBearEntity.java
@@ -44,4 +44,9 @@ public class PolarBearEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return false;
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/RabbitEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/RabbitEntity.java
index 752a0d106..a789b48e4 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/RabbitEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/RabbitEntity.java
@@ -59,4 +59,9 @@ public class RabbitEntity extends AnimalEntity {
metadata.put(EntityData.VARIANT, variant);
}
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("dandelion") || javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("golden_carrot");
+ }
}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/StriderEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/StriderEntity.java
index 9ea97eb18..2a99a5a03 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/StriderEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/StriderEntity.java
@@ -85,4 +85,9 @@ public class StriderEntity extends AnimalEntity {
super.updateBedrockMetadata(session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("warped_fungus");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/TurtleEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/TurtleEntity.java
index 9456f4d28..89df815d7 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/TurtleEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/TurtleEntity.java
@@ -46,4 +46,9 @@ public class TurtleEntity extends AnimalEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("seagrass");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/AbstractHorseEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/AbstractHorseEntity.java
index 1fe8d4362..d2f89e101 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/AbstractHorseEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/AbstractHorseEntity.java
@@ -26,6 +26,7 @@
package org.geysermc.connector.entity.living.animal.horse;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.google.common.collect.ImmutableSet;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
@@ -38,7 +39,15 @@ import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.item.ItemRegistry;
+import java.util.Set;
+
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 DONKEY_AND_HORSE_FOODS = ImmutableSet.of("golden_apple", "enchanted_golden_apple",
+ "golden_carrot", "sugar", "apple", "wheat", "hay_block");
public AbstractHorseEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
@@ -101,4 +110,9 @@ public class AbstractHorseEntity extends AnimalEntity {
updateBedrockAttributes(session);
}
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return DONKEY_AND_HORSE_FOODS.contains(javaIdentifierStripped);
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
index 48e321932..0b21c771e 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java
@@ -75,4 +75,9 @@ public class LlamaEntity extends ChestedHorseEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("wheat") || javaIdentifierStripped.equals("hay_block");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java
index 87d700259..7866d25cf 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java
@@ -83,4 +83,9 @@ public class CatEntity extends TameableEntity {
}
}
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/ParrotEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/ParrotEntity.java
index f9df03d6b..50ec9ed04 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/ParrotEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/ParrotEntity.java
@@ -45,4 +45,9 @@ public class ParrotEntity extends TameableEntity {
}
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ return javaIdentifierStripped.contains("seeds") || javaIdentifierStripped.equals("cookie");
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/WolfEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/WolfEntity.java
index 144c0fe25..91350ef54 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/WolfEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/WolfEntity.java
@@ -26,13 +26,23 @@
package org.geysermc.connector.entity.living.animal.tameable;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.google.common.collect.ImmutableSet;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
+import java.util.Set;
+
public class WolfEntity extends TameableEntity {
+ /**
+ * A list of all foods a wolf can eat on Java Edition.
+ * Used to display interactive tag or particles if needed.
+ */
+ private static final Set WOLF_FOODS = ImmutableSet.of("pufferfish", "tropical_fish", "chicken", "cooked_chicken",
+ "porkchop", "beef", "rabbit", "cooked_porkchop", "cooked_beef", "rotten_flesh", "mutton", "cooked_mutton",
+ "cooked_rabbit");
private byte collarColor;
@@ -75,4 +85,10 @@ public class WolfEntity extends TameableEntity {
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public boolean canEat(String javaIdentifierStripped) {
+ // Cannot be a baby to eat these foods
+ return WOLF_FOODS.contains(javaIdentifierStripped) && !metadata.getFlags().getFlag(EntityFlag.BABY);
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
index 538b9d582..43658f63b 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
@@ -45,7 +45,7 @@ import java.util.List;
@Getter
public enum EntityType {
- CHICKEN(AnimalEntity.class, 10, 0.7f, 0.4f),
+ CHICKEN(ChickenEntity.class, 10, 0.7f, 0.4f),
COW(AnimalEntity.class, 11, 1.4f, 0.9f),
PIG(PigEntity.class, 12, 0.9f),
SHEEP(SheepEntity.class, 13, 1.3f, 0.9f),
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/BlockSoundInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/BlockSoundInteractionHandler.java
index 2172fd9e6..ea9951b83 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/BlockSoundInteractionHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/BlockSoundInteractionHandler.java
@@ -25,11 +25,9 @@
package org.geysermc.connector.network.translators.sound;
-import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.nukkitx.math.vector.Vector3f;
import org.geysermc.connector.inventory.GeyserItemStack;
import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.item.ItemRegistry;
import java.util.Map;
@@ -47,6 +45,9 @@ public interface BlockSoundInteractionHandler extends SoundInteractionHandler> interactionEntry : SoundHandlerRegistry.INTERACTION_HANDLERS.entrySet()) {
if (!(interactionEntry.getValue() instanceof BlockSoundInteractionHandler)) {
continue;
@@ -66,7 +67,9 @@ public interface BlockSoundInteractionHandler extends SoundInteractionHandler> interactionEntry : SoundHandlerRegistry.INTERACTION_HANDLERS.entrySet()) {
if (!(interactionEntry.getValue() instanceof EntitySoundInteractionHandler)) {
continue;
@@ -67,7 +68,10 @@ public interface EntitySoundInteractionHandler extends SoundInteractionHandler DONKEY_AND_HORSE_FOODS = ImmutableSet.of("golden_apple", "enchanted_golden_apple",
- "golden_carrot", "sugar", "apple", "wheat", "hay_block");
-
- /**
- * A list of all flowers. Used for feeding bees.
- */
- private static final Set FLOWERS = ImmutableSet.of("dandelion", "poppy", "blue_orchid", "allium", "azure_bluet",
- "red_tulip", "pink_tulip", "white_tulip", "orange_tulip", "cornflower", "lily_of_the_valley", "wither_rose",
- "sunflower", "lilac", "rose_bush", "peony");
-
/**
* All entity types that can be leashed on Java Edition
*/
@@ -66,14 +52,6 @@ public class InteractiveTagManager {
private static final Set SADDLEABLE_WHEN_TAMED_MOB_TYPES = EnumSet.of(EntityType.DONKEY, EntityType.HORSE,
EntityType.ZOMBIE_HORSE, EntityType.MULE);
- /**
- * A list of all foods a wolf can eat on Java Edition.
- * Used to display interactive tag if needed.
- */
- private static final Set WOLF_FOODS = ImmutableSet.of("pufferfish", "tropical_fish", "chicken", "cooked_chicken",
- "porkchop", "beef", "rabbit", "cooked_porkchop", "cooked_beef", "rotten_flesh", "mutton", "cooked_mutton",
- "cooked_rabbit");
-
/**
* Update the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride")
*
@@ -85,9 +63,8 @@ public class InteractiveTagManager {
ItemEntry itemEntry = session.getPlayerInventory().getItemInHand().getItemEntry();
String javaIdentifierStripped = itemEntry.getJavaIdentifier().replace("minecraft:", "");
- // TODO - in the future, update these in the metadata? So the client doesn't have to wiggle their cursor around for it to happen
- // TODO - also, might be good to abstract out the eating thing. I know there will need to be food tracked for https://github.com/GeyserMC/Geyser/issues/1005 but not all food is breeding food
InteractiveTag interactiveTag = InteractiveTag.NONE;
+
if (entityMetadata.getLong(EntityData.LEASH_HOLDER_EID) == session.getPlayerEntity().getGeyserId()) {
// Unleash the entity
interactiveTag = InteractiveTag.REMOVE_LEASH;
@@ -105,31 +82,24 @@ public class InteractiveTagManager {
// Holding a leash and the mob is leashable for sure
// (Plugins can change this behavior so that's something to look into in the far far future)
interactiveTag = InteractiveTag.LEASH;
+ } else if (interactEntity instanceof AnimalEntity && ((AnimalEntity) interactEntity).canEat(javaIdentifierStripped)) {
+ // This animal can be fed
+ interactiveTag = InteractiveTag.FEED;
} else {
switch (interactEntity.getEntityType()) {
- case BEE:
- if (FLOWERS.contains(javaIdentifierStripped)) {
- interactiveTag = InteractiveTag.FEED;
+ case BOAT:
+ if (interactEntity.getPassengers().size() < 2) {
+ interactiveTag = InteractiveTag.BOARD_BOAT;
}
break;
- case BOAT:
- interactiveTag = InteractiveTag.BOARD_BOAT;
- break;
case CAT:
- if (javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon")) {
- interactiveTag = InteractiveTag.FEED;
- } else if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED) &&
+ if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED) &&
entityMetadata.getLong(EntityData.OWNER_EID) == session.getPlayerEntity().getGeyserId()) {
// Tamed and owned by player - can sit/stand
interactiveTag = entityMetadata.getFlags().getFlag(EntityFlag.SITTING) ? InteractiveTag.STAND : InteractiveTag.SIT;
break;
}
break;
- case CHICKEN:
- if (javaIdentifierStripped.contains("seeds")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
case MOOSHROOM:
// Shear the mooshroom
if (javaIdentifierStripped.equals("shears")) {
@@ -143,9 +113,7 @@ public class InteractiveTagManager {
}
// Fall down to COW as this works on mooshrooms
case COW:
- if (javaIdentifierStripped.equals("wheat")) {
- interactiveTag = InteractiveTag.FEED;
- } else if (javaIdentifierStripped.equals("bucket")) {
+ if (javaIdentifierStripped.equals("bucket")) {
// Milk the cow
interactiveTag = InteractiveTag.MILK;
}
@@ -175,69 +143,28 @@ public class InteractiveTagManager {
interactiveTag = InteractiveTag.OPEN_CONTAINER;
break;
}
- // have another switch statement as, while these share mount attributes they don't share food
- switch (interactEntity.getEntityType()) {
- case LLAMA:
- case TRADER_LLAMA:
- if (javaIdentifierStripped.equals("wheat") || javaIdentifierStripped.equals("hay_block")) {
- interactiveTag = InteractiveTag.FEED;
- break;
- }
- case DONKEY:
- case HORSE:
- // Undead can't eat
- if (DONKEY_AND_HORSE_FOODS.contains(javaIdentifierStripped)) {
- interactiveTag = InteractiveTag.FEED;
- break;
- }
- }
if (!entityMetadata.getFlags().getFlag(EntityFlag.BABY)) {
// Can't ride a baby
if (tamed) {
interactiveTag = InteractiveTag.RIDE_HORSE;
- } else if (itemEntry.equals(ItemEntry.AIR)) {
+ } else if (itemEntry.getJavaId() == 0) {
// Can't hide an untamed entity without having your hand empty
interactiveTag = InteractiveTag.MOUNT;
}
}
break;
- case FOX:
- if (javaIdentifierStripped.equals("sweet_berries")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
- case HOGLIN:
- if (javaIdentifierStripped.equals("crimson_fungus")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
case MINECART:
- interactiveTag = InteractiveTag.RIDE_MINECART;
+ if (interactEntity.getPassengers().isEmpty()) {
+ interactiveTag = InteractiveTag.RIDE_MINECART;
+ }
break;
case MINECART_CHEST:
case MINECART_COMMAND_BLOCK:
case MINECART_HOPPER:
interactiveTag = InteractiveTag.OPEN_CONTAINER;
break;
- case OCELOT:
- if (javaIdentifierStripped.equals("cod") || javaIdentifierStripped.equals("salmon")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
- case PANDA:
- if (javaIdentifierStripped.equals("bamboo")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
- case PARROT:
- if (javaIdentifierStripped.contains("seeds") || javaIdentifierStripped.equals("cookie")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
case PIG:
- if (javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("potato") || javaIdentifierStripped.equals("beetroot")) {
- interactiveTag = InteractiveTag.FEED;
- } else if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
+ if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
interactiveTag = InteractiveTag.MOUNT;
}
break;
@@ -246,15 +173,8 @@ public class InteractiveTagManager {
interactiveTag = InteractiveTag.BARTER;
}
break;
- case RABBIT:
- if (javaIdentifierStripped.equals("dandelion") || javaIdentifierStripped.equals("carrot") || javaIdentifierStripped.equals("golden_carrot")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
case SHEEP:
- if (javaIdentifierStripped.equals("wheat")) {
- interactiveTag = InteractiveTag.FEED;
- } else if (!entityMetadata.getFlags().getFlag(EntityFlag.SHEARED)) {
+ if (!entityMetadata.getFlags().getFlag(EntityFlag.SHEARED)) {
if (javaIdentifierStripped.equals("shears")) {
// Shear the sheep
interactiveTag = InteractiveTag.SHEAR;
@@ -265,17 +185,10 @@ public class InteractiveTagManager {
}
break;
case STRIDER:
- if (javaIdentifierStripped.equals("warped_fungus")) {
- interactiveTag = InteractiveTag.FEED;
- } else if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
+ if (entityMetadata.getFlags().getFlag(EntityFlag.SADDLED)) {
interactiveTag = InteractiveTag.RIDE_STRIDER;
}
break;
- case TURTLE:
- if (javaIdentifierStripped.equals("seagrass")) {
- interactiveTag = InteractiveTag.FEED;
- }
- break;
case VILLAGER:
if (entityMetadata.getInt(EntityData.VARIANT) != 14 && entityMetadata.getInt(EntityData.VARIANT) != 0
&& entityMetadata.getFloat(EntityData.SCALE) >= 0.75f) { // Not a nitwit, has a profession and is not a baby
@@ -289,10 +202,6 @@ public class InteractiveTagManager {
if (javaIdentifierStripped.equals("bone") && !entityMetadata.getFlags().getFlag(EntityFlag.TAMED)) {
// Bone and untamed - can tame
interactiveTag = InteractiveTag.TAME;
- } else if (WOLF_FOODS.contains(javaIdentifierStripped)) {
- // Compatible food in hand - feed
- // Sometimes just sits/stands when the wolf isn't hungry - there doesn't appear to be a way to fix this
- interactiveTag = InteractiveTag.FEED;
} else if (entityMetadata.getFlags().getFlag(EntityFlag.TAMED) &&
entityMetadata.getLong(EntityData.OWNER_EID) == session.getPlayerEntity().getGeyserId()) {
// Tamed and owned by player - can sit/stand