Skip to content

Commit

Permalink
Make snowrealmagic compat melt blocks better
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jan 8, 2024
1 parent 0c953fc commit 41ff068
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ public interface SnowRealMagicPlatform {
@Override
public Services.@Nullable Melter melter() {
return (level, pos, original) -> {
Block snowVariant = original.getBlock();
if (SnowRealMagicPlatform.INSTANCE.isVariant(snowVariant)) {
try {
// TODO: fix melting further stuff down
BlockState newState = SnowRealMagicPlatform.INSTANCE.decreaseLayer(snowVariant, original, level, pos, false);
if (newState != original) {
level.setBlockAndUpdate(pos, newState);
var mutablePos = pos.mutable();
var state = original;
for (int i = 0; i < 16; i++) {
Block snowVariant = state.getBlock();
if (SnowRealMagicPlatform.INSTANCE.isVariant(snowVariant)) {
BlockState newState = SnowRealMagicPlatform.INSTANCE.decreaseLayer(snowVariant, state, level, mutablePos, false);
if (newState != state) {
level.setBlockAndUpdate(mutablePos, newState);
return true;
}
} catch (Throwable e) {
throw new RuntimeException(e);
break;
}
mutablePos.move(Direction.DOWN);
state = level.getBlockState(mutablePos);
}
return false;
};
Expand Down

0 comments on commit 41ff068

Please sign in to comment.