Require lit campfires for soup cooking and bubble heated cauldrons
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
|
||||
## Режимы котла
|
||||
|
||||
Суп варится только над горящим костром непосредственно под котлом; костёр душ тоже подходит.
|
||||
Тушение или удаление костра приостанавливает приготовление без потери ингредиентов.
|
||||
Повторное разжигание продолжает варку. Нагретая вода бурлит даже без ингредиентов.
|
||||
Готовые порции можно забирать без огня. При перезапуске незаконченная варка, как и раньше,
|
||||
начинает отсчёт заново и ждёт горящего костра.
|
||||
|
||||
В версии 0.2.2 обычные котлы выполняют рецепты из вкладки «Рецепты» AstraPlusEditor:
|
||||
предмет и его количество, тип жидкости, точный уровень, расход и результат. Определения принадлежат AstraPlus,
|
||||
а расход и выдача — AstraCauldron. Супы, цветная вода и сохранённые зелья сохраняют свои правила.
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
||||
id("net.neoforged.moddev") version "2.0.146"
|
||||
}
|
||||
group = "online.astradev"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
repositories { mavenCentral() }
|
||||
val astraPlusApi = providers.gradleProperty("astraPlusApi")
|
||||
.orElse("../AstraPlus/build/libs/AstraPlus-0.5.9-api.jar")
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package online.astradev.cauldron;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CampfireBlock;
|
||||
import net.minecraft.world.level.block.LayeredCauldronBlock;
|
||||
|
||||
/** Uses the existing campfire ticker; no scanning worlds or spawning persistent effects. */
|
||||
public final class CauldronHeat {
|
||||
private CauldronHeat() {}
|
||||
public static boolean heated(LevelReader level, BlockPos cauldron) {
|
||||
var below = cauldron.below();
|
||||
if (!level.hasChunkAt(below)) return false;
|
||||
var state = level.getBlockState(below);
|
||||
return state.getBlock() instanceof CampfireBlock && state.getValue(CampfireBlock.LIT);
|
||||
}
|
||||
public static void tick(ServerLevel level, BlockPos campfire) {
|
||||
var pos = campfire.above();
|
||||
if ((level.getGameTime() + pos.asLong()) % 10 != 0 || !heated(level, pos)) return;
|
||||
var state = level.getBlockState(pos);
|
||||
double surface;
|
||||
if (state.is(Blocks.WATER_CAULDRON)) surface = .375 + .1875 * state.getValue(LayeredCauldronBlock.LEVEL);
|
||||
else {
|
||||
var pot = AstraCauldron.pots() == null ? null : AstraCauldron.pots().get(level, pos);
|
||||
if (!state.is(Blocks.CAULDRON) || pot == null || pot.soup().isEmpty() || pot.brewTicks() > 0) return;
|
||||
surface = CauldronAnimation.liquidHeight(pot.servings(), pot.capacity());
|
||||
}
|
||||
level.sendParticles(ParticleTypes.BUBBLE_POP, pos.getX() + .5, pos.getY() + surface + .01, pos.getZ() + .5, 4, .18, .015, .18, 0);
|
||||
level.sendParticles(ParticleTypes.SPLASH, pos.getX() + .5, pos.getY() + surface + .02, pos.getZ() + .5, 2, .16, 0, .16, 0);
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public final class SoupPots implements AutoCloseable {
|
||||
}
|
||||
pot = Pot.raw(List.of());
|
||||
}
|
||||
if (pot.brewing()) { say(player, "Суп варится… Осталось: " + Math.max(1, (pot.brewTicks - elapsed.getOrDefault(pos, 0) + 19) / 20) + " с."); return true; }
|
||||
if (pot.brewing()) { say(player, CauldronHeat.heated(level, blockPos) ? "Суп варится… Осталось: " + Math.max(1, (pot.brewTicks - elapsed.getOrDefault(pos, 0) + 19) / 20) + " с." : "Варка приостановлена. Зажгите костёр под котлом."); return true; }
|
||||
if (pot.ready()) {
|
||||
if (!held.is(Items.BOWL)) { say(player, "Суп готов. Порций: " + pot.servings + ". Возьмите его миской — ПКМ."); return true; }
|
||||
int left = pot.servings - 1; var result = pot.soup.copy();
|
||||
@@ -149,6 +149,7 @@ public final class SoupPots implements AutoCloseable {
|
||||
say(player, left == 0 ? "Последняя порция собрана. Котёл пуст." : "Осталось порций: " + left + "."); return true;
|
||||
}
|
||||
if (pot.items.size() == 4 && (player.isShiftKeyDown() || !held.isEmpty())) {
|
||||
if (!CauldronHeat.heated(level, blockPos)) { say(player, "Для варки нужен горящий костёр прямо под котлом."); return true; }
|
||||
String rejection = ingredients.rejection(pot.items);
|
||||
if (rejection != null) { say(player, rejection + " ПКМ пустой рукой возвращает последний ингредиент."); return true; }
|
||||
var next = new Pot(pot.items, ingredients.brew(pot.items), (int)Math.round(config.brewSeconds * 20), config.servingsPerBrew, config.servingsPerBrew);
|
||||
@@ -185,7 +186,8 @@ public final class SoupPots implements AutoCloseable {
|
||||
var level = server.getLevel(ResourceKey.create(Registries.DIMENSION, Identifier.parse(pos.dimension)));
|
||||
if (level == null || !level.hasChunkAt(pos.pos)) { removeVisuals(pos); continue; }
|
||||
if (!valid(level.getBlockState(pos.pos), pot)) { breakPot(level, pos.pos); continue; }
|
||||
if (pot.brewing()) {
|
||||
boolean heated = CauldronHeat.heated(level, pos.pos);
|
||||
if (pot.brewing() && heated) {
|
||||
int time = elapsed.merge(pos, 1, Integer::sum);
|
||||
if (time >= pot.brewTicks && (time - pot.brewTicks) % 20 == 0
|
||||
&& change(pos, new Pot(List.of(), pot.soup, 0, pot.servings, pot.capacity))) {
|
||||
@@ -199,9 +201,7 @@ public final class SoupPots implements AutoCloseable {
|
||||
if (ticks % 2 == 0 && !pot.ready()) {
|
||||
var displays = visuals.get(pos);
|
||||
int water = level.getBlockState(pos.pos).getValue(LayeredCauldronBlock.LEVEL);
|
||||
for (int i = 0; i < displays.size(); i++) displays.get(i).ingredient(i, water, ticks + 2, elapsed.getOrDefault(pos, 0) + 2, pot.brewTicks);
|
||||
if (pot.brewing() && ticks % 10 == 0)
|
||||
level.sendParticles(ParticleTypes.SPLASH, pos.pos.getX() + .5, pos.pos.getY() + .95, pos.pos.getZ() + .5, 2, .2, 0, .2, 0);
|
||||
for (int i = 0; i < displays.size(); i++) displays.get(i).ingredient(i, water, ticks + 2, elapsed.getOrDefault(pos, 0) + (heated ? 2 : 0), pot.brewTicks);
|
||||
}
|
||||
}
|
||||
if (ticks % 20 == 0) for (var player : server.getPlayerList().getPlayers()) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package online.astradev.cauldron.mixin;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.crafting.*;
|
||||
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(CampfireBlockEntity.class)
|
||||
public abstract class CampfireHeatMixin {
|
||||
@Inject(method = "cookTick", at = @At("TAIL"))
|
||||
private static void astracauldron$heat(ServerLevel level, BlockPos pos, BlockState state, CampfireBlockEntity entity,
|
||||
RecipeManager.CachedCheck<SingleRecipeInput, CampfireCookingRecipe> recipes, CallbackInfo ci) {
|
||||
online.astradev.cauldron.CauldronHeat.tick(level, pos);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
"required": true,
|
||||
"package": "online.astradev.cauldron.mixin",
|
||||
"compatibilityLevel": "JAVA_25",
|
||||
"server": ["CauldronWeatherMixin", "LayeredCauldronMixin", "SoupStackMixin"],
|
||||
"server": ["CauldronWeatherMixin", "LayeredCauldronMixin", "SoupStackMixin", "CampfireHeatMixin"],
|
||||
"injectors": {"defaultRequire": 1}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,18 @@ public final class SoupVerification {
|
||||
checkLiquids(level);
|
||||
fill(level, READY); for (int i = 0; i < 4; i++) use(READY, new ItemStack(Items.CARROT));
|
||||
use(READY, new ItemStack(Items.BOWL));
|
||||
require(AstraCauldron.pots().get(level, READY).soup().isEmpty(), "cannot brew without campfire; ingredients preserved");
|
||||
level.setBlock(READY.below(), Blocks.CAMPFIRE.defaultBlockState().setValue(net.minecraft.world.level.block.CampfireBlock.LIT, false), 3);
|
||||
use(READY, new ItemStack(Items.BOWL));
|
||||
require(AstraCauldron.pots().get(level, READY).soup().isEmpty(), "unlit campfire cannot start soup");
|
||||
level.setBlock(READY.below(), Blocks.CAMPFIRE.defaultBlockState(), 3);
|
||||
use(READY, new ItemStack(Items.BOWL));
|
||||
require(AstraCauldron.pots().get(level, READY).brewTicks() > 0, "four ingredients start timed brew");
|
||||
level.setBlock(READY.below(), Blocks.AIR.defaultBlockState(), 3);
|
||||
for (int i = 0; i < 100; i++) AstraCauldron.pots().tick();
|
||||
require(AstraCauldron.pots().get(level, READY).brewTicks() > 0, "removing fire pauses cooking beyond full duration");
|
||||
level.setBlock(READY.below(), Blocks.SOUL_CAMPFIRE.defaultBlockState(), 3);
|
||||
require(online.astradev.cauldron.CauldronHeat.heated(level, READY), "soul campfire resumes heating");
|
||||
require(displays(level, READY).size() == 4, "four ingredient displays while brewing");
|
||||
require(displays(level, READY).stream().noneMatch(Display::shouldBeSaved), "ingredient displays never persist as entities");
|
||||
}
|
||||
@@ -97,7 +108,8 @@ public final class SoupVerification {
|
||||
require(AstraCauldron.pots().get(level, READY).servings() == 2, "two saved servings remain");
|
||||
checkSaveFailure(server, level);
|
||||
fill(level, RAW); use(RAW, new ItemStack(Items.APPLE));
|
||||
fill(level, BREW); for (int i = 0; i < 4; i++) use(BREW, new ItemStack(Items.BREAD)); use(BREW, new ItemStack(Items.BOWL));
|
||||
fill(level, BREW); level.setBlock(BREW.below(), Blocks.CAMPFIRE.defaultBlockState(), 3);
|
||||
for (int i = 0; i < 4; i++) use(BREW, new ItemStack(Items.BREAD)); use(BREW, new ItemStack(Items.BOWL));
|
||||
try (var zip = new ZipFile("astraplus/output/AstraPlus.zip")) {
|
||||
require(zip.getEntry("assets/astraplus/items/colored_water.json") != null, "AstraPlus packs its own water resource");
|
||||
require(zip.getEntry("assets/astradev_soups/items/combined_soup.json") != null, "AstraCauldron bowl exported before AstraPlus pack build");
|
||||
|
||||
@@ -8,7 +8,9 @@ $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")) {
|
||||
$plusVersion = [regex]::Match((Get-Content "$plus/build.gradle.kts" -Raw), '(?m)^version = "([^"]+)"').Groups[1].Value
|
||||
$cauldronVersion = [regex]::Match((Get-Content "$repo/build.gradle.kts" -Raw), '(?m)^version = "([^"]+)"').Groups[1].Value
|
||||
foreach ($jar in @("$plus/build/libs/AstraPlus-$plusVersion.jar", "$repo/build/libs/AstraCauldron-$cauldronVersion.jar", "$repo/build/libs/AstraCauldron-$cauldronVersion-verification.jar")) {
|
||||
Copy-Item -LiteralPath $jar -Destination (Join-Path $run 'mods')
|
||||
}
|
||||
$serverRoot = (Resolve-Path -LiteralPath $ServerDirectory).Path.Replace('\','/')
|
||||
|
||||
Reference in New Issue
Block a user