Fix barrel fluid transformations not happening when it is raining
This commit is contained in:
parent
e6c9040d50
commit
f61a2974c0
|
|
@ -1,4 +1,4 @@
|
|||
// 1.20.1 2024-04-06T19:57:06.8812402 Recipes
|
||||
// 1.20.1 2024-05-21T11:17:56.5956994 Recipes
|
||||
825a24c8f9f1feb2d92e9a5d43b4445275f98a4d data/exdeorum/advancements/recipes/building_blocks/compressed_crushed_blackstone.json
|
||||
ee98248148569129e0d4e14d7de03108e51a6dac data/exdeorum/advancements/recipes/building_blocks/compressed_crushed_deepslate.json
|
||||
b7ee636abe5154ab8bb5a6ad5cde13ea8375ae3e data/exdeorum/advancements/recipes/building_blocks/compressed_crushed_end_stone.json
|
||||
|
|
@ -156,6 +156,7 @@ f6ee5b900f693e7839961e26fa690b1df4eaa893 data/exdeorum/recipes/barrel_compost/de
|
|||
fea2a11e64ae425b6dcc29480e9793fad877792b data/exdeorum/recipes/barrel_compost/egg.json
|
||||
09f8e54e4112aa8f163967130087c9a24f9d03a0 data/exdeorum/recipes/barrel_compost/fermented_spider_eye.json
|
||||
79bbe21466b4700c57cdcaeb15ebc5af741eafd4 data/exdeorum/recipes/barrel_compost/golden_apples.json
|
||||
586b6dbbd6285fcc2696dd98676c1b73d1d8e590 data/exdeorum/recipes/barrel_compost/golden_carrot.json
|
||||
7e4e8500b94b97fded88c19b66b5c4f2fa8c3b38 data/exdeorum/recipes/barrel_compost/grass.json
|
||||
48e6e1cb9f5a9208a6f6110328c592a087a0c04d data/exdeorum/recipes/barrel_compost/kelp.json
|
||||
dbc452bd95428da7c2c44fe0f2f55c04a0939e25 data/exdeorum/recipes/barrel_compost/leaves.json
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ public abstract class AbstractCrucibleBlockEntity extends EBlockEntity {
|
|||
return map;
|
||||
});
|
||||
|
||||
public static final int MAX_SOLIDS = 1_000;
|
||||
private static final int MAX_SOLIDS = 1000;
|
||||
private static final int MAX_FLUID_CAPACITY = 4000;
|
||||
|
||||
private final AbstractCrucibleBlockEntity.ItemHandler item = new AbstractCrucibleBlockEntity.ItemHandler();
|
||||
private final AbstractCrucibleBlockEntity.FluidHandler tank = new AbstractCrucibleBlockEntity.FluidHandler();
|
||||
|
|
@ -298,7 +299,7 @@ public abstract class AbstractCrucibleBlockEntity extends EBlockEntity {
|
|||
|
||||
private static class FluidHandler extends FluidHelper {
|
||||
public FluidHandler() {
|
||||
super(4_000);
|
||||
super(MAX_FLUID_CAPACITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -339,32 +340,34 @@ public abstract class AbstractCrucibleBlockEntity extends EBlockEntity {
|
|||
}
|
||||
// Update twice per tick
|
||||
if (!level.isClientSide) {
|
||||
var tank = crucible.tank;
|
||||
|
||||
if ((level.getGameTime() % 10L) == 0L) {
|
||||
short delta = (short) Math.min(crucible.solids, crucible.getMeltingRate());
|
||||
|
||||
// Skip if no heat
|
||||
if (delta <= 0) return;
|
||||
|
||||
if (crucible.tank.getSpace() >= delta) {
|
||||
if (tank.getSpace() >= delta) {
|
||||
// Remove solids
|
||||
crucible.solids -= delta;
|
||||
|
||||
// Add lava
|
||||
if (crucible.tank.isEmpty()) {
|
||||
if (tank.isEmpty()) {
|
||||
if (crucible.fluid != null) {
|
||||
crucible.tank.setFluid(new FluidStack(crucible.fluid, delta));
|
||||
tank.setFluid(new FluidStack(crucible.fluid, delta));
|
||||
crucible.needsLightUpdate = true;
|
||||
}
|
||||
} else {
|
||||
crucible.tank.getFluid().grow(delta);
|
||||
tank.getFluid().grow(delta);
|
||||
}
|
||||
|
||||
// Sync to client
|
||||
crucible.markUpdated();
|
||||
}
|
||||
}
|
||||
if (crucible instanceof WaterCrucibleBlockEntity && level.isRainingAt(pos.above())) {
|
||||
BarrelBlockEntity.fillRainWater(crucible, crucible.tank);
|
||||
if (tank.getFluidAmount() < MAX_FLUID_CAPACITY && crucible instanceof WaterCrucibleBlockEntity && level.isRainingAt(pos.above())) {
|
||||
BarrelBlockEntity.fillRainWater(crucible, tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ import thedarkcolour.exdeorum.recipe.RecipeUtil;
|
|||
import thedarkcolour.exdeorum.recipe.barrel.BarrelFluidMixingRecipe;
|
||||
import thedarkcolour.exdeorum.recipe.barrel.FluidTransformationRecipe;
|
||||
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
||||
import thedarkcolour.exdeorum.registry.EFluids;
|
||||
|
||||
public class BarrelBlockEntity extends EBlockEntity {
|
||||
private static final int MOSS_SPREAD_RANGE = 2;
|
||||
private static final int MAX_CAPACITY = 1000;
|
||||
|
||||
private final BarrelBlockEntity.ItemHandler item = new BarrelBlockEntity.ItemHandler();
|
||||
private final BarrelBlockEntity.FluidHandler tank = new BarrelBlockEntity.FluidHandler();
|
||||
|
|
@ -160,16 +160,16 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
}
|
||||
|
||||
public boolean isBrewing() {
|
||||
return this.tank.getFluidAmount() == 1000 && this.progress != 0.0f && !isBurning();
|
||||
return this.tank.getFluidAmount() == MAX_CAPACITY && this.progress != 0.0f && !isBurning();
|
||||
}
|
||||
|
||||
public boolean isBurning() {
|
||||
return this.getBlockState().ignitedByLava() && isHotFluid(this.tank.getFluid().getFluid().getFluidType()) && this.progress != 0.0f;
|
||||
}
|
||||
|
||||
// Composting is in progress if at 1000. When finished, compost is set back to 0
|
||||
// Composting is in progress if at MAX_CAPACITY. When finished, compost is set back to 0
|
||||
public boolean isComposting() {
|
||||
return this.compost == 1000;
|
||||
return this.compost == MAX_CAPACITY;
|
||||
}
|
||||
|
||||
// Returns true if there are no solid ingredients (can a fluid be inserted?)
|
||||
|
|
@ -178,7 +178,7 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
}
|
||||
|
||||
public boolean hasFullWater() {
|
||||
return this.tank.getFluidAmount() == 1000 && this.tank.getFluid().getFluid().is(FluidTags.WATER);
|
||||
return this.tank.getFluidAmount() == MAX_CAPACITY && this.tank.getFluid().getFluid().is(FluidTags.WATER);
|
||||
}
|
||||
|
||||
// Burning temp of wood according to google is 300 C or ~575 kelvin
|
||||
|
|
@ -408,7 +408,7 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
|
||||
private void addCompost(ItemStack playerItem, int volume) {
|
||||
int oldCompost = this.compost;
|
||||
this.compost = (short) Math.min(1000, this.compost + volume);
|
||||
this.compost = (short) Math.min(MAX_CAPACITY, this.compost + volume);
|
||||
|
||||
if (this.compost != 0) {
|
||||
if (!CompostColors.isLoaded()) {
|
||||
|
|
@ -465,10 +465,10 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
|
||||
public void updateFluidTransform() {
|
||||
if (!this.level.isClientSide) {
|
||||
var belowState = this.level.getBlockState(this.worldPosition.below());
|
||||
if (this.tank.getFluidAmount() != 1000) {
|
||||
if (this.tank.getFluidAmount() != MAX_CAPACITY) {
|
||||
this.currentTransformRecipe = null;
|
||||
} else {
|
||||
var belowState = this.level.getBlockState(this.worldPosition.below());
|
||||
this.currentTransformRecipe = RecipeUtil.getFluidTransformationRecipe(this.tank.getFluid().getFluid(), belowState);
|
||||
|
||||
if (this.currentTransformRecipe != null) {
|
||||
|
|
@ -487,21 +487,20 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
@Override
|
||||
public void tick(Level level, BlockPos pos, BlockState state, BarrelBlockEntity barrel) {
|
||||
if (!level.isClientSide) {
|
||||
var tank = barrel.tank;
|
||||
// Turn compost to dirt
|
||||
if (barrel.isComposting()) {
|
||||
barrel.doCompost();
|
||||
} else if (isHotFluid(barrel.tank.getFluid().getFluid().getFluidType()) && state.ignitedByLava()) {
|
||||
} else if (isHotFluid(tank.getFluid().getFluid().getFluidType()) && state.ignitedByLava()) {
|
||||
if ((barrel.progress += getProgressStep()) >= 1.0f) {
|
||||
if (barrel.tank.getFluidAmount() == 1000) {
|
||||
var fluid = barrel.tank.getFluid().getFluid();
|
||||
if (tank.getFluidAmount() == MAX_CAPACITY) {
|
||||
var fluid = tank.getFluid().getFluid();
|
||||
level.setBlockAndUpdate(pos, fluid.getFluidType().getBlockForFluidState(level, pos, fluid.defaultFluidState()));
|
||||
} else {
|
||||
level.setBlockAndUpdate(pos, Blocks.FIRE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
barrel.markUpdated();
|
||||
} else if (level.isRainingAt(pos.above()) && barrel.item.getStackInSlot(0).isEmpty() && barrel.compost == 0) {
|
||||
fillRainWater(barrel, barrel.tank);
|
||||
} else if (barrel.currentTransformRecipe != null) {
|
||||
var recipe = barrel.currentTransformRecipe;
|
||||
var catalysts = 0;
|
||||
|
|
@ -536,13 +535,20 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
// Reset progress
|
||||
barrel.progress = 0.0f;
|
||||
level.playSound(null, pos, SoundEvents.BREWING_STAND_BREW, SoundSource.BLOCKS, 1.0f, 0.6f);
|
||||
barrel.tank.setFluid(FluidStack.EMPTY);
|
||||
barrel.tank.fill(new FluidStack(recipe.resultFluid, 1000), IFluidHandler.FluidAction.EXECUTE);
|
||||
tank.setFluid(FluidStack.EMPTY);
|
||||
tank.fill(new FluidStack(recipe.resultFluid, 1000), IFluidHandler.FluidAction.EXECUTE);
|
||||
}
|
||||
barrel.markUpdated();
|
||||
}
|
||||
} else if (tank.getFluidAmount() < MAX_CAPACITY && level.isRainingAt(pos.above()) && barrel.item.getStackInSlot(0).isEmpty() && barrel.compost == 0) {
|
||||
fillRainWater(barrel, tank);
|
||||
|
||||
// avoid checking fluid transform until full
|
||||
if (tank.getFluidAmount() == MAX_CAPACITY) {
|
||||
barrel.updateFluidTransform();
|
||||
}
|
||||
} else if (barrel.hasFullWater()) {
|
||||
if (barrel.tank.getFluid().getFluid().getFluidType() == ForgeMod.WATER_TYPE.get()) {
|
||||
if (tank.getFluid().getFluid().getFluidType() == ForgeMod.WATER_TYPE.get()) {
|
||||
var rand = level.random;
|
||||
// Leak water to create moss (only wooden barrels do this)
|
||||
if (state.ignitedByLava() && rand.nextInt(500) == 0) {
|
||||
|
|
@ -567,7 +573,7 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
if (tank.isEmpty()) {
|
||||
tank.setFluid(new FluidStack(Fluids.WATER, 1));
|
||||
block.markUpdated();
|
||||
} else if (tank.getFluid().getFluid() == Fluids.WATER && tank.getFluidAmount() < tank.getCapacity()) {
|
||||
} else if (tank.getFluid().getFluid() == Fluids.WATER) {
|
||||
tank.getFluid().grow(1);
|
||||
block.markUpdated();
|
||||
}
|
||||
|
|
@ -651,7 +657,7 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
// Inner class
|
||||
private class FluidHandler extends FluidHelper {
|
||||
public FluidHandler() {
|
||||
super(1000);
|
||||
super(MAX_CAPACITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user