Gigantic amaranita bonemeal grow
This commit is contained in:
parent
9899492a93
commit
0fe5b9f0b9
2 changed files with 36 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -13,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
|
@ -64,4 +67,14 @@ public class LargeAmaranitaBlock extends EndPlantBlock {
|
||||||
public OffsetType getOffsetType() {
|
public OffsetType getOffsetType() {
|
||||||
return OffsetType.NONE;
|
return OffsetType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,18 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndFeatures;
|
import ru.betterend.registry.EndFeatures;
|
||||||
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class SmallAmaranitaBlock extends EndPlantBlock {
|
public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12);
|
||||||
|
@ -26,6 +29,12 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||||
BlockPos bigPos = growBig(world, pos);
|
BlockPos bigPos = growBig(world, pos);
|
||||||
if (bigPos != null) {
|
if (bigPos != null) {
|
||||||
|
if (EndFeatures.GIGANTIC_AMARANITA.getFeature().generate(world, null, random, bigPos, null)) {
|
||||||
|
replaceMushroom(world, bigPos);
|
||||||
|
replaceMushroom(world, bigPos.south());
|
||||||
|
replaceMushroom(world, bigPos.east());
|
||||||
|
replaceMushroom(world, bigPos.south().east());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EndFeatures.LARGE_AMARANITA.getFeature().generate(world, null, random, pos, null);
|
EndFeatures.LARGE_AMARANITA.getFeature().generate(world, null, random, pos, null);
|
||||||
|
@ -50,9 +59,20 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFrame(ServerWorld world, BlockPos pos) {
|
private boolean checkFrame(ServerWorld world, BlockPos pos) {
|
||||||
return world.getBlockState(pos).isOf(this) ||
|
return world.getBlockState(pos).isOf(this) &&
|
||||||
world.getBlockState(pos.south()).isOf(this) ||
|
world.getBlockState(pos.south()).isOf(this) &&
|
||||||
world.getBlockState(pos.east()).isOf(this) ||
|
world.getBlockState(pos.east()).isOf(this) &&
|
||||||
world.getBlockState(pos.south().east()).isOf(this);
|
world.getBlockState(pos.south().east()).isOf(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void replaceMushroom(ServerWorld world, BlockPos pos) {
|
||||||
|
if (world.getBlockState(pos).isOf(this)) {
|
||||||
|
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
||||||
|
return random.nextInt(8) == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue