Added support for 1.20's food for breeding compatibility.

This commit is contained in:
Brianna OKeefe 2024-03-11 19:07:11 -05:00
parent 50d1a41acd
commit 0319e37caf

View File

@ -8,13 +8,7 @@ import com.craftaro.ultimatestacker.settings.Settings;
import com.craftaro.ultimatestacker.stackable.entity.Split;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@ -75,55 +69,68 @@ public class InteractListeners implements Listener {
private boolean correctFood(ItemStack is, Entity entity) {
Material type = is.getType();
switch (entity.getType().name()) {
case "COW":
case "MUSHROOM_COW":
case "SHEEP":
return type == Material.WHEAT;
case "PIG":
return type == Material.CARROT || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && type == Material.BEETROOT) || type == Material.POTATO;
return type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO;
case "CHICKEN":
return type == XMaterial.WHEAT_SEEDS.parseMaterial()
return type == Material.WHEAT_SEEDS
|| type == Material.MELON_SEEDS
|| type == Material.PUMPKIN_SEEDS
|| type == XMaterial.BEETROOT_SEEDS.parseMaterial();
|| type == Material.BEETROOT_SEEDS;
case "HORSE":
return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed();
case "DONKEY":
case "MULE":
return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((AbstractHorse) entity).isTamed();
case "WOLF":
return type == XMaterial.BEEF.parseMaterial()
|| type == XMaterial.CHICKEN.parseMaterial()
|| type == XMaterial.COD.parseMaterial()
|| type == XMaterial.MUTTON.parseMaterial()
|| type == XMaterial.PORKCHOP.parseMaterial()
|| type == XMaterial.RABBIT.parseMaterial()
|| XMaterial.SALMON.equals(XMaterial.matchXMaterial(is))
|| type == XMaterial.COOKED_BEEF.parseMaterial()
|| type == XMaterial.COOKED_CHICKEN.parseMaterial()
|| type == XMaterial.COOKED_COD.parseMaterial()
|| type == XMaterial.COOKED_MUTTON.parseMaterial()
|| type == XMaterial.COOKED_PORKCHOP.parseMaterial()
|| type == XMaterial.COOKED_RABBIT.parseMaterial()
|| XMaterial.COOKED_SALMON.equals(XMaterial.matchXMaterial(is))
return type == Material.BEEF
|| type == Material.CHICKEN
|| type == Material.COD
|| type == Material.MUTTON
|| type == Material.PORKCHOP
|| type == Material.RABBIT
|| type == Material.SALMON
|| type == Material.COOKED_BEEF
|| type == Material.COOKED_CHICKEN
|| type == Material.COOKED_COD
|| type == Material.COOKED_MUTTON
|| type == Material.COOKED_PORKCHOP
|| type == Material.COOKED_RABBIT
|| type == Material.COOKED_SALMON
|| type == Material.ROTTEN_FLESH
&& ((Wolf) entity).isTamed();
case "OCELOT":
return (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
? type == Material.SALMON
|| type == Material.COD
|| type == Material.PUFFERFISH
|| type == Material.TROPICAL_FISH
: type == XMaterial.COD.parseMaterial()); // Now broken in 1.13 ((Ocelot) entity).isTamed()
case "PANDA":
return (type == Material.BAMBOO);
case "FOX":
return type == Material.SWEET_BERRIES;
case "CAT":
return (type == Material.COD || type == Material.SALMON) && ((Cat) entity).isTamed();
return (type == Material.COD || type == Material.SALMON) && ((Tameable) entity).isTamed();
case "PANDA":
return type == Material.BAMBOO;
case "FOX":
return type == Material.SWEET_BERRIES || type == Material.GLOW_BERRIES;
case "RABBIT":
return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION;
case "LLAMA":
case "TRADER_LLAMA":
return type == Material.HAY_BLOCK;
case "TURTLE":
return type == Material.SEAGRASS;
case "HOGLIN":
return type == Material.CRIMSON_FUNGUS;
case "STRIDER":
return type == Material.WARPED_FUNGUS;
case "BEE":
return type == Material.HONEYCOMB || type == Material.HONEY_BOTTLE;
case "AXOLOTL":
return type == Material.TROPICAL_FISH_BUCKET;
case "GOAT":
return type == Material.WHEAT;
case "GLOW_SQUID":
return type == Material.GLOW_INK_SAC;
case "CAMEL":
return type == Material.CACTUS;
default:
return false;
}