added more customizability to renewableCoral (#1022)
* added more customizability to renewableCoral * changed renewableCoral to use enums instead of strings * added suggested changes to renewablecoralmode * Update src/main/java/carpet/CarpetSettings.java Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
This commit is contained in:
1 parent
2a391962ff
commit
56a15fb384
4 files changed
+89
-4
No files matched your search
@@ -757,9 +757,18 @@ public class CarpetSettings
|
||||
validate = LightBatchValidator.class
|
||||
)
|
||||
public static int lightEngineMaxBatchSize = 5;
|
||||
|
||||
@Rule(desc = "Coral structures will grow with bonemeal from coral plants", category = FEATURE)
|
||||
public static boolean renewableCoral = false;
|
||||
|
||||
public enum RenewableCoralMode {
|
||||
FALSE,
|
||||
EXPANDED,
|
||||
TRUE;
|
||||
}
|
||||
@Rule(
|
||||
desc = "Coral structures will grow with bonemeal from coral plants",
|
||||
extra = "Expanded also allows growing from coral fans for sustainable farming outside of warm oceans",
|
||||
category = FEATURE
|
||||
)
|
||||
public static RenewableCoralMode renewableCoral = RenewableCoralMode.FALSE;
|
||||
|
||||
@Rule(
|
||||
desc = "Nether basalt generator without soul sand below ",
|
||||
|
||||
@@ -29,7 +29,10 @@ public abstract class CoralBlockMixin implements Fertilizable
|
||||
{
|
||||
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
{
|
||||
return CarpetSettings.renewableCoral && var3.get(CoralParentBlock.WATERLOGGED) && var1.getFluidState(var2.up()).isIn(FluidTags.WATER);
|
||||
return CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.EXPANDED
|
||||
|| CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.TRUE
|
||||
&& var3.get(CoralParentBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.up()).isIn(FluidTags.WATER);
|
||||
}
|
||||
|
||||
public boolean canGrow(World var1, Random var2, BlockPos var3, BlockState var4)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.CoralFeatureInterface;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(CoralFanBlock.class)
|
||||
public abstract class CoralFanBlockMixin implements Fertilizable
|
||||
{
|
||||
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
{
|
||||
return CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.EXPANDED
|
||||
&& var3.get(CoralParentBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.up()).isIn(FluidTags.WATER);
|
||||
}
|
||||
|
||||
public boolean canGrow(World var1, Random var2, BlockPos var3, BlockState var4)
|
||||
{
|
||||
return (double)var1.random.nextFloat() < 0.15D;
|
||||
}
|
||||
|
||||
public void grow(ServerWorld worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
{
|
||||
|
||||
CoralFeature coral;
|
||||
int variant = random.nextInt(3);
|
||||
if (variant == 0)
|
||||
coral = new CoralClawFeature(DefaultFeatureConfig.CODEC);
|
||||
else if (variant == 1)
|
||||
coral = new CoralTreeFeature(DefaultFeatureConfig.CODEC);
|
||||
else
|
||||
coral = new CoralMushroomFeature(DefaultFeatureConfig.CODEC);
|
||||
|
||||
MapColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
BlockState proper_block = blockUnder;
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.values())
|
||||
{
|
||||
proper_block = block.getDefaultState();
|
||||
if (proper_block.getMapColor(worldIn,pos) == color)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), 4);
|
||||
|
||||
if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, proper_block))
|
||||
{
|
||||
worldIn.setBlockState(pos, blockUnder, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (worldIn.random.nextInt(10)==0)
|
||||
{
|
||||
BlockPos randomPos = pos.add(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
|
||||
if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
|
||||
{
|
||||
worldIn.setBlockState(randomPos, Blocks.WET_SPONGE.getDefaultState(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@
|
||||
"PoweredRailBlock_powerLimitMixin",
|
||||
"LivingEntity_maxCollisionsMixin",
|
||||
"CoralBlockMixin",
|
||||
"CoralFanBlockMixin",
|
||||
"CoralFeatureMixin",
|
||||
"BuddingAmethystBlock_movableAmethystMixin",
|
||||
"FluidBlock_renewableBlackstoneMixin",
|
||||
|
||||
Reference in new issue
Block a user