desertShrubs

This commit is contained in:
DeadlyMC committed 2019-06-06 16:26:24 +05:30
1 parent 653ddcf5f3
commit a8598ad700
3 files changed
+34 -1

No files matched your search

+1 -1
View File
@@ -115,7 +115,7 @@ public class CarpetSettings
.isACommand().boolAccelerate().defaultFalse(),
rule("renewableSponges", "experimental feature", "Guardians turn into Elder Guardian when struck by lightning").wip(),
rule("movableTileEntities", "experimental", "Pistons can push tile entities, like hoppers, chests etc.").boolAccelerate(),
rule("desertShrubs", "feature", "Saplings turn into dead shrubs in hot climates and no water access when it attempts to grow into a tree").wip(),
rule("desertShrubs", "feature", "Saplings turn into dead shrubs in hot climates and no water access when it attempts to grow into a tree"),
rule("silverFishDropGravel", "experimental", "Silverfish drop a gravel item when breaking out of a block"),
rule("summonNaturalLightning","creative", "summoning a lightning bolt has all the side effects of natural lightning"),
rule("commandSpawn", "commands", "Enables /spawn command for spawn tracking").isACommand(),
@@ -0,0 +1,32 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.helpers.BlockSaplingHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SaplingBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biomes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Random;
@Mixin(SaplingBlock.class)
public abstract class SaplingBlockMixin
{
@Inject(method = "generate", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"),
cancellable = true)
private void onGenerate(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
{
if(CarpetSettings.getBool("desertShrubs") && iWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(iWorld_1, blockPos_1))
{
iWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3);
ci.cancel();
}
}
}