Add submerged whirlpool brewing, four servings and mixed soup colors
This commit is contained in:
@@ -89,6 +89,15 @@ public final class SoupSmokeTest extends JavaPlugin {
|
||||
return event;
|
||||
}
|
||||
private void addFour(Block block) { for (ItemStack i : recipe()) click(block, i, false, false); }
|
||||
private void advance(int ticks) throws Exception {
|
||||
var refresh = AstraSoupsPlugin.class.getDeclaredMethod("refresh"); refresh.setAccessible(true);
|
||||
for (int i = 0; i < ticks; i++) refresh.invoke(plugin);
|
||||
}
|
||||
private List<Item> visualItems(Block block) {
|
||||
return world.getNearbyEntities(block.getLocation().add(.5, .5, .5), .5, .5, .5).stream()
|
||||
.filter(e -> e instanceof Item && e.getPersistentDataContainer().has(new NamespacedKey(plugin, "cauldron_visual")))
|
||||
.map(e -> (Item) e).toList();
|
||||
}
|
||||
private ItemStack soupInInventory() {
|
||||
return Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).filter(plugin.ingredients()::isCombined).findFirst().orElseThrow();
|
||||
}
|
||||
@@ -113,6 +122,24 @@ public final class SoupSmokeTest extends JavaPlugin {
|
||||
check(soup.getData(DataComponentTypes.FOOD).nutrition() == 10, "Example combines 10 hunger points");
|
||||
check(Math.abs(soup.getData(DataComponentTypes.FOOD).saturation() - 13.2f) < .001, "Example combines 13.2 saturation points");
|
||||
check(soup.getMaxStackSize() == 16, "Combined soup stacks to sixteen");
|
||||
var plain = net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText();
|
||||
List<String> lore = soup.lore().stream().map(plain::serialize).toList();
|
||||
check(lore.stream().anyMatch(s -> s.contains(" II (1:30)")) && lore.stream().anyMatch(s -> s.contains(" I (8:00)")), "Potion levels use Roman numerals with parenthesized durations");
|
||||
check(lore.stream().noneMatch(s -> s.contains("\u2022")), "Soup descriptions contain no floating dot separators");
|
||||
ItemStack oldSoup = soup.clone(); ItemMeta oldMeta = oldSoup.getItemMeta();
|
||||
oldMeta.lore(List.of(net.kyori.adventure.text.Component.text("Strength 2 \u2022 1:30"))); oldSoup.setItemMeta(oldMeta);
|
||||
check(Ingredients.normalize(oldSoup) && oldSoup.isSimilar(soup), "Existing soup descriptions migrate without changing effects or food");
|
||||
ItemStack purple = potion(Material.POTION, PotionType.WATER), green = purple.clone();
|
||||
PotionMeta purpleMeta = (PotionMeta) purple.getItemMeta(); purpleMeta.setColor(Color.fromRGB(0x8B3AC7)); purple.setItemMeta(purpleMeta);
|
||||
PotionMeta greenMeta = (PotionMeta) green.getItemMeta(); greenMeta.setColor(Color.fromRGB(0x45B649)); green.setItemMeta(greenMeta);
|
||||
ItemStack colorExample = ingredients.brew(List.of(item(Material.SPIDER_EYE), item(Material.GOLDEN_APPLE), purple, green));
|
||||
NamespacedKey colorKey = new NamespacedKey(plugin, "soup_color");
|
||||
check(colorExample.getItemMeta().getPersistentDataContainer().get(colorKey, org.bukkit.persistence.PersistentDataType.INTEGER) == 0x9D7965, "Red eye, golden apple, purple and green potions blend into exact brown RGB");
|
||||
ItemStack redSoup = ingredients.brew(Collections.nCopies(4, item(Material.APPLE)));
|
||||
ItemStack orangeSoup = ingredients.brew(Collections.nCopies(4, item(Material.CARROT)));
|
||||
check(!redSoup.getItemMeta().getPersistentDataContainer().get(colorKey, org.bukkit.persistence.PersistentDataType.INTEGER)
|
||||
.equals(orangeSoup.getItemMeta().getPersistentDataContainer().get(colorKey, org.bukkit.persistence.PersistentDataType.INTEGER)), "Different food colors produce different soup colors");
|
||||
check(ingredients.read(redSoup).color().asRGB() == 0xC73735, "Reusing a combined soup preserves its stored liquid color");
|
||||
List<ItemStack> reversed = new ArrayList<>(Arrays.asList(recipe())); Collections.reverse(reversed);
|
||||
check(ingredients.brew(reversed).isSimilar(soup), "Same recipe stacks regardless of ingredient insertion order");
|
||||
check(effects(soup).stream().anyMatch(e -> e.getType().equals(PotionEffectType.NIGHT_VISION) && e.getDuration() == 9600 && e.getAmplifier() == 0), "Extended night vision preserved");
|
||||
@@ -169,6 +196,7 @@ public final class SoupSmokeTest extends JavaPlugin {
|
||||
check(player.getInventory().getItemInMainHand().getType().isAir(), "Adding a fourth ingredient consumes exactly one item");
|
||||
long count = world.getEntities().stream().filter(e -> e instanceof Item && e.getPersistentDataContainer().has(new NamespacedKey(plugin, "cauldron_visual"))).count();
|
||||
check(count == 4, "Four real item entities visualize the ingredients");
|
||||
check(visualItems(pot).stream().allMatch(e -> e.getLocation().getY() < pot.getY() + .9375 - .26), "Idle ingredients are partly submerged after accounting for client item bobbing");
|
||||
for (Entity e : world.getEntities()) if (e instanceof Item drop && e.getPersistentDataContainer().has(new NamespacedKey(plugin, "cauldron_visual"))) {
|
||||
check(!drop.canPlayerPickup() && !drop.canMobPickup() && !drop.hasGravity() && drop.isUnlimitedLifetime(), "Display ingredient cannot be picked up or expire");
|
||||
}
|
||||
@@ -178,35 +206,79 @@ public final class SoupSmokeTest extends JavaPlugin {
|
||||
plugin.getConfig().set("incompatible", List.of(List.of("material:cooked_beef", "effect:minecraft:strength")));
|
||||
plugin.saveConfig(); plugin.onCommand(Bukkit.getConsoleSender(), plugin.getCommand("soups"), "soups", new String[]{"reload"});
|
||||
click(pot, item(Material.AIR), true, false);
|
||||
check(world.getEntities().stream().noneMatch(e -> e instanceof BlockDisplay), "Incompatible recipe does not create ready soup");
|
||||
check(world.getEntities().stream().noneMatch(e -> e instanceof TextDisplay), "Incompatible recipe does not create ready soup");
|
||||
click(pot, item(Material.AIR), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getType() == Material.SPLASH_POTION, "Rejected recipe retains its ingredients");
|
||||
plugin.getConfig().set("incompatible", List.of()); plugin.saveConfig();
|
||||
plugin.onCommand(Bukkit.getConsoleSender(), plugin.getCommand("soups"), "soups", new String[]{"reload"});
|
||||
click(pot, recipe()[3], false, false);
|
||||
click(pot, item(Material.AIR), true, false);
|
||||
check(world.getEntities().stream().anyMatch(e -> e instanceof BlockDisplay), "Brew creates colored soup surface");
|
||||
check(world.getEntities().stream().noneMatch(e -> e instanceof TextDisplay), "Starting a brew does not create soup immediately");
|
||||
check(visualItems(pot).size() == 4, "Brewing retains four animated ingredient entities");
|
||||
Item tracked = visualItems(pot).getFirst(); Location start = tracked.getLocation();
|
||||
click(pot, new ItemStack(Material.BOWL, 2), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getAmount() == 2
|
||||
&& Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).noneMatch(plugin.ingredients()::isCombined), "An early bowl cannot collect soup or be consumed");
|
||||
click(pot, item(Material.AIR), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getType().isAir() && visualItems(pot).size() == 4, "Empty hand cannot withdraw ingredients during brewing");
|
||||
advance(40);
|
||||
check(tracked.isValid() && tracked.getLocation().distance(start) > .1, "Same item entity moves along the whirlpool");
|
||||
double radius = Math.hypot(tracked.getLocation().getX() - pot.getX() - .5, tracked.getLocation().getZ() - pot.getZ() - .5);
|
||||
check(radius < .2 && tracked.getLocation().getY() < start.getY(), "Whirlpool pulls ingredients inward and downward");
|
||||
click(pot, item(Material.STICK), true, false);
|
||||
advance(39);
|
||||
check(world.getEntities().stream().noneMatch(e -> e instanceof TextDisplay), "No soup before the configured 80th tick");
|
||||
advance(1);
|
||||
check(world.getEntities().stream().anyMatch(e -> e instanceof TextDisplay), "Brew creates colored soup surface");
|
||||
TextDisplay surface = world.getEntities().stream().filter(e -> e instanceof TextDisplay).map(e -> (TextDisplay) e).findFirst().orElseThrow();
|
||||
check(surface.getBackgroundColor().asRGB() == soup.getItemMeta().getPersistentDataContainer().get(colorKey, org.bukkit.persistence.PersistentDataType.INTEGER)
|
||||
&& surface.getBackgroundColor().getAlpha() == 255 && !surface.isSeeThrough(), "Liquid surface uses the exact opaque mixed RGB, not a terracotta palette");
|
||||
check(world.getEntities().stream().noneMatch(e -> e instanceof Item && e.getPersistentDataContainer().has(new NamespacedKey(plugin, "cauldron_visual"))), "Brew removes ingredient visuals");
|
||||
click(pot, new ItemStack(Material.BOWL, 2), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getAmount() == 1, "Collecting soup consumes one bowl");
|
||||
check(soupInInventory().isSimilar(soup), "Collecting yields exactly the expected recipe");
|
||||
check(pot.getType() == Material.CAULDRON, "Collecting consumes cauldron water");
|
||||
check(pot.getType() == Material.WATER_CAULDRON, "Cauldron retains soup after the first of four portions");
|
||||
for (int i = 0; i < 3; i++) click(pot, item(Material.BOWL), false, false);
|
||||
check(soupInInventory().getAmount() == 4 && pot.getType() == Material.CAULDRON, "Four bowls collect exactly four stackable portions and empty the cauldron");
|
||||
click(pot, item(Material.BOWL), false, false);
|
||||
check(soupInInventory().getAmount() == 4, "A fifth bowl cannot obtain another portion");
|
||||
// Persist one raw and one cooked cauldron for a true process restart.
|
||||
fill(pot); addFour(pot); click(pot, item(Material.STICK), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getType() == Material.STICK, "Ordinary right-click with an item starts cooking without consuming the tool");
|
||||
advance(80);
|
||||
click(pot, item(Material.BOWL), false, false);
|
||||
click(pot, item(Material.BOWL), false, false);
|
||||
Block raw = world.getBlockAt(5, 80, 2); fill(raw); click(raw, item(Material.GOLDEN_CARROT), false, false);
|
||||
Block brewing = world.getBlockAt(8, 80, 2); fill(brewing); addFour(brewing); click(brewing, item(Material.STICK), false, false);
|
||||
check(visualItems(brewing).size() == 4, "In-flight brew saved for restart with its four ingredients");
|
||||
check(new java.io.File(plugin.getDataFolder(), "cauldrons.yml").length() > 0, "Cauldron states saved before restart");
|
||||
}
|
||||
private void second() {
|
||||
private void second() throws Exception {
|
||||
advance(1); // setup loaded the chunk this tick; give visuals their first refresh.
|
||||
check(pot.getType() == Material.WATER_CAULDRON, "Ready cauldron block survives restart");
|
||||
click(pot, item(Material.BOWL), false, false);
|
||||
click(pot, new ItemStack(Material.BOWL, 2), false, false);
|
||||
ItemStack soup = soupInInventory();
|
||||
check(soup.getMaxStackSize() == 16 && effects(soup).size() == 2, "Ready soup keeps stack size and effects across process restart");
|
||||
click(pot, item(Material.BOWL), false, false);
|
||||
check(soupInInventory().getAmount() == 2 && pot.getType() == Material.CAULDRON, "Restart preserves exactly two remaining portions instead of refilling the cauldron");
|
||||
player.getInventory().clear();
|
||||
Block raw = world.getBlockAt(5, 80, 2);
|
||||
click(raw, item(Material.AIR), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getType() == Material.GOLDEN_CARROT, "Raw ingredient can be withdrawn after process restart");
|
||||
click(raw, item(Material.AIR), false, false);
|
||||
check(player.getInventory().isEmpty(), "Withdrawn ingredient cannot be obtained twice");
|
||||
Block brewing = world.getBlockAt(8, 80, 2);
|
||||
check(visualItems(brewing).size() == 4, "In-flight brew restores animated ingredients after process restart");
|
||||
click(brewing, item(Material.BOWL), false, false);
|
||||
check(player.getInventory().getItemInMainHand().getType() == Material.BOWL
|
||||
&& Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).noneMatch(plugin.ingredients()::isCombined), "Restart cannot turn an in-flight brew into instant soup");
|
||||
advance(80);
|
||||
click(brewing, new ItemStack(Material.BOWL, 4), false, false);
|
||||
check(soupInInventory().getMaxStackSize() == 16 && effects(soupInInventory()).size() == 2, "Resumed brew completes and yields the expected soup once");
|
||||
for (int i = 0; i < 3; i++) click(brewing, player.getInventory().getItemInMainHand(), false, false);
|
||||
check(soupInInventory().getAmount() == 4 && brewing.getType() == Material.CAULDRON, "Resumed in-flight brew produces exactly four portions");
|
||||
player.getInventory().clear();
|
||||
click(brewing, item(Material.BOWL), false, false);
|
||||
check(Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).noneMatch(plugin.ingredients()::isCombined), "Repeated collection cannot duplicate a completed brew");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user