mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-21 06:53:29 +01:00
Added the ability for fluid collectors to collect water and lava from filled cauldrons. Closes #1440
This commit is contained in:
parent
632c34739a
commit
ea1a072c72
4 changed files with 42 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
|||
* Fixed Farmer not playing well with non-vanilla farmland.
|
||||
* Added the ability to change the farmers work area with a compass.
|
||||
* Make blocks still drop items even when broken incorrectly.
|
||||
* Added the ability for fluid collectors to collect water and lava from filled cauldrons.
|
||||
|
||||
# 1.3.10+mc1.21.1
|
||||
* Fixed Fluid placer not being harvestable.
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.tags.TagKey;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.neoforged.neoforge.common.Tags;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -38,9 +39,10 @@ public class FuelRecipeGenerator extends RecipeProvider {
|
|||
addSolid(recipeOutput, "stick", Items.STICK, 2000, 100);
|
||||
addSolid(recipeOutput, "tiny-coal", ActuallyTags.Items.TINY_COALS, 4000, 200);
|
||||
addSolid(recipeOutput, "charcoal", Items.CHARCOAL, 32000, 1600);
|
||||
addSolid(recipeOutput, "coal-block", Items.COAL_BLOCK, 320000, 16000);
|
||||
addSolid(recipeOutput, "coal-block", Tags.Items.STORAGE_BLOCKS_COAL, 320000, 16000);
|
||||
addSolid(recipeOutput, "lava", Items.LAVA_BUCKET, 400000, 20000);
|
||||
|
||||
|
||||
recipeOutput.accept(ActuallyAdditions.modLoc("liquid_fuel/canola_oil"), new LiquidFuelRecipe(
|
||||
new FluidStack(InitFluids.CANOLA_OIL.get(), 50), 4000, 100), null);
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ import net.minecraft.world.item.crafting.RecipeType;
|
|||
import net.minecraft.world.item.crafting.SingleRecipeInput;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SolidFuelRecipe implements Recipe<SingleRecipeInput> {
|
||||
public static String NAME = "solid_fuel";
|
||||
private Ingredient itemIngredient;
|
||||
private int burnTime;
|
||||
private int totalEnergy;
|
||||
private final Ingredient itemIngredient;
|
||||
private final int burnTime;
|
||||
private final int totalEnergy;
|
||||
|
||||
public SolidFuelRecipe(Ingredient itemIngredient, int totalEnergy, int burnTime) {
|
||||
this.itemIngredient = itemIngredient;
|
||||
|
@ -35,7 +37,7 @@ public class SolidFuelRecipe implements Recipe<SingleRecipeInput> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(SingleRecipeInput pInv, Level pLevel) {
|
||||
public boolean matches(SingleRecipeInput pInv, @Nonnull Level pLevel) {
|
||||
return itemIngredient.test(pInv.getItem(0));
|
||||
}
|
||||
|
||||
|
@ -48,8 +50,9 @@ public class SolidFuelRecipe implements Recipe<SingleRecipeInput> {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack assemble(SingleRecipeInput pInv, HolderLookup.Provider registries) {
|
||||
public ItemStack assemble(@Nonnull SingleRecipeInput pInv, @Nonnull HolderLookup.Provider registries) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
@ -58,16 +61,19 @@ public class SolidFuelRecipe implements Recipe<SingleRecipeInput> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getResultItem(HolderLookup.Provider provider) {
|
||||
public ItemStack getResultItem(@Nonnull HolderLookup.Provider provider) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ActuallyRecipes.SOLID_FUEL_RECIPE.get();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return ActuallyRecipes.Types.SOLID_FUEL.get();
|
||||
|
@ -86,11 +92,13 @@ public class SolidFuelRecipe implements Recipe<SingleRecipeInput> {
|
|||
SolidFuelRecipe.Serializer::toNetwork, SolidFuelRecipe.Serializer::fromNetwork
|
||||
);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MapCodec<SolidFuelRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public StreamCodec<RegistryFriendlyByteBuf, SolidFuelRecipe> streamCodec() {
|
||||
return STREAM_CODEC;
|
||||
|
|
|
@ -31,12 +31,11 @@ import net.minecraft.world.entity.player.Inventory;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.fluids.FluidType;
|
||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||
|
@ -104,6 +103,28 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing
|
|||
BlockPos coordsBlock = this.worldPosition.relative(sideToManipulate);
|
||||
|
||||
BlockState stateToBreak = this.level.getBlockState(coordsBlock);
|
||||
|
||||
// Try cauldron
|
||||
if(stateToBreak.getBlock() instanceof AbstractCauldronBlock cauldron) {
|
||||
if (cauldron.isFull(stateToBreak)) {
|
||||
if (stateToBreak.getBlock() == Blocks.WATER_CAULDRON) {
|
||||
if (this.tank.fillInternal(new FluidStack(Fluids.WATER, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE) >= FluidType.BUCKET_VOLUME) {
|
||||
this.tank.fillInternal(new FluidStack(Fluids.WATER, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
level.setBlockAndUpdate(coordsBlock, Blocks.CAULDRON.defaultBlockState());
|
||||
level.playSound(null, coordsBlock, SoundEvents.BUCKET_FILL, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
} else if (stateToBreak.getBlock() == Blocks.LAVA_CAULDRON) {
|
||||
if (this.tank.fillInternal(new FluidStack(Fluids.LAVA, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE) >= FluidType.BUCKET_VOLUME) {
|
||||
this.tank.fillInternal(new FluidStack(Fluids.LAVA, FluidType.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
level.setBlockAndUpdate(coordsBlock, Blocks.CAULDRON.defaultBlockState());
|
||||
level.playSound(null, coordsBlock, SoundEvents.BUCKET_FILL_LAVA, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Block blockToBreak = stateToBreak.getBlock();
|
||||
if (!this.isPlacer && FluidType.BUCKET_VOLUME <= this.tank.getCapacity() - this.tank.getFluidAmount()) {
|
||||
if (blockToBreak instanceof LiquidBlock liquidBlock && liquidBlock.fluid != null && stateToBreak.getFluidState().isSource() ) {
|
||||
|
|
Loading…
Reference in a new issue