Migrate AstraSoups to NeoForge as AstraCauldron

This commit is contained in:
2026-09-08 19:44:45 +03:00
parent 8391dfe739
commit a82c2aa0f9
52 changed files with 2095 additions and 2010 deletions
+14 -9
View File
@@ -5,21 +5,26 @@ import net.minecraft.client.renderer.item.ItemModels;
import net.minecraft.client.color.item.ItemTintSources;
import net.minecraft.client.resources.model.cuboid.CuboidModel;
import java.nio.file.*;
import java.util.zip.ZipFile;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
// Run with the Minecraft 26.2 client and its libraries on the classpath.
class CheckSoupModels {
public static void main(String[] args) throws Exception {
ItemModels.bootstrap();
ItemTintSources.bootstrap();
Path assets = Path.of(args[0]);
try (var reader = Files.newBufferedReader(assets.resolve("items/combined_soup.json"))) {
ClientItem item = ClientItem.CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow();
System.out.println("PASS: Minecraft 26.2 decodes composite bowl and custom model color tint: " + item.model());
}
try (var reader = Files.newBufferedReader(assets.resolve("models/item/soup_liquid.json"))) {
CuboidModel model = CuboidModel.fromStream(reader);
if (model.geometry() == null || model.transforms() == null) throw new AssertionError("Missing geometry/transforms");
System.out.println("PASS: Minecraft 26.2 decodes liquid geometry and item display transforms");
try (var zip = new ZipFile(args[0])) {
for (String name : new String[]{"assets/astradev_soups/items/combined_soup.json", "assets/astraplus/items/colored_water.json",
"assets/astradev_soups/models/item/soup_liquid.json", "assets/astraplus/models/internal/colored_water.json"}) {
var entry = zip.getEntry(name);
if (entry == null) throw new AssertionError("Missing packed model " + name);
try (var reader = new InputStreamReader(zip.getInputStream(entry), StandardCharsets.UTF_8)) {
if (name.contains("/items/")) ClientItem.CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow();
else if (CuboidModel.fromStream(reader).geometry() == null) throw new AssertionError("Missing geometry " + name);
System.out.println("PASS Minecraft 26.2 model decoder: " + name);
}
}
}
}
}
+6 -2
View File
@@ -1,6 +1,10 @@
param([string]$MinecraftDirectory = "$env:APPDATA/.minecraft")
param([string]$MinecraftDirectory = "$env:APPDATA/.minecraft", [string]$ResourcePack)
$ErrorActionPreference = 'Stop'
$repo = Split-Path $PSScriptRoot -Parent
if (!$ResourcePack) {
$run = (Get-Content -LiteralPath "$repo/build/active-verification.txt" -Raw).Trim()
$ResourcePack = Join-Path $run 'astraplus/output/AstraPlus.zip'
}
$version = Get-Content -Raw -LiteralPath "$MinecraftDirectory/versions/26.2/26.2.json" | ConvertFrom-Json
$classpath = @("$MinecraftDirectory/versions/26.2/26.2.jar") + @(
$version.libraries | Where-Object { $_.downloads.artifact.path } | ForEach-Object {
@@ -11,7 +15,7 @@ New-Item -ItemType Directory -Force -Path "$repo/build" | Out-Null
$arguments = @(
'--class-path', ('"' + (($classpath -join ';').Replace('\', '/')) + '"'),
('"' + "$PSScriptRoot/CheckSoupModels.java".Replace('\', '/') + '"'),
('"' + "$repo/src/main/resources/astra-itemsadder/astradev_soups/resourcepack/assets/astradev_soups".Replace('\', '/') + '"')
('"' + $ResourcePack.Replace('\', '/') + '"')
)
$argumentFile = "$repo/build/check-models.args"
Set-Content -Encoding utf8 -LiteralPath $argumentFile -Value $arguments
-5
View File
@@ -1,5 +0,0 @@
name: SoupSmokeTest
version: '1.0'
main: smoke.SoupSmokeTest
api-version: '26.2'
depend: [AstraSoups]
-328
View File
@@ -1,328 +0,0 @@
package smoke;
import online.astradev.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() {
new org.bukkit.scheduler.BukkitRunnable() {
int attempts;
@Override public void run() {
String phase = Files.exists(getDataFolder().toPath().resolve("phase1.txt")) ? "phase2" : "phase1";
try {
if (phase.equals("phase1")) {
var ia = Bukkit.getPluginManager().getPlugin("ItemsAdder");
var api = Class.forName("dev.lone.itemsadder.api.ItemsAdder", true, ia.getClass().getClassLoader());
if (!(boolean) api.getMethod("areItemsLoaded").invoke(null)
|| !Files.exists(Path.of("plugins/ItemsAdder/output/generated.zip"))) {
if (++attempts < 180) return;
throw new IllegalStateException("ItemsAdder pack did not become ready");
}
}
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);
cancel();
Bukkit.shutdown();
}
}.runTaskTimer(this, 40, 20);
}
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);
check(!stack.hasData(DataComponentTypes.CUSTOM_MODEL_DATA), "Vanilla soup keeps its original icon: " + 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");
check(soup.getData(DataComponentTypes.ITEM_MODEL).asString().equals("astradev_soups:combined_soup"), "Combined soup selects the bundled colored bowl model");
ItemStack legacyIcon = soup.clone();
legacyIcon.resetData(DataComponentTypes.ITEM_MODEL);
legacyIcon.unsetData(DataComponentTypes.CUSTOM_MODEL_DATA);
check(Ingredients.normalize(legacyIcon) && legacyIcon.isSimilar(soup), "Old soup icon migrates while retaining all recipe components");
check(!Ingredients.normalize(legacyIcon), "Icon migration is idempotent");
ItemStack extendedData = soup.clone();
extendedData.setData(DataComponentTypes.CUSTOM_MODEL_DATA,
io.papermc.paper.datacomponent.item.CustomModelData.customModelData()
.addFloat(42).addFlag(true).addString("keep").addColor(Color.BLACK).addColor(Color.BLUE).build());
Ingredients.normalize(extendedData);
var retained = extendedData.getData(DataComponentTypes.CUSTOM_MODEL_DATA);
check(retained.floats().equals(List.of(42f)) && retained.flags().equals(List.of(true))
&& retained.strings().equals(List.of("keep")) && retained.colors().get(1).equals(Color.BLUE),
"Icon migration preserves unrelated custom model data slots");
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");
check(colorExample.getData(DataComponentTypes.CUSTOM_MODEL_DATA).colors().getFirst().asRGB() == 0x9D7965, "Bowl liquid tint uses exactly the cauldron mixed 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");
check(!redSoup.getData(DataComponentTypes.CUSTOM_MODEL_DATA).colors()
.equals(orangeSoup.getData(DataComponentTypes.CUSTOM_MODEL_DATA).colors()), "Different mixtures have different icon tints");
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");
}
}
+50
View File
@@ -0,0 +1,50 @@
param(
[string]$ServerDirectory = 'C:/Users/ScarPC/Documents/NeoForge Server 26.2',
[string]$Java = 'java',
[int]$Port = 25639
)
$ErrorActionPreference = 'Stop'
$repo = Split-Path $PSScriptRoot -Parent
$plus = Join-Path (Split-Path $repo -Parent) 'AstraPlus'
$run = Join-Path $repo ('build/verification-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,6))
New-Item -ItemType Directory -Path (Join-Path $run 'mods') -Force | Out-Null
foreach ($jar in @("$plus/build/libs/AstraPlus-0.5.1.jar", "$repo/build/libs/AstraCauldron-0.2.0.jar", "$repo/build/libs/AstraCauldron-0.2.0-verification.jar")) {
Copy-Item -LiteralPath $jar -Destination (Join-Path $run 'mods')
}
$serverRoot = (Resolve-Path -LiteralPath $ServerDirectory).Path.Replace('\','/')
$argsLines = Get-Content -LiteralPath "$ServerDirectory/libraries/net/neoforged/neoforge/26.2.0.79/win_args.txt"
$argsText = (@(foreach ($line in $argsLines) {
if ($line -eq '-DlibraryDirectory=libraries') { '"-DlibraryDirectory=' + $serverRoot + '/libraries"' }
elseif ($line.StartsWith('libraries/')) { '"' + $line.Replace('libraries/', "$serverRoot/libraries/") + '"' }
else { $line }
}) -join "`n")
[IO.File]::WriteAllText((Join-Path $run 'server-args.txt'), $argsText, [Text.UTF8Encoding]::new($false))
[IO.File]::WriteAllText((Join-Path $run 'eula.txt'), 'eula=true')
$properties = @"
server-ip=127.0.0.1
server-port=$Port
online-mode=false
level-type=minecraft:flat
generator-settings={"layers":[{"block":"minecraft:bedrock","height":1},{"block":"minecraft:dirt","height":2},{"block":"minecraft:grass_block","height":1}],"biome":"minecraft:plains"}
generate-structures=false
spawn-protection=0
view-distance=2
simulation-distance=2
max-tick-time=90000
use-native-transport=false
motd=AstraCauldron isolated verification
"@
[IO.File]::WriteAllText((Join-Path $run 'server.properties'), $properties)
Set-Content -LiteralPath "$repo/build/active-verification.txt" -Value $run
Push-Location $run
try {
foreach ($phase in @('gameplay','restart')) {
& $Java '-Xms256M' '-Xmx1G' '-Dastracauldron.isolatedVerification=true' '@server-args.txt' nogui *> "$phase.log"
if ($LASTEXITCODE -ne 0) { throw "Server failed: $run/$phase.log" }
$result = Get-Content -LiteralPath 'verification-result.txt' -Raw
if ($result -match '(?m)^FAIL' -or $result -notmatch "PASS ${phase}:") { throw "Verification failed: $run/verification-result.txt" }
Copy-Item -LiteralPath 'verification-result.txt' -Destination "$phase-result.txt"
Write-Output (($result -split "`n")[-1])
}
} finally { Pop-Location }
Write-Output "Verified both launches: $run"