TripleTerrain (WIP)

This commit is contained in:
paulevsGitch 2021-03-11 03:55:14 +03:00
parent 311e5f3e4b
commit 9b464bcc06
12 changed files with 148 additions and 2 deletions

View file

@ -79,7 +79,7 @@ public class EndTerrainBlock extends BlockBase {
} }
} }
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) { protected boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
BlockPos blockPos = pos.up(); BlockPos blockPos = pos.up();
BlockState blockState = worldView.getBlockState(blockPos); BlockState blockState = worldView.getBlockState(blockPos);
if (blockState.isOf(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) { if (blockState.isOf(Blocks.SNOW) && (Integer) blockState.get(SnowBlock.LAYERS) == 1) {

View file

@ -0,0 +1,96 @@
package ru.betterend.blocks.basis;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.patterns.Patterns;
import ru.betterend.blocks.EndTerrainBlock;
public class TripleTerrainBlock extends EndTerrainBlock {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
public TripleTerrainBlock(MaterialColor color) {
super(color);
this.setDefaultState(this.getDefaultState().with(SHAPE, TripleShape.BOTTOM));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(SHAPE);
}
@Override
public String getModelPattern(String block) {
System.out.println(block);
String name = Registry.BLOCK.getId(this).getPath();
if (block.endsWith("_middle")) {
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top");
}
Map<String, String> map = Maps.newHashMap();
map.put("%top%", "betterend:block/" + name + "_top");
map.put("%side%", "betterend:block/" + name + "_side");
map.put("%bottom%", "minecraft:block/end_stone");
return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map);
}
@Override
public Identifier statePatternId() {
return Patterns.STATE_TRIPLE_ROTATED_TOP;
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
TripleShape shape = state.get(SHAPE);
if (shape == TripleShape.TOP) {
super.randomTick(state, world, pos, random);
return;
}
else if (random.nextInt(16) == 0) {
boolean bottom = canSurviveBottom(world, pos);
if (shape == TripleShape.BOTTOM) {
if (!bottom) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
}
}
else {
boolean top = canSurvive(state, world, pos);
if (!top && !bottom) {
world.setBlockState(pos, Blocks.END_STONE.getDefaultState());
}
else if (top && !bottom) {
world.setBlockState(pos, state.with(SHAPE, TripleShape.TOP));
}
else if (!top && bottom) {
world.setBlockState(pos, state.with(SHAPE, TripleShape.BOTTOM));
}
}
}
}
protected boolean canSurviveBottom(WorldView world, BlockPos pos) {
BlockPos blockPos = pos.down();
BlockState blockState = world.getBlockState(blockPos);
if (blockState.getFluidState().getLevel() == 8) {
return false;
}
else {
return !blockState.isSideSolidFullSquare(world, blockPos, Direction.UP);
}
}
}

View file

@ -46,6 +46,7 @@ public class Patterns {
public final static Identifier STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json"); public final static Identifier STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json");
public final static Identifier STATE_FURNACE = BetterEnd.makeID("patterns/blockstate/furnace.json"); public final static Identifier STATE_FURNACE = BetterEnd.makeID("patterns/blockstate/furnace.json");
public final static Identifier STATE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/rotated_top.json"); public final static Identifier STATE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/rotated_top.json");
public final static Identifier STATE_TRIPLE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/triple_rotated_top.json");
public final static Identifier STATE_STALACTITE = BetterEnd.makeID("patterns/blockstate/stalactite.json"); public final static Identifier STATE_STALACTITE = BetterEnd.makeID("patterns/blockstate/stalactite.json");
//Models Block //Models Block

View file

@ -110,6 +110,7 @@ import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.blocks.basis.SimpleLeavesBlock; import ru.betterend.blocks.basis.SimpleLeavesBlock;
import ru.betterend.blocks.basis.StalactiteBlock; import ru.betterend.blocks.basis.StalactiteBlock;
import ru.betterend.blocks.basis.StoneLanternBlock; import ru.betterend.blocks.basis.StoneLanternBlock;
import ru.betterend.blocks.basis.TripleTerrainBlock;
import ru.betterend.blocks.basis.VineBlock; import ru.betterend.blocks.basis.VineBlock;
import ru.betterend.blocks.basis.WallMushroomBlock; import ru.betterend.blocks.basis.WallMushroomBlock;
import ru.betterend.blocks.complex.ColoredMaterial; import ru.betterend.blocks.complex.ColoredMaterial;
@ -126,7 +127,7 @@ public class EndBlocks {
public static final Block END_MYCELIUM = registerBlock("end_mycelium", new EndTerrainBlock(MaterialColor.LIGHT_BLUE)); public static final Block END_MYCELIUM = registerBlock("end_mycelium", new EndTerrainBlock(MaterialColor.LIGHT_BLUE));
public static final Block END_MOSS = registerBlock("end_moss", new EndTerrainBlock(MaterialColor.CYAN)); public static final Block END_MOSS = registerBlock("end_moss", new EndTerrainBlock(MaterialColor.CYAN));
public static final Block CHORUS_NYLIUM = registerBlock("chorus_nylium", new EndTerrainBlock(MaterialColor.MAGENTA)); public static final Block CHORUS_NYLIUM = registerBlock("chorus_nylium", new EndTerrainBlock(MaterialColor.MAGENTA));
public static final Block CAVE_MOSS = registerBlock("cave_moss", new EndTerrainBlock(MaterialColor.PURPLE)); public static final Block CAVE_MOSS = registerBlock("cave_moss", new TripleTerrainBlock(MaterialColor.PURPLE));
public static final Block CRYSTAL_MOSS = registerBlock("crystal_moss", new EndTerrainBlock(MaterialColor.PINK)); public static final Block CRYSTAL_MOSS = registerBlock("crystal_moss", new EndTerrainBlock(MaterialColor.PINK));
public static final Block SHADOW_GRASS = registerBlock("shadow_grass", new ShadowGrassBlock()); public static final Block SHADOW_GRASS = registerBlock("shadow_grass", new ShadowGrassBlock());
public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.PINK)); public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.PINK));
@ -322,6 +323,7 @@ public class EndBlocks {
public static final Block BULB_VINE_SEED = registerBlock("bulb_vine_seed", new BulbVineSeedBlock()); public static final Block BULB_VINE_SEED = registerBlock("bulb_vine_seed", new BulbVineSeedBlock());
public static final Block BULB_VINE = registerBlock("bulb_vine", new BulbVineBlock()); public static final Block BULB_VINE = registerBlock("bulb_vine", new BulbVineBlock());
public static final Block JUNGLE_VINE = registerBlock("jungle_vine", new VineBlock()); public static final Block JUNGLE_VINE = registerBlock("jungle_vine", new VineBlock());
public static final Block RUBINEA = registerBlock("rubinea", new VineBlock());
// Mob-Related // Mob-Related
public static final Block SILK_MOTH_NEST = registerBlock("silk_moth_nest", new SilkMothNestBlock()); public static final Block SILK_MOTH_NEST = registerBlock("silk_moth_nest", new SilkMothNestBlock());

View file

@ -0,0 +1,7 @@
{
"variants": {
"shape=top": { "model": "betterend:block/rubinea_middle" },
"shape=middle": { "model": "betterend:block/rubinea_middle" },
"shape=bottom": { "model": "betterend:block/rubinea_bottom" }
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/rubinea_bottom"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/rubinea"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:block/rubinea_bottom"
}
}

View file

@ -0,0 +1,22 @@
{
"variants": {
"shape=bottom": [
{ "model": "betterend:pattern/%block%" },
{ "model": "betterend:pattern/%block%", "y": 90 },
{ "model": "betterend:pattern/%block%", "y": 180 },
{ "model": "betterend:pattern/%block%", "y": 270 }
],
"shape=middle": [
{ "model": "betterend:pattern/%block%_middle" },
{ "model": "betterend:pattern/%block%_middle", "y": 90 },
{ "model": "betterend:pattern/%block%_middle", "y": 180 },
{ "model": "betterend:pattern/%block%_middle", "y": 270 }
],
"shape=top": [
{ "model": "betterend:pattern/%block%" },
{ "model": "betterend:pattern/%block%", "x": 180, "y": 90 },
{ "model": "betterend:pattern/%block%", "x": 180, "y": 180 },
{ "model": "betterend:pattern/%block%", "x": 180, "y": 270 }
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 223 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B