Retroactively limit amount of fluid in overfilled water crucibles
This commit is contained in:
parent
ff4a00c609
commit
95cde6fb2d
|
|
@ -52,6 +52,7 @@ import net.minecraftforge.items.ItemStackHandler;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thedarkcolour.exdeorum.blockentity.helper.FluidHelper;
|
||||
import thedarkcolour.exdeorum.config.EConfig;
|
||||
import thedarkcolour.exdeorum.recipe.crucible.CrucibleRecipe;
|
||||
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
||||
|
|
@ -291,7 +292,7 @@ public abstract class AbstractCrucibleBlockEntity extends EBlockEntity {
|
|||
}
|
||||
}
|
||||
|
||||
private static class FluidHandler extends FluidTank {
|
||||
private static class FluidHandler extends FluidHelper {
|
||||
public FluidHandler() {
|
||||
super(4_000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@ import net.minecraftforge.fluids.FluidType;
|
|||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import thedarkcolour.exdeorum.block.BarrelBlock;
|
||||
import thedarkcolour.exdeorum.blockentity.helper.FluidHelper;
|
||||
import thedarkcolour.exdeorum.client.CompostColors;
|
||||
import thedarkcolour.exdeorum.config.EConfig;
|
||||
import thedarkcolour.exdeorum.recipe.RecipeUtil;
|
||||
|
|
@ -604,7 +604,7 @@ public class BarrelBlockEntity extends EBlockEntity {
|
|||
}
|
||||
|
||||
// Inner class
|
||||
private class FluidHandler extends FluidTank {
|
||||
private class FluidHandler extends FluidHelper {
|
||||
public FluidHandler() {
|
||||
super(1000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,18 +25,6 @@ public class EnergyHelper extends EnergyStorage {
|
|||
super(capacity);
|
||||
}
|
||||
|
||||
public EnergyHelper(int capacity, int maxTransfer) {
|
||||
super(capacity, maxTransfer);
|
||||
}
|
||||
|
||||
public EnergyHelper(int capacity, int maxReceive, int maxExtract) {
|
||||
super(capacity, maxReceive, maxExtract);
|
||||
}
|
||||
|
||||
public EnergyHelper(int capacity, int maxReceive, int maxExtract, int energy) {
|
||||
super(capacity, maxReceive, maxExtract, energy);
|
||||
}
|
||||
|
||||
public void setStoredEnergy(int energy) {
|
||||
this.energy = energy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Ex Deorum
|
||||
* Copyright (c) 2024 thedarkcolour
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package thedarkcolour.exdeorum.blockentity.helper;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
// Only changed behavior from FluidTank is that fluid stacks read from NBT are clamped and removed validator predicate.
|
||||
public class FluidHelper extends FluidTank {
|
||||
public FluidHelper(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank readFromNBT(CompoundTag nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.fluid.setAmount(Math.min(this.capacity, this.fluid.getAmount()));
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ import net.minecraftforge.items.ItemStackHandler;
|
|||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// Has same behavior as ItemStackHandler but is more customizable.
|
||||
public class ItemHelper extends ItemStackHandler {
|
||||
public ItemHelper(int size) {
|
||||
super(size);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user