Skip to content

Commit

Permalink
fixes dust replacing lava (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thutmose committed Sep 16, 2022
1 parent f817cf8 commit 86cbef5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main/java/thut/api/block/flowing/IFlowingBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface IFlowingBlock
public static final IntegerProperty VISCOSITY = IntegerProperty.create("viscosity", 0, 15);

public static final ResourceLocation DUSTREPLACEABLE = new ResourceLocation("thutcore:dust_replace");
public static final ResourceLocation NOTDUSTREPLACEABLE = new ResourceLocation("thutcore:no_dust_replace");

public static VoxelShape[] makeShapes()
{
Expand Down Expand Up @@ -163,6 +164,26 @@ default BlockState tryFall(BlockState state, ServerLevel level, BlockPos pos, Ra
int below = getExistingAmount(b, belowPos, level);
boolean belowFalling = isFalling(b);

if (!this.canReplace(b))
{
boolean shouldBeFalling = !level.getFluidState(belowPos).isEmpty();
if (shouldBeFalling && !falling)
{
BlockState fall = makeFalling(state, true);
if (fall != state)
{
level.setBlock(pos, state = fall, 2);
level.scheduleTick(pos.immutable(), thisBlock(), getFallRate());
}
}
else if (!shouldBeFalling && falling)
{
BlockState fall = makeFalling(state, false);
if (fall != state) level.setBlock(pos, state = fall, 2);
}
return state;
}

if (falling || !state.hasProperty(FALLING))
{
if ((below < 0 || below == 16))
Expand Down Expand Up @@ -227,7 +248,6 @@ else if (dust - diff >= 0)
if (below >= 0 && below < 16)
{
BlockState fall = makeFalling(state, true);

if (fall != state)
{
level.setBlock(pos, state = fall, 2);
Expand Down Expand Up @@ -333,6 +353,7 @@ default boolean canReplace(BlockState state, BlockPos pos, ServerLevel level)
default boolean canReplace(BlockState state)
{
if (state.isAir()) return true;
if (ItemList.is(NOTDUSTREPLACEABLE, state)) return false;
if (state.canBeReplaced(Fluids.FLOWING_WATER)) return true;
return ItemList.is(DUSTREPLACEABLE, state);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lava"
]
}

0 comments on commit 86cbef5

Please sign in to comment.