297 lines
24 KiB
Java
297 lines
24 KiB
Java
package smoke;
|
|
|
|
import online.astracraft.soups.*;
|
|
import io.papermc.paper.datacomponent.DataComponentTypes;
|
|
import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
|
|
import org.bukkit.*;
|
|
import org.bukkit.block.*;
|
|
import org.bukkit.block.data.Levelled;
|
|
import org.bukkit.entity.*;
|
|
import org.bukkit.event.Event;
|
|
import org.bukkit.event.block.*;
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
import org.bukkit.inventory.*;
|
|
import org.bukkit.inventory.meta.*;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.bukkit.potion.*;
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
import com.mojang.authlib.GameProfile;
|
|
import net.minecraft.network.Connection;
|
|
import net.minecraft.network.protocol.PacketFlow;
|
|
import net.minecraft.server.level.ClientInformation;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.server.network.CommonListenerCookie;
|
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
|
import java.nio.file.*;
|
|
import java.util.*;
|
|
|
|
/** ONLY for the disposable isolated server; never install this helper on the working server. */
|
|
public final class SoupSmokeTest extends JavaPlugin {
|
|
private final List<String> results = new ArrayList<>();
|
|
private AstraSoupsPlugin plugin;
|
|
private Player player;
|
|
private ServerPlayer nativePlayer;
|
|
private World world;
|
|
private Block pot;
|
|
|
|
@Override public void onEnable() {
|
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
|
String phase = Files.exists(getDataFolder().toPath().resolve("phase1.txt")) ? "phase2" : "phase1";
|
|
try {
|
|
setup();
|
|
if (phase.equals("phase1")) first(); else second();
|
|
results.add("PASS: ALL " + results.size() + " CHECKS (" + phase + ")");
|
|
} catch (Throwable ex) {
|
|
getLogger().log(java.util.logging.Level.SEVERE, "SMOKE FAILED", ex);
|
|
results.add("FAIL: " + ex);
|
|
}
|
|
try { Files.createDirectories(getDataFolder().toPath()); Files.write(getDataFolder().toPath().resolve(phase + ".txt"), results); }
|
|
catch (Exception e) { throw new RuntimeException(e); }
|
|
results.forEach(getLogger()::info);
|
|
Bukkit.shutdown();
|
|
}, 40);
|
|
}
|
|
|
|
private void setup() {
|
|
plugin = (AstraSoupsPlugin) Bukkit.getPluginManager().getPlugin("AstraSoups");
|
|
check(plugin != null && plugin.isEnabled(), "Plugin enables on Paper 26.2");
|
|
world = Bukkit.getWorlds().getFirst();
|
|
world.getChunkAt(0, 0).addPluginChunkTicket(this);
|
|
var server = ((CraftServer) Bukkit.getServer()).getServer();
|
|
var level = ((CraftWorld) world).getHandle();
|
|
var profile = new GameProfile(UUID.randomUUID(), "SoupTest");
|
|
nativePlayer = new ServerPlayer(server, level, profile, ClientInformation.createDefault());
|
|
nativePlayer.connection = new ServerGamePacketListenerImpl(server, new Connection(PacketFlow.SERVERBOUND), nativePlayer, CommonListenerCookie.createInitial(profile, false));
|
|
nativePlayer.setPos(2, 80, 2);
|
|
player = nativePlayer.getBukkitEntity();
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
pot = world.getBlockAt(2, 80, 2);
|
|
}
|
|
|
|
private void check(boolean value, String name) { if (!value) throw new AssertionError(name); results.add("PASS: " + name); }
|
|
private ItemStack item(Material material) { return new ItemStack(material); }
|
|
private ItemStack potion(Material material, PotionType type) {
|
|
ItemStack stack = item(material); PotionMeta meta = (PotionMeta) stack.getItemMeta();
|
|
meta.setBasePotionType(type); stack.setItemMeta(meta); return stack;
|
|
}
|
|
private ItemStack[] recipe() {
|
|
return new ItemStack[]{potion(Material.POTION, PotionType.LONG_NIGHT_VISION), item(Material.COOKED_BEEF), item(Material.GLOW_BERRIES), potion(Material.SPLASH_POTION, PotionType.STRONG_STRENGTH)};
|
|
}
|
|
private void fill(Block b) { b.setType(Material.WATER_CAULDRON); Levelled l = (Levelled) b.getBlockData(); l.setLevel(3); b.setBlockData(l); }
|
|
private PlayerInteractEvent click(Block block, ItemStack held, boolean sneak, boolean denied) {
|
|
player.getInventory().setItemInMainHand(held);
|
|
player.setSneaking(sneak);
|
|
PlayerInteractEvent event = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, held, block, BlockFace.UP, EquipmentSlot.HAND);
|
|
if (denied) event.setUseInteractedBlock(Event.Result.DENY);
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
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<ItemDisplay> visualItems(Block block) {
|
|
return world.getNearbyEntities(block.getLocation().add(.5, .5, .5), .5, .5, .5).stream()
|
|
.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();
|
|
}
|
|
private List<PotionEffect> effects(ItemStack soup) {
|
|
return soup.getData(DataComponentTypes.CONSUMABLE).consumeEffects().stream().filter(e -> e instanceof ConsumeEffect.ApplyStatusEffects)
|
|
.flatMap(e -> ((ConsumeEffect.ApplyStatusEffects) e).effects().stream()).toList();
|
|
}
|
|
private void first() throws Exception {
|
|
Ingredients ingredients = plugin.ingredients();
|
|
check(Math.abs(ingredients.read(item(Material.COOKED_BEEF)).saturation() - 12.8f) < .001, "Steak saturation is 12.8 absolute points");
|
|
for (Material material : Material.values()) if (material.isItem() && material.isEdible()) {
|
|
check(ingredients.read(item(material)) != null, "Edible accepted: " + material);
|
|
}
|
|
check(ingredients.read(item(Material.CAKE)).nutrition() == 14, "Whole cake accepted as seven slices");
|
|
check(ingredients.read(item(Material.TIPPED_ARROW)) == null, "Tipped arrows are not potion ingredients");
|
|
check(ingredients.read(item(Material.STONE)) == null, "Nonfood rejected");
|
|
for (Material material : List.of(Material.MUSHROOM_STEW, Material.RABBIT_STEW, Material.BEETROOT_SOUP, Material.SUSPICIOUS_STEW)) {
|
|
ItemStack stack = item(material); Ingredients.normalize(stack);
|
|
check(stack.getMaxStackSize() == 16, "Vanilla soup stack size: " + material);
|
|
}
|
|
ItemStack soup = ingredients.brew(Arrays.asList(recipe()));
|
|
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");
|
|
check(effects(soup).stream().anyMatch(e -> e.getType().equals(PotionEffectType.STRENGTH) && e.getDuration() == 1800 && e.getAmplifier() == 1), "Strength II from splash potion preserved without splash reduction");
|
|
ItemStack roundTrip = ItemStack.deserializeBytes(soup.serializeAsBytes());
|
|
check(roundTrip.isSimilar(soup), "All soup components survive binary serialization");
|
|
var yaml = new org.bukkit.configuration.file.YamlConfiguration(); yaml.set("soup", soup);
|
|
var loaded = new org.bukkit.configuration.file.YamlConfiguration(); loaded.loadFromString(yaml.saveToString());
|
|
check(soup.isSimilar(loaded.getItemStack("soup")), "Soup survives YAML serialization");
|
|
ItemStack appleSoup = ingredients.brew(Collections.nCopies(4, item(Material.ENCHANTED_GOLDEN_APPLE)));
|
|
check(effects(appleSoup).stream().anyMatch(e -> e.getType().equals(PotionEffectType.ABSORPTION) && e.getAmplifier() == 3), "Unique vanilla food effects preserved");
|
|
ItemStack stew = item(Material.SUSPICIOUS_STEW); SuspiciousStewMeta sm = (SuspiciousStewMeta) stew.getItemMeta();
|
|
sm.addCustomEffect(new PotionEffect(PotionEffectType.BLINDNESS, 240, 0), true); stew.setItemMeta(sm);
|
|
ItemStack stewSoup = ingredients.brew(List.of(stew, item(Material.APPLE), item(Material.APPLE), item(Material.APPLE)));
|
|
check(effects(stewSoup).stream().anyMatch(e -> e.getType().equals(PotionEffectType.BLINDNESS) && e.getDuration() == 240), "Suspicious stew effect retained");
|
|
ItemStack customPotion = potion(Material.LINGERING_POTION, PotionType.WATER);
|
|
PotionMeta pm = (PotionMeta) customPotion.getItemMeta(); pm.addCustomEffect(new PotionEffect(PotionEffectType.HASTE, 1234, 2, true, false, false), true); customPotion.setItemMeta(pm);
|
|
ItemStack customPotionSoup = ingredients.brew(List.of(customPotion, item(Material.APPLE), item(Material.APPLE), item(Material.APPLE)));
|
|
check(effects(customPotionSoup).stream().anyMatch(e -> e.getDuration() == 1234 && e.getAmplifier() == 2 && e.isAmbient() && !e.hasParticles() && !e.hasIcon()), "Custom lingering potion flags and exact ticks preserved");
|
|
// Real Minecraft consumption and vanilla remainder handling, using a disconnected native server player.
|
|
player.getInventory().clear(); player.setFoodLevel(5); player.setSaturation(0);
|
|
ItemStack stack = soup.clone(); stack.setAmount(2);
|
|
var nms = CraftItemStack.asNMSCopy(stack);
|
|
var remaining = nms.finishUsingItem(((CraftWorld) world).getHandle(), nativePlayer);
|
|
check(player.getFoodLevel() == 15 && Math.abs(player.getSaturation() - 13.2f) < .001, "Native eating applies summed hunger and saturation exactly once");
|
|
check(player.getPotionEffect(PotionEffectType.STRENGTH).getAmplifier() == 1
|
|
&& player.getPotionEffect(PotionEffectType.NIGHT_VISION).getDuration() == 9600, "Native eating applies strength and night vision");
|
|
check(remaining.getCount() == 1 && CraftItemStack.asBukkitCopy(remaining).isSimilar(soup), "Native eating keeps the remaining stacked soup");
|
|
check(player.getInventory().contains(Material.BOWL), "Native eating returns one bowl from a stack");
|
|
var last = remaining.finishUsingItem(((CraftWorld) world).getHandle(), nativePlayer);
|
|
check(CraftItemStack.asBukkitCopy(last).getType() == Material.BOWL, "Final soup becomes a bowl");
|
|
check(player.getFoodLevel() == 20 && player.getSaturation() == 20, "Native hunger and saturation remain capped at twenty");
|
|
|
|
player.addAttachment(this, "astrasoups.admin", true);
|
|
ItemStack unique = item(Material.PAPER); ItemMeta uniqueMeta = unique.getItemMeta();
|
|
uniqueMeta.displayName(net.kyori.adventure.text.Component.text("Custom test food")); unique.setItemMeta(uniqueMeta);
|
|
player.getInventory().setItemInMainHand(unique);
|
|
plugin.onCommand(player, plugin.getCommand("soups"), "soups", new String[]{"register", "test_food", "7", "4.5"});
|
|
check(plugin.ingredients().read(unique).nutrition() == 7 && plugin.ingredients().read(unique).tags().contains("custom:test_food"), "Registered nonvanilla food supplies custom nutrition and selector");
|
|
check(plugin.ingredients().read(item(Material.PAPER)) == null, "Registered custom food does not match plain base material");
|
|
var configPath = plugin.getDataFolder().toPath().resolve("config.yml");
|
|
String goodConfig = Files.readString(configPath);
|
|
Files.writeString(configPath, "incompatible: [broken");
|
|
plugin.onCommand(Bukkit.getConsoleSender(), plugin.getCommand("soups"), "soups", new String[]{"reload"});
|
|
check(plugin.ingredients().read(unique).nutrition() == 7, "Malformed reload retains previous working ingredient configuration");
|
|
Files.writeString(configPath, goodConfig);
|
|
plugin.onCommand(Bukkit.getConsoleSender(), plugin.getCommand("soups"), "soups", new String[]{"reload"});
|
|
|
|
player.getInventory().clear(); fill(pot);
|
|
ItemStack denied = new ItemStack(Material.APPLE, 2);
|
|
click(pot, denied, false, true);
|
|
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 = 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");
|
|
click(pot, recipe()[3], false, false);
|
|
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 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().noneMatch(e -> e instanceof TextDisplay), "Starting a brew does not create soup immediately");
|
|
check(visualItems(pot).size() == 4, "Brewing retains four animated ingredient entities");
|
|
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);
|
|
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");
|
|
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(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");
|
|
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");
|
|
// 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() 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");
|
|
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");
|
|
}
|
|
}
|