Cave pumpkin
This commit is contained in:
parent
72113034ea
commit
3dcafa522c
40 changed files with 474 additions and 49 deletions
|
@ -18,6 +18,7 @@ public class BlockProperties {
|
|||
public static final BooleanProperty IS_FLOOR = BooleanProperty.of("is_floor");
|
||||
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
|
||||
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||
public static final BooleanProperty SMALL = BooleanProperty.of("small");
|
||||
|
||||
public static final IntProperty DESTRUCTION_LONG = IntProperty.of("destruction", 0, 8);
|
||||
public static final IntProperty DESTRUCTION = IntProperty.of("destruction", 0, 2);
|
||||
|
@ -26,6 +27,7 @@ public class BlockProperties {
|
|||
public static final IntProperty COLOR = IntProperty.of("color", 0, 7);
|
||||
public static final IntProperty PORTAL = IntProperty.of("portal", 0, EndPortals.getCount());
|
||||
public static final IntProperty SIZE = IntProperty.of("size", 0, 7);
|
||||
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
|
||||
|
||||
public static enum TripleShape implements StringIdentifiable {
|
||||
TOP("top"),
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
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.MaterialColor;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class CapsacisCapBlock extends BlockBase {
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
||||
public static final IntProperty COLOR = BlockProperties.COLOR;
|
||||
|
||||
public CapsacisCapBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.NETHER_WART_BLOCK).materialColor(MaterialColor.MAGENTA));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
double px = ctx.getBlockPos().getX() * 0.1;
|
||||
double py = ctx.getBlockPos().getY() * 0.1;
|
||||
double pz = ctx.getBlockPos().getZ() * 0.1;
|
||||
return this.getDefaultState().with(COLOR, MHelper.floor(NOISE.eval(px, py, pz) * 3.5 + 4));
|
||||
}
|
||||
}
|
65
src/main/java/ru/betterend/blocks/CavePumpkinBlock.java
Normal file
65
src/main/java/ru/betterend/blocks/CavePumpkinBlock.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.ShapeContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class CavePumpkinBlock extends BlockBaseNotFull implements IRenderTypeable {
|
||||
public static final BooleanProperty SMALL = BlockProperties.SMALL;
|
||||
private static final VoxelShape SHAPE_SMALL;
|
||||
private static final VoxelShape SHAPE_BIG;
|
||||
|
||||
public CavePumpkinBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.PUMPKIN).luminance((state) -> state.get(SMALL) ? 10 : 15));
|
||||
setDefaultState(getDefaultState().with(SMALL, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(SMALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return state.get(SMALL) ? SHAPE_SMALL : SHAPE_BIG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return state.get(SMALL) ? Collections.singletonList(new ItemStack(EndBlocks.CAVE_PUMPKIN_SEED)) : Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
static {
|
||||
VoxelShape lantern = Block.createCuboidShape(1, 0, 1, 15, 13, 15);
|
||||
VoxelShape cap = Block.createCuboidShape(0, 12, 0, 16, 15, 16);
|
||||
VoxelShape top = Block.createCuboidShape(5, 15, 5, 11, 16, 11);
|
||||
SHAPE_BIG = VoxelShapes.union(lantern, cap, top);
|
||||
|
||||
lantern = Block.createCuboidShape(1, 7, 1, 15, 13, 15);
|
||||
cap = Block.createCuboidShape(4, 12, 4, 12, 15, 12);
|
||||
top = Block.createCuboidShape(6, 15, 6, 10, 16, 10);
|
||||
SHAPE_SMALL = VoxelShapes.union(lantern, cap, top);
|
||||
}
|
||||
}
|
70
src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java
Normal file
70
src/main/java/ru/betterend/blocks/CavePumpkinVineBlock.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
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.StructureWorldAccess;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
|
||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.up());
|
||||
return isTerrain(down);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||
int age = state.get(AGE);
|
||||
BlockState down = world.getBlockState(pos.down());
|
||||
if (down.getMaterial().isReplaceable() || (down.isOf(EndBlocks.CAVE_PUMPKIN) && down.get(BlockProperties.SMALL))) {
|
||||
if (age < 3) {
|
||||
world.setBlockState(pos, state.with(AGE, age + 1));
|
||||
}
|
||||
if (age == 2) {
|
||||
world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState().with(BlockProperties.SMALL, true));
|
||||
}
|
||||
else if (age == 3) {
|
||||
world.setBlockState(pos.down(), EndBlocks.CAVE_PUMPKIN.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
state = super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
|
||||
if (state.isOf(this) && state.get(BlockProperties.AGE) > 1) {
|
||||
BlockState down = world.getBlockState(pos.down());
|
||||
if (!down.isOf(EndBlocks.CAVE_PUMPKIN)) {
|
||||
state = state.with(BlockProperties.AGE, 1);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBlock.OffsetType getOffsetType() {
|
||||
return AbstractBlock.OffsetType.NONE;
|
||||
}
|
||||
}
|
|
@ -14,9 +14,10 @@ import net.minecraft.state.property.IntProperty;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
|
||||
public abstract class EndPlantWithAgeBlock extends EndPlantBlock {
|
||||
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
|
||||
public static final IntProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public EndPlantWithAgeBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
|
|
|
@ -13,9 +13,10 @@ import net.minecraft.state.StateManager;
|
|||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
|
||||
public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
||||
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
|
||||
public static final IntProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public UnderwaterPlantWithAgeBlock() {
|
||||
super(FabricBlockSettings.of(Material.UNDERWATER_PLANT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue