Skip to content

Commit

Permalink
Further setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Dec 8, 2022
1 parent 88d6c4a commit 0138e5d
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 43 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G -Djava.net.preferIPv4Stack=true
org.gradle.daemon=false
mod_version=1.0.4
mod_version=1.0.6
modid=overgrowth
mc_version=1.19.2
forge_version=43.0.8
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/ldtteam/overgrowth/Overgrowth.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public Overgrowth()
ITransformationHandler.HANDLERS.add(new NightCampfire());
ITransformationHandler.HANDLERS.add(new SandToSandstone());
ITransformationHandler.HANDLERS.add(new UndoPath());
ITransformationHandler.HANDLERS.add(new MuddyRain());
ITransformationHandler.HANDLERS.add(new MudDry());

Mod.EventBusSubscriber.Bus.FORGE.bus().get().register(EntityHandling.class);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ldtteam/overgrowth/handlers/ByeTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 199 == 0;
return worldTick % 19 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockPos worldPos = Utils.getWorldPos(chunk, chunk.getSections()[chunkSection], relativePos);
chunk.getLevel().destroyBlock(worldPos, true);
chunk.getLevel().destroyBlock(worldPos, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 99 == 0;
return worldTick % 18 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
for (final Direction direction : Direction.Plane.HORIZONTAL)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 97 == 0;
return worldTick % 17 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
for (final Direction direction : Direction.values())
{
Expand All @@ -66,7 +66,7 @@ public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, f
final LevelChunkSection section = chunk.getSections()[chunkSection];
final BlockPos worldPos = Utils.getWorldPos(chunk, section, relativePos);

chunk.getLevel().setBlock(worldPos, transformationMapping.get(Utils.getBlockState(chunk, relativePos, chunkSection).getBlock()).defaultBlockState(), UPDATE_ALL_IMMEDIATE);
chunk.getLevel().setBlock(worldPos, transformationMapping.get(input.getBlock()).withPropertiesOf(input), UPDATE_ALL_IMMEDIATE);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 96 == 0;
return worldTick % 16 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockState upState = Utils.getBlockState(chunk, relativePos.above(), chunkSection);
if (upState.isAir() || chunk.getLevel().getRandom().nextInt(100) < 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 130 == 0;
return worldTick % 23 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
for (final Direction direction : Direction.values())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public boolean transforms(final BlockState state)
}

@Override
public boolean ready(final long worldTick)
public boolean ready(final long worldTick, final LevelChunk chunk)
{
return worldTick % 101 == 0;
return chunk.getLevel().isRaining() ? worldTick % 6 == 0 : worldTick % 11 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockState upState = Utils.getBlockState(chunk, relativePos.above(), chunkSection);
if (upState.isAir())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 102 == 0;
return worldTick % 12 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockState state = Utils.getBlockState(chunk, relativePos, chunkSection);
final LevelChunkSection section = chunk.getSections()[chunkSection];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ public interface ITransformationHandler
* @param worldTick the relative world tick to do a transformation in.
* @return true if so.
*/
boolean ready(final long worldTick);
default boolean ready(final long worldTick)
{
return true;
}

/**
* Check if the transformation handler is ready to do a transformation now.
* @param worldTick the relative world tick to do a transformation in.
* @return true if so.
*/
default boolean ready(final long worldTick, final LevelChunk chunk)
{
return ready(worldTick);
}

/**
* Transform a given block in a given chunk.
* @param relativePos the relative position in the chunk section.
* @param chunk the chunk itself.
* @param chunkSection the chunk section id.
* @param input the input state.
*/
void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection);
void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input);

/**
* Add a new handler to the list of handlers.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ldtteam/overgrowth/handlers/LavaDry.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 103 == 0;
return worldTick % 13 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
int lavaCount = 0;
for (final Direction direction : Direction.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 104 == 0;
return worldTick % 14 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
for (final Direction direction : Direction.values())
{
Expand All @@ -60,7 +60,7 @@ public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, f
final BlockPos worldPos = Utils.getWorldPos(chunk, section, relativePos);


chunk.getLevel().setBlock(worldPos, transformationMapping.get(Utils.getBlockState(chunk, relativePos, chunkSection).getBlock()).defaultBlockState(), UPDATE_ALL_IMMEDIATE);
chunk.getLevel().setBlock(worldPos, transformationMapping.get(input.getBlock()).withPropertiesOf(input), UPDATE_ALL_IMMEDIATE);
return;
}
}
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/ldtteam/overgrowth/handlers/MudDry.java
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 src/main/java/com/ldtteam/overgrowth/handlers/MuddyRain.java
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 99 == 0;
return worldTick % 11 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockState relativeState = Utils.getBlockState(chunk, relativePos.below(), chunkSection);
if (relativeState.getBlock() == Blocks.HAY_BLOCK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 103 == 0;
return worldTick % 13 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockState relativeState = Utils.getBlockState(chunk, relativePos.below(), chunkSection);
if (relativeState.getBlock() == Blocks.SAND)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ldtteam/overgrowth/handlers/SpiderWebs.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 105 == 0;
return worldTick % 15 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
for (final Direction direction : Direction.values())
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ldtteam/overgrowth/handlers/UndoPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public boolean transforms(final BlockState state)
@Override
public boolean ready(final long worldTick)
{
return worldTick % 299 == 0;
return worldTick % 29 == 0;
}

@Override
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection)
public void transformBlock(final BlockPos relativePos, final LevelChunk chunk, final int chunkSection, final BlockState input)
{
final BlockPos worldPos = Utils.getWorldPos(chunk, chunk.getSections()[chunkSection], relativePos);
chunk.getLevel().setBlock(worldPos, Blocks.DIRT.defaultBlockState(), 0x03);
Expand Down
Loading

0 comments on commit 0138e5d

Please sign in to comment.