Skip to content

Implement Droopleaf (for real this time) #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: 1.20.1-aria-for-painters
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/main/java/de/dafuqs/spectrum/blocks/FluidLogging.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class FluidLogging {
public enum State implements StringIdentifiable {
NOT_LOGGED("none", 0),
WATER("water", 0),
LIQUID_CRYSTAL("liquid_crystal", LiquidCrystalFluidBlock.LUMINANCE);
LIQUID_CRYSTAL("liquid_crystal", LiquidCrystalFluidBlock.LUMINANCE),
MUD("mud",0);

private final String name;
private final int luminance;
Expand All @@ -43,19 +44,25 @@ public FluidState getFluidState() {
case WATER -> {
return Fluids.WATER.getStill(false);
}
case MUD -> {
return SpectrumFluids.MUD.getStill(false);
}
default -> {
return Fluids.EMPTY.getDefaultState();
}
}
}

public static State getForFluidState(FluidState fluidState) {
if (fluidState.getFluid() == SpectrumFluids.LIQUID_CRYSTAL) {
return LIQUID_CRYSTAL;
} else if (fluidState.getFluid() == SpectrumFluids.MUD)
{
return MUD;
} else if (fluidState.isIn(FluidTags.WATER)) {
return WATER;
}

return NOT_LOGGED;
}

Expand All @@ -80,13 +87,20 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit
if (this == State.LIQUID_CRYSTAL) {
SpectrumFluids.LIQUID_CRYSTAL.onEntityCollision(state, world, pos, entity);
}
else if (this == State.MUD) {
SpectrumFluids.MUD.onEntityCollision(state, world, pos, entity);
}
}
}

public static final EnumProperty<State> ANY_INCLUDING_NONE = EnumProperty.of("fluid_logged", State.class);
public static final EnumProperty<State> ANY_EXCLUDING_NONE = EnumProperty.of("fluid_logged", State.class, State.WATER, State.LIQUID_CRYSTAL);
public static final EnumProperty<State> ANY_EXCLUDING_NONE = EnumProperty.of("fluid_logged", State.class, State.WATER, State.LIQUID_CRYSTAL, State.MUD);
public static final EnumProperty<State> WATER_AND_CRYSTAL = EnumProperty.of("fluid_logged", State.class, State.WATER, State.LIQUID_CRYSTAL);
public static final EnumProperty<State> NONE_AND_CRYSTAL = EnumProperty.of("fluid_logged", State.class, State.NOT_LOGGED, State.LIQUID_CRYSTAL);

public static final EnumProperty<State> NONE_WATER_AND_CRYSTAL = EnumProperty.of("fluid_logged", State.class, State.NOT_LOGGED, State.WATER, State.LIQUID_CRYSTAL);
public static final EnumProperty<State> NONE_WATER_AND_MUD = EnumProperty.of("fluid_logged", State.class, State.NOT_LOGGED, State.WATER, State.MUD);


public interface SpectrumFluidLoggable extends SpectrumFluidDrainable, SpectrumFluidFillable {

}
Expand All @@ -95,7 +109,7 @@ public interface SpectrumFluidFillable extends FluidFillable {

@Override
default boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return state.get(ANY_INCLUDING_NONE) == State.NOT_LOGGED && (fluid == Fluids.WATER || fluid == SpectrumFluids.LIQUID_CRYSTAL);
return state.get(ANY_INCLUDING_NONE) == State.NOT_LOGGED && (fluid == Fluids.WATER || fluid == SpectrumFluids.LIQUID_CRYSTAL || fluid == SpectrumFluids.MUD);
}

@Override
Expand All @@ -108,6 +122,9 @@ default boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState sta
} else if (fluidState.getFluid() == SpectrumFluids.LIQUID_CRYSTAL) {
world.setBlockState(pos, state.with(ANY_INCLUDING_NONE, State.LIQUID_CRYSTAL), Block.NOTIFY_ALL);
world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
} else if (fluidState.getFluid() == SpectrumFluids.MUD) {
world.setBlockState(pos, state.with(ANY_INCLUDING_NONE, State.MUD), Block.NOTIFY_ALL);
world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
}
}

Expand Down Expand Up @@ -137,11 +154,17 @@ default ItemStack tryDrainFluid(WorldAccess world, BlockPos pos, BlockState stat
world.breakBlock(pos, true);
}
return new ItemStack(SpectrumItems.LIQUID_CRYSTAL_BUCKET);
} else if (fluidLog == State.MUD) {
world.setBlockState(pos, state.with(ANY_INCLUDING_NONE, State.NOT_LOGGED), Block.NOTIFY_ALL);
if (!state.canPlaceAt(world, pos)) {
world.breakBlock(pos, true);
}
return new ItemStack(SpectrumItems.MUD_BUCKET);
}

return ItemStack.EMPTY;
}


//TODO: Remove this when we add custom fill sounds for our fluids.
@Override
default Optional<SoundEvent> getBucketFillSound() {
return Fluids.WATER.getBucketFillSound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MermaidsBrushBlock extends PlantBlock implements Fertilizable, Reve

private static final VoxelShape SHAPE = Block.createCuboidShape(1.0, 0.0, 1.0, 15.0, 16.0, 15.0);

public static final EnumProperty<FluidLogging.State> LOGGED = FluidLogging.ANY_EXCLUDING_NONE;
public static final EnumProperty<FluidLogging.State> LOGGED = FluidLogging.WATER_AND_CRYSTAL;
public static final IntProperty AGE = Properties.AGE_7;

public MermaidsBrushBlock(Settings settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class QuitoxicReedsBlock extends Block implements RevelationAware, FluidLogging.SpectrumFluidLoggable {

public static final EnumProperty<FluidLogging.State> LOGGED = FluidLogging.ANY_INCLUDING_NONE;
public static final EnumProperty<FluidLogging.State> LOGGED = FluidLogging.NONE_WATER_AND_CRYSTAL;
public static final IntProperty AGE = Properties.AGE_7;

// 'always drop' has no cloak and therefore drops normally even when broken 'via the world'
Expand Down Expand Up @@ -70,7 +70,47 @@ public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Ran
world.breakBlock(pos, true);
}
}


@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return state.get(LOGGED) == FluidLogging.State.NOT_LOGGED && (fluid == Fluids.WATER || fluid == SpectrumFluids.LIQUID_CRYSTAL);
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
if (state.get(LOGGED) == FluidLogging.State.NOT_LOGGED) {
if (!world.isClient()) {
if (fluidState.getFluid() == Fluids.WATER) {
world.setBlockState(pos, state.with(LOGGED, FluidLogging.State.WATER), Block.NOTIFY_ALL);
world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
} else if (fluidState.getFluid() == SpectrumFluids.LIQUID_CRYSTAL) {
world.setBlockState(pos, state.with(LOGGED, FluidLogging.State.LIQUID_CRYSTAL), Block.NOTIFY_ALL);
world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world));
}
}
return true;
} else {
return false;
}
}
@Override
public ItemStack tryDrainFluid(WorldAccess world, BlockPos pos, BlockState state) {
FluidLogging.State fluidLog = state.get(LOGGED);

if (fluidLog == FluidLogging.State.WATER) {
world.setBlockState(pos, state.with(LOGGED, FluidLogging.State.NOT_LOGGED), Block.NOTIFY_ALL);
if (!state.canPlaceAt(world, pos)) {
world.breakBlock(pos, true);
}
return new ItemStack(Items.WATER_BUCKET);
} else if (fluidLog == FluidLogging.State.LIQUID_CRYSTAL) {
world.setBlockState(pos, state.with(LOGGED, FluidLogging.State.NOT_LOGGED), Block.NOTIFY_ALL);
if (!state.canPlaceAt(world, pos)) {
world.breakBlock(pos, true);
}
return new ItemStack(SpectrumItems.LIQUID_CRYSTAL_BUCKET);
}
return ItemStack.EMPTY;
}
@Nullable
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
Expand Down
Loading
Loading