Smooth cauldron item orbits and lower soup level after each serving

This commit is contained in:
2026-09-05 15:24:44 +03:00
parent 6c03e62761
commit 945188193a
9 changed files with 177 additions and 106 deletions
+26 -14
View File
@@ -93,10 +93,10 @@ public final class SoupSmokeTest extends JavaPlugin {
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) {
private List<ItemDisplay> 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();
.filter(e -> e instanceof ItemDisplay && e.getPersistentDataContainer().has(new NamespacedKey(plugin, "cauldron_visual")))
.map(e -> (ItemDisplay) e).toList();
}
private ItemStack soupInInventory() {
return Arrays.stream(player.getInventory().getContents()).filter(Objects::nonNull).filter(plugin.ingredients()::isCombined).findFirst().orElseThrow();
@@ -194,11 +194,11 @@ public final class SoupSmokeTest extends JavaPlugin {
check(player.getInventory().getItemInMainHand().getAmount() == 2, "Cancelled protected interaction does not take an ingredient");
addFour(pot);
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");
long count = visualItems(pot).size();
check(count == 4, "Four ItemDisplays visualize the ingredients");
check(visualItems(pot).stream().allMatch(e -> e.getLocation().getY() + e.getTransformation().getTranslation().y < pot.getY() + .9375 - .05), "Display centers are partly submerged without client item bobbing");
for (ItemDisplay drop : visualItems(pot)) {
check(!drop.hasGravity() && drop.getInterpolationDuration() == 2, "Display ingredient has client interpolation and no dropped-item physics");
}
click(pot, item(Material.AIR), false, false);
check(player.getInventory().getItemInMainHand().getType() == Material.SPLASH_POTION, "Empty-hand withdrawal is LIFO");
@@ -215,16 +215,17 @@ public final class SoupSmokeTest extends JavaPlugin {
click(pot, item(Material.AIR), true, false);
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();
ItemDisplay tracked = visualItems(pot).getFirst(); Location anchor = tracked.getLocation();
org.joml.Vector3f start = new org.joml.Vector3f(tracked.getTransformation().getTranslation());
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");
org.joml.Vector3f moved = tracked.getTransformation().getTranslation();
check(tracked.isValid() && tracked.getLocation().equals(anchor) && moved.distance(start) > .1, "Same stationary entity moves its interpolated model without teleporting");
check(Math.abs(Math.hypot(moved.x, moved.z) - .23) < .00001, "Whirlpool maintains its radius instead of collapsing to center");
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");
@@ -233,12 +234,22 @@ public final class SoupSmokeTest extends JavaPlugin {
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");
check(visualItems(pot).isEmpty(), "Brew removes ingredient visuals");
double previousHeight = surface.getTransformation().getTranslation().y;
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.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(((Levelled) pot.getBlockData()).getLevel() == 2 && surface.isValid()
&& surface.getTransformation().getTranslation().y < previousHeight, "First portion lowers both water and the same interpolated soup surface");
for (int i = 0; i < 3; i++) {
previousHeight = surface.getTransformation().getTranslation().y;
click(pot, item(Material.BOWL), false, false);
if (i < 2) check(surface.isValid() && surface.getTransformation().getTranslation().y < previousHeight,
"Each remaining portion visibly lowers soup without respawning the surface");
if (i == 1) check(pot.getType() == Material.CAULDRON && surface.isValid(), "Last portion uses a low colored surface with no blue water above it");
}
check(!surface.isValid(), "Final portion removes the liquid surface");
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");
@@ -256,6 +267,7 @@ public final class SoupSmokeTest extends JavaPlugin {
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");
check(((Levelled) pot.getBlockData()).getLevel() == 1, "Restart preserves the reduced water level for two of four servings");
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");