Configure cauldron operations brewing consumption and feedback
This commit is contained in:
@@ -91,13 +91,13 @@ public final class LiquidPots implements AutoCloseable {
|
||||
return true;
|
||||
}
|
||||
var dye = api.mixDye(OptionalInt.empty(), held);
|
||||
if (state.is(Blocks.WATER_CAULDRON) && dye.isPresent()) {
|
||||
if (AstraCauldron.config().dyeWater && state.is(Blocks.WATER_CAULDRON) && dye.isPresent()) {
|
||||
var next = new Liquid(state.getValue(LayeredCauldronBlock.LEVEL), dye.getAsInt(), null);
|
||||
if (!change(pos, next)) { error(player); return true; }
|
||||
held.consume(1, player); setVisual(level, pos, next);
|
||||
say(player, "Вода окрашена. Окуните кожаную броню, шерсть или ковры; красители можно смешивать."); return true;
|
||||
}
|
||||
if (state.is(Blocks.CAULDRON) && potion.isPresent()) {
|
||||
if (AstraCauldron.config().storePotions && state.is(Blocks.CAULDRON) && potion.isPresent()) {
|
||||
var next = new Liquid(1, potion.get().contents().getColor() & 0xFFFFFF, potion.get());
|
||||
if (!change(pos, next)) { error(player); return true; }
|
||||
consumeAndGive(player, 1, new ItemStack(Items.GLASS_BOTTLE)); setVisual(level, pos, next);
|
||||
@@ -107,13 +107,13 @@ public final class LiquidPots implements AutoCloseable {
|
||||
}
|
||||
if (liquid.potion == null) {
|
||||
var dye = api.mixDye(OptionalInt.of(liquid.rgb), held);
|
||||
if (dye.isPresent()) {
|
||||
if (AstraCauldron.config().dyeWater && dye.isPresent()) {
|
||||
var next = new Liquid(liquid.levels, dye.getAsInt(), null);
|
||||
if (!change(pos, next)) { error(player); return true; }
|
||||
held.consume(1, player); setVisual(level,pos,next); return true;
|
||||
}
|
||||
var blocks = api.dyeBlocks(held, liquid.rgb, liquid.levels);
|
||||
if (blocks.isPresent()) {
|
||||
if (AstraCauldron.config().dyeBlocks && blocks.isPresent()) {
|
||||
var batch = blocks.get(); var result = batch.result();
|
||||
if (!decrease(level,pos,liquid,batch.levelsUsed())) { error(player); return true; }
|
||||
int count = result.getCount();
|
||||
@@ -121,7 +121,7 @@ public final class LiquidPots implements AutoCloseable {
|
||||
say(player,"Окрашено предметов: " + count + "."); return true;
|
||||
}
|
||||
var armor = api.dyeArmor(held, liquid.rgb);
|
||||
if (armor.isPresent()) {
|
||||
if (AstraCauldron.config().dyeArmor && armor.isPresent()) {
|
||||
if (!decrease(level,pos,liquid,1)) { error(player); return true; }
|
||||
// Transform the equipped item, including Creative, preserving enchantments/damage/name.
|
||||
if (held.getCount() == 1) player.setItemInHand(hand, armor.get()); else consumeAndGive(player,1,armor.get());
|
||||
@@ -143,6 +143,7 @@ public final class LiquidPots implements AutoCloseable {
|
||||
say(player,"Цветная вода: " + liquid.levels + "/3. Для варки супа нужна чистая вода."); return true;
|
||||
}
|
||||
if (potion.isPresent()) {
|
||||
if (!AstraCauldron.config().storePotions) return true;
|
||||
if (!potion.get().equals(liquid.potion)) { say(player,"В котле другое зелье. Сначала заберите его бутылочками."); return true; }
|
||||
if (liquid.levels == 3) { say(player,"Котёл уже полон."); return true; }
|
||||
var next = liquid.withLevels(liquid.levels + 1);
|
||||
@@ -155,7 +156,7 @@ public final class LiquidPots implements AutoCloseable {
|
||||
consumeAndGive(player,1,bottle); sound(level,blockPos); return true;
|
||||
}
|
||||
var arrows = api.tipArrows(held,liquid.potion,liquid.levels);
|
||||
if (arrows.isPresent()) {
|
||||
if (AstraCauldron.config().tipArrows && arrows.isPresent()) {
|
||||
var batch = arrows.get(); var result = batch.result();
|
||||
if (!decrease(level,pos,liquid,batch.levelsUsed())) { error(player); return true; }
|
||||
int count = result.getCount();
|
||||
@@ -197,7 +198,7 @@ public final class LiquidPots implements AutoCloseable {
|
||||
player.getInventory().add(result); if(!result.isEmpty()) player.drop(result,false);
|
||||
player.containerMenu.broadcastChanges();
|
||||
}
|
||||
private static void sound(ServerLevel level,BlockPos pos) { level.playSound(null,pos,SoundEvents.BOTTLE_FILL,SoundSource.BLOCKS,.8f,1); }
|
||||
private static void say(ServerPlayer player,String text) { player.sendSystemMessage(Component.literal(text).withStyle(ChatFormatting.GOLD),true); }
|
||||
private static void sound(ServerLevel level,BlockPos pos) { var config = AstraCauldron.config(); if (config.sounds) level.playSound(null,pos,SoundEvents.BOTTLE_FILL,SoundSource.BLOCKS,config.soundVolume,1); }
|
||||
private static void say(ServerPlayer player,String text) { var config = AstraCauldron.config(); if (config.messages) player.sendSystemMessage(Component.literal(config.messageOverrides.getOrDefault(text,text)).withStyle(ChatFormatting.GOLD),true); }
|
||||
private static void error(ServerPlayer player) { say(player,"Не удалось сохранить котёл. Действие отменено."); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user