Glowing pillar prototype
This commit is contained in:
parent
fb3c567e02
commit
9fc9370adc
27 changed files with 562 additions and 31 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -29,7 +29,9 @@ import ru.betterend.blocks.BlockEndLotusStem;
|
|||
import ru.betterend.blocks.BlockEndstoneDust;
|
||||
import ru.betterend.blocks.BlockGlowingMoss;
|
||||
import ru.betterend.blocks.BlockHelixTreeLeaves;
|
||||
import ru.betterend.blocks.BlockHelixTreeLuminophor;
|
||||
import ru.betterend.blocks.BlockGlowingPillarLuminophor;
|
||||
import ru.betterend.blocks.BlockGlowingPillarRoots;
|
||||
import ru.betterend.blocks.BlockGlowingPillarSeed;
|
||||
import ru.betterend.blocks.BlockHelixTreeSapling;
|
||||
import ru.betterend.blocks.BlockHydralux;
|
||||
import ru.betterend.blocks.BlockHydraluxPetal;
|
||||
|
@ -158,7 +160,6 @@ public class EndBlocks {
|
|||
|
||||
public static final Block HELIX_TREE_SAPLING = registerBlock("helix_tree_sapling", new BlockHelixTreeSapling());
|
||||
public static final Block HELIX_TREE_LEAVES = registerBlock("helix_tree_leaves", new BlockHelixTreeLeaves());
|
||||
public static final Block HELIX_TREE_LUMINOPHOR = registerBlock("helix_tree_luminophor", new BlockHelixTreeLuminophor());
|
||||
public static final WoodenMaterial HELIX_TREE = new WoodenMaterial("helix_tree", MaterialColor.GRAY, MaterialColor.ORANGE);
|
||||
|
||||
// Small Plants //
|
||||
|
@ -180,6 +181,11 @@ public class EndBlocks {
|
|||
public static final Block LANCELEAF_SEED = registerBlock("lanceleaf_seed", new BlockLanceleafSeed());
|
||||
public static final Block LANCELEAF = registerBlockNI("lanceleaf", new BlockLanceleaf());
|
||||
|
||||
public static final Block GLOWING_PILLAR_SEED = registerBlock("glowing_pillar_seed", new BlockGlowingPillarSeed());
|
||||
public static final Block GLOWING_PILLAR_ROOTS = registerBlockNI("glowing_pillar_roots", new BlockGlowingPillarRoots());
|
||||
public static final Block GLOWING_PILLAR_LUMINOPHOR = registerBlock("glowing_pillar_luminophor", new BlockGlowingPillarLuminophor());
|
||||
public static final Block GLOWING_PILLAR_LEAVES = registerBlock("glowing_pillar_leaves", new BlockFur(GLOWING_PILLAR_SEED, 15, 3));
|
||||
|
||||
public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BlockBubbleCoral());
|
||||
public static final Block MENGER_SPONGE = registerBlock("menger_sponge", new BlockMengerSponge());
|
||||
public static final Block MENGER_SPONGE_WET = registerBlock("menger_sponge_wet", new BlockMengerSpongeWet());
|
||||
|
|
|
@ -38,6 +38,7 @@ public class BlocksHelper {
|
|||
public static final int FLAG_IGNORE_OBSERVERS = 16;
|
||||
|
||||
public static final int SET_SILENT = FLAG_UPDATE_BLOCK | FLAG_IGNORE_OBSERVERS | FLAG_SEND_CLIENT_CHANGES;
|
||||
public static final int SET_OBSERV = FLAG_UPDATE_BLOCK | FLAG_SEND_CLIENT_CHANGES;
|
||||
public static final Direction[] HORIZONTAL = makeHorizontal();
|
||||
public static final Direction[] DIRECTIONS = Direction.values();
|
||||
|
||||
|
@ -66,6 +67,14 @@ public class BlocksHelper {
|
|||
public static void setWithoutUpdate(WorldAccess world, BlockPos pos, Block block) {
|
||||
world.setBlockState(pos, block.getDefaultState(), SET_SILENT);
|
||||
}
|
||||
|
||||
public static void setWithUpdate(WorldAccess world, BlockPos pos, BlockState state) {
|
||||
world.setBlockState(pos, state, SET_OBSERV);
|
||||
}
|
||||
|
||||
public static void setWithUpdate(WorldAccess world, BlockPos pos, Block block) {
|
||||
world.setBlockState(pos, block.getDefaultState(), SET_OBSERV);
|
||||
}
|
||||
|
||||
public static int upRay(WorldAccess world, BlockPos pos, int maxDist) {
|
||||
int length = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue