-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
165 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.ldtteam.overgrowth.handlers; | ||
|
||
import com.ldtteam.overgrowth.utils.Utils; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.chunk.LevelChunk; | ||
import net.minecraft.world.level.chunk.LevelChunkSection; | ||
|
||
import static net.minecraft.world.level.block.Block.UPDATE_ALL_IMMEDIATE; | ||
|
||
/** | ||
* Mud dries up | ||
*/ | ||
public class MudDry implements ITransformationHandler | ||
{ | ||
@Override | ||
public boolean transforms(final BlockState state) | ||
{ | ||
return state.getBlock() == Blocks.MUD; | ||
} | ||
|
||
@Override | ||
public boolean ready(final long worldTick, final LevelChunk chunk) | ||
{ | ||
return !chunk.getLevel().isRaining() && worldTick % 17 == 0; | ||
} | ||
|
||
@Override | ||
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input) | ||
{ | ||
int waterCount = 0; | ||
for (final Direction direction : Direction.values()) | ||
{ | ||
final BlockState relativeState = Utils.getBlockState(chunk, relativePos.relative(direction), chunkSection); | ||
if (relativeState.getBlock() == Blocks.WATER || relativeState.getBlock() == Blocks.MUD) | ||
{ | ||
waterCount++; | ||
} | ||
} | ||
|
||
if (waterCount < 3) | ||
{ | ||
final LevelChunkSection section = chunk.getSections()[chunkSection]; | ||
final BlockPos worldPos = Utils.getWorldPos(chunk, section, relativePos); | ||
|
||
chunk.getLevel().setBlock(worldPos, Blocks.DIRT.defaultBlockState(), UPDATE_ALL_IMMEDIATE); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/ldtteam/overgrowth/handlers/MuddyRain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.ldtteam.overgrowth.handlers; | ||
|
||
import com.ldtteam.overgrowth.utils.Utils; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.data.worldgen.placement.VegetationPlacements; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.BonemealableBlock; | ||
import net.minecraft.world.level.block.TallGrassBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.chunk.LevelChunk; | ||
import net.minecraft.world.level.chunk.LevelChunkSection; | ||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; | ||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration; | ||
import net.minecraft.world.level.levelgen.placement.PlacedFeature; | ||
|
||
import java.util.List; | ||
|
||
import static net.minecraft.world.level.block.Block.UPDATE_ALL_IMMEDIATE; | ||
|
||
/** | ||
* Makes grass or dirt randomly to mud in the rain | ||
*/ | ||
public class MuddyRain implements ITransformationHandler | ||
{ | ||
@Override | ||
public boolean transforms(final BlockState state) | ||
{ | ||
return state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.GRASS_BLOCK; | ||
} | ||
|
||
@Override | ||
public boolean ready(final long worldTick, final LevelChunk chunk) | ||
{ | ||
return chunk.getLevel().isRaining() && worldTick % 17 == 0; | ||
} | ||
|
||
@Override | ||
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input) | ||
{ | ||
final LevelChunkSection section = chunk.getSections()[chunkSection]; | ||
final BlockPos worldPos = Utils.getWorldPos(chunk, section, relativePos); | ||
|
||
if (chunk.getLevel().canSeeSky(worldPos.above())) | ||
{ | ||
chunk.getLevel().setBlock(worldPos, Blocks.MUD.defaultBlockState(), UPDATE_ALL_IMMEDIATE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.