Fixes
This commit is contained in:
parent
518e7b3fcf
commit
46ceaee8be
21 changed files with 207 additions and 55 deletions
|
@ -33,6 +33,8 @@ import net.minecraft.world.WorldView;
|
|||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||
import ru.betterend.client.ERenderLayer;
|
||||
import ru.betterend.client.IRenderTypeable;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockMossyGlowshroomFur extends BlockBaseNotFull implements IRenderTypeable {
|
||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||
|
@ -96,7 +98,11 @@ public class BlockMossyGlowshroomFur extends BlockBaseNotFull implements IRender
|
|||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
||||
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Lists.newArrayList(new ItemStack(this));
|
||||
} else {
|
||||
}
|
||||
else if (MHelper.RANDOM.nextInt(16) == 0) {
|
||||
return Lists.newArrayList(new ItemStack(BlockRegistry.MOSSY_GLOWSHROOM_SAPLING));
|
||||
}
|
||||
else {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
||||
import ru.betterend.registry.FeatureRegistry;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
|
||||
public BlockMossyGlowshroomSapling() {
|
||||
super((DefaultFeature) FeatureRegistry.MOSSY_GLOWSHROOM.getFeature(), 7);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Fertilizable;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.client.ERenderLayer;
|
||||
import ru.betterend.client.IRenderTypeable;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
|
||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
|
||||
private final DefaultFeature feature;
|
||||
|
||||
public BlockFeatureSapling(DefaultFeature feature) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.collidable(false)
|
||||
.breakInstantly()
|
||||
.sounds(BlockSoundGroup.GRASS)
|
||||
.ticksRandomly());
|
||||
this.feature = feature;
|
||||
}
|
||||
|
||||
public BlockFeatureSapling(DefaultFeature feature, int light) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.collidable(false)
|
||||
.breakInstantly()
|
||||
.sounds(BlockSoundGroup.GRASS)
|
||||
.lightLevel(light)
|
||||
.ticksRandomly());
|
||||
this.feature = feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
return world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (!canPlaceAt(state, world, pos))
|
||||
return Blocks.AIR.getDefaultState();
|
||||
else
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
||||
return random.nextInt(16) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||
feature.generate(world, world.getChunkManager().getChunkGenerator(), random, pos, DefaultFeatureConfig.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
super.scheduledTick(state, world, pos, random);
|
||||
if (canGrow(world, random, pos, state)) {
|
||||
grow(world, random, pos, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue