Glowing pillar prototype

This commit is contained in:
paulevsGitch 2020-12-10 20:59:29 +03:00
parent fb3c567e02
commit 9fc9370adc
27 changed files with 562 additions and 31 deletions

View file

@ -44,6 +44,6 @@ public class BlockBlueVineSeed extends BlockPlantWithAge {
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
return state.isOf(EndBlocks.END_MOSS) || state.isOf(EndBlocks.END_MYCELIUM);
}
}

View file

@ -0,0 +1,52 @@
package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
public class BlockGlowingPillarLuminophor extends BlockBase {
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
public BlockGlowingPillarLuminophor() {
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.ORANGE)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.strength(0.2F)
.luminance(15));
this.setDefaultState(this.stateManager.getDefaultState().with(NATURAL, false));
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.get(NATURAL) ? world.getBlockState(pos.down()).isOf(EndBlocks.GLOWING_PILLAR_ROOTS) : true;
}
@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
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(NATURAL);
}
}

View file

@ -0,0 +1,23 @@
package ru.betterend.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUpDownPlant;
import ru.betterend.registry.EndBlocks;
public class BlockGlowingPillarRoots extends BlockUpDownPlant {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.isOf(EndBlocks.AMBER_MOSS);
}
}

View file

@ -0,0 +1,55 @@
package ru.betterend.blocks;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class BlockGlowingPillarSeed extends BlockPlantWithAge {
@Override
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
int height = MHelper.randRange(1, 2, random);
int h = BlocksHelper.upRay(world, pos, height + 2);
if (h < height) {
return;
}
Mutable mut = new Mutable().set(pos);
BlockState roots = EndBlocks.GLOWING_PILLAR_ROOTS.getDefaultState();
if (height < 2) {
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
mut.move(Direction.UP);
}
else {
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
mut.move(Direction.UP);
BlocksHelper.setWithUpdate(world, mut, roots.with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
mut.move(Direction.UP);
}
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LUMINOPHOR.getDefaultState().with(BlockBlueVineLantern.NATURAL, true));
for (Direction dir: BlocksHelper.DIRECTIONS) {
pos = mut.offset(dir);
if (world.isAir(pos)) {
BlocksHelper.setWithUpdate(world, pos, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, dir));
}
}
mut.move(Direction.UP);
if (world.isAir(mut)) {
BlocksHelper.setWithUpdate(world, mut, EndBlocks.GLOWING_PILLAR_LEAVES.getDefaultState().with(Properties.FACING, Direction.UP));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.isOf(EndBlocks.AMBER_MOSS);
}
}

View file

@ -1,19 +0,0 @@
package ru.betterend.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.sound.BlockSoundGroup;
import ru.betterend.blocks.basis.BlockBase;
public class BlockHelixTreeLuminophor extends BlockBase {
public BlockHelixTreeLuminophor() {
super(FabricBlockSettings.of(Material.LEAVES)
.materialColor(MaterialColor.ORANGE)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
.strength(0.2F)
.luminance(15));
}
}