Lanceleaf, more moss variation, translations
This commit is contained in:
parent
5bd4abebfb
commit
2183fe5829
43 changed files with 480 additions and 35 deletions
53
src/main/java/ru/betterend/blocks/BlockLanceleaf.java
Normal file
53
src/main/java/ru/betterend/blocks/BlockLanceleaf.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
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.BlockProperties.PentaShape;
|
||||
import ru.betterend.blocks.basis.BlockPlant;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class BlockLanceleaf extends BlockPlant {
|
||||
public static final EnumProperty<PentaShape> SHAPE = BlockProperties.PENTA_SHAPE;
|
||||
public static final IntProperty ROTATION = BlockProperties.ROTATION;
|
||||
|
||||
public BlockLanceleaf() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(SHAPE, ROTATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
PentaShape shape = state.get(SHAPE);
|
||||
if (shape == PentaShape.TOP) {
|
||||
return world.getBlockState(pos.down()).isOf(this);
|
||||
}
|
||||
else if (shape == PentaShape.BOTTOM) {
|
||||
return world.getBlockState(pos.down()).isOf(EndBlocks.AMBER_MOSS) && world.getBlockState(pos.up()).isOf(this);
|
||||
}
|
||||
else {
|
||||
return world.getBlockState(pos.down()).isOf(this) && world.getBlockState(pos.up()).isOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
40
src/main/java/ru/betterend/blocks/BlockLanceleafSeed.java
Normal file
40
src/main/java/ru/betterend/blocks/BlockLanceleafSeed.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import ru.betterend.blocks.BlockProperties.PentaShape;
|
||||
import ru.betterend.blocks.basis.BlockPlantWithAge;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockLanceleafSeed extends BlockPlantWithAge {
|
||||
@Override
|
||||
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
|
||||
int height = MHelper.randRange(4, 6, random);
|
||||
int h = BlocksHelper.upRay(world, pos, height + 2);
|
||||
if (h < height + 1) {
|
||||
return;
|
||||
}
|
||||
int rotation = random.nextInt(4);
|
||||
Mutable mut = new Mutable().set(pos);
|
||||
BlockState plant = EndBlocks.LANCELEAF.getDefaultState().with(BlockProperties.ROTATION, rotation);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, plant.with(BlockProperties.PENTA_SHAPE, PentaShape.BOTTOM));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_BOTTOM));
|
||||
for (int i = 2; i < height - 2; i++) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.MIDDLE));
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.PRE_TOP));
|
||||
BlocksHelper.setWithoutUpdate(world, mut.move(Direction.UP), plant.with(BlockProperties.PENTA_SHAPE, PentaShape.TOP));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.isOf(EndBlocks.AMBER_MOSS);
|
||||
}
|
||||
}
|
|
@ -2,15 +2,18 @@ package ru.betterend.blocks;
|
|||
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
public class BlockProperties {
|
||||
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
|
||||
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class);
|
||||
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.of("shape", HydraluxShape.class);
|
||||
public static final EnumProperty<PentaShape> PENTA_SHAPE = EnumProperty.of("shape", PentaShape.class);
|
||||
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
|
||||
public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light");
|
||||
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
|
||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
||||
|
||||
public static enum TripleShape implements StringIdentifiable {
|
||||
TOP("top"),
|
||||
|
@ -89,4 +92,28 @@ public class BlockProperties {
|
|||
return glow;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum PentaShape implements StringIdentifiable {
|
||||
BOTTOM("bottom"),
|
||||
PRE_BOTTOM("pre_bottom"),
|
||||
MIDDLE("middle"),
|
||||
PRE_TOP("pre_top"),
|
||||
TOP("top");
|
||||
|
||||
private final String name;
|
||||
|
||||
PentaShape(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.world.BlockView;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
@ -41,7 +42,7 @@ import ru.betterend.util.BlocksHelper;
|
|||
|
||||
public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
|
||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
|
||||
public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3);
|
||||
public static final IntProperty ROTATION = BlockProperties.ROTATION;
|
||||
public static final BooleanProperty TOP = BooleanProperty.of("top");
|
||||
|
||||
public BlockDoublePlant() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue