Mossy bone, multiple terrain plants
This commit is contained in:
parent
ed286099ee
commit
d32eae2c06
11 changed files with 102 additions and 8 deletions
56
src/main/java/ru/betterend/blocks/MossyBoneBlock.java
Normal file
56
src/main/java/ru/betterend/blocks/MossyBoneBlock.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.SnowBlock;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.enchantment.Enchantments;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.loot.context.LootContext;
|
||||||
|
import net.minecraft.loot.context.LootContextParameters;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.WorldView;
|
||||||
|
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||||
|
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||||
|
|
||||||
|
public class MossyBoneBlock extends EndPillarBlock {
|
||||||
|
public MossyBoneBlock() {
|
||||||
|
super(FabricBlockSettings.copyOf(Blocks.BONE_BLOCK).hardness(0.5F).ticksRandomly());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
|
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
||||||
|
if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
|
return Collections.singletonList(new ItemStack(this));
|
||||||
|
}
|
||||||
|
return Collections.singletonList(new ItemStack(Blocks.BONE_BLOCK));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||||
|
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
|
||||||
|
world.setBlockState(pos, Blocks.BONE_BLOCK.getDefaultState().with(AXIS, state.get(AXIS)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canSurvive(BlockState state, WorldView worldView, BlockPos pos) {
|
||||||
|
BlockPos blockPos = pos.up();
|
||||||
|
BlockState blockState = worldView.getBlockState(blockPos);
|
||||||
|
if (blockState.isOf(Blocks.SNOW) && (Integer)blockState.get(SnowBlock.LAYERS) == 1) {
|
||||||
|
return true;
|
||||||
|
} else if (blockState.getFluidState().getLevel() == 8) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
int i = ChunkLightProvider.getRealisticOpacity(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getOpacity(worldView, blockPos));
|
||||||
|
return i < 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,15 +5,20 @@ import net.minecraft.block.BlockState;
|
||||||
import ru.betterend.blocks.basis.EndPlantBlock;
|
import ru.betterend.blocks.basis.EndPlantBlock;
|
||||||
|
|
||||||
public class TerrainPlantBlock extends EndPlantBlock {
|
public class TerrainPlantBlock extends EndPlantBlock {
|
||||||
private final Block ground;
|
private final Block[] ground;
|
||||||
|
|
||||||
public TerrainPlantBlock(Block ground) {
|
public TerrainPlantBlock(Block... ground) {
|
||||||
super(true);
|
super(true);
|
||||||
this.ground = ground;
|
this.ground = ground;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTerrain(BlockState state) {
|
protected boolean isTerrain(BlockState state) {
|
||||||
return state.isOf(ground);
|
for (Block block: ground) {
|
||||||
|
if (state.isOf(block)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ import ru.betterend.blocks.LumecornSeedBlock;
|
||||||
import ru.betterend.blocks.MengerSpongeBlock;
|
import ru.betterend.blocks.MengerSpongeBlock;
|
||||||
import ru.betterend.blocks.MengerSpongeWetBlock;
|
import ru.betterend.blocks.MengerSpongeWetBlock;
|
||||||
import ru.betterend.blocks.MissingTileBlock;
|
import ru.betterend.blocks.MissingTileBlock;
|
||||||
|
import ru.betterend.blocks.MossyBoneBlock;
|
||||||
import ru.betterend.blocks.MossyGlowshroomCapBlock;
|
import ru.betterend.blocks.MossyGlowshroomCapBlock;
|
||||||
import ru.betterend.blocks.MossyGlowshroomHymenophoreBlock;
|
import ru.betterend.blocks.MossyGlowshroomHymenophoreBlock;
|
||||||
import ru.betterend.blocks.MossyGlowshroomSaplingBlock;
|
import ru.betterend.blocks.MossyGlowshroomSaplingBlock;
|
||||||
|
@ -144,6 +145,7 @@ public class EndBlocks {
|
||||||
public static final Block RUTISCUS_PATH = registerBlock("rutiscus_path", new EndPathBlock(RUTISCUS));
|
public static final Block RUTISCUS_PATH = registerBlock("rutiscus_path", new EndPathBlock(RUTISCUS));
|
||||||
|
|
||||||
public static final Block MOSSY_OBSIDIAN = registerBlock("mossy_obsidian", new MossyObsidian());
|
public static final Block MOSSY_OBSIDIAN = registerBlock("mossy_obsidian", new MossyObsidian());
|
||||||
|
public static final Block MOSSY_BONE = registerBlock("mossy_bone", new MossyBoneBlock());
|
||||||
|
|
||||||
// Rocks //
|
// Rocks //
|
||||||
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND);
|
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND);
|
||||||
|
@ -231,8 +233,8 @@ public class EndBlocks {
|
||||||
public static final Block SALTEAGO = registerBlock("salteago", new TerrainPlantBlock(END_MOSS));
|
public static final Block SALTEAGO = registerBlock("salteago", new TerrainPlantBlock(END_MOSS));
|
||||||
public static final Block VAIOLUSH_FERN = registerBlock("vaiolush_fern", new TerrainPlantBlock(END_MOSS));
|
public static final Block VAIOLUSH_FERN = registerBlock("vaiolush_fern", new TerrainPlantBlock(END_MOSS));
|
||||||
public static final Block FRACTURN = registerBlock("fracturn", new TerrainPlantBlock(END_MOSS));
|
public static final Block FRACTURN = registerBlock("fracturn", new TerrainPlantBlock(END_MOSS));
|
||||||
public static final Block CLAWFERN = registerBlock("clawfern", new TerrainPlantBlock(SANGNUM));
|
public static final Block CLAWFERN = registerBlock("clawfern", new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_BONE));
|
||||||
public static final Block GLOBULAGUS = registerBlock("globulagus", new TerrainPlantBlock(SANGNUM));
|
public static final Block GLOBULAGUS = registerBlock("globulagus", new TerrainPlantBlock(SANGNUM, MOSSY_OBSIDIAN, MOSSY_BONE));
|
||||||
public static final Block ORANGO = registerBlock("orango", new TerrainPlantBlock(RUTISCUS));
|
public static final Block ORANGO = registerBlock("orango", new TerrainPlantBlock(RUTISCUS));
|
||||||
public static final Block AERIDIUM = registerBlock("aeridium", new TerrainPlantBlock(RUTISCUS));
|
public static final Block AERIDIUM = registerBlock("aeridium", new TerrainPlantBlock(RUTISCUS));
|
||||||
public static final Block LUTEBUS = registerBlock("lutebus", new TerrainPlantBlock(RUTISCUS));
|
public static final Block LUTEBUS = registerBlock("lutebus", new TerrainPlantBlock(RUTISCUS));
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"axis=x": { "model": "betterend:block/mossy_bone_hor", "y": 90 },
|
||||||
|
"axis=y": { "model": "betterend:block/mossy_bone_ver" },
|
||||||
|
"axis=z": { "model": "betterend:block/mossy_bone_hor" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube",
|
||||||
|
"textures": {
|
||||||
|
"down": "block/bone_block_side",
|
||||||
|
"east": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"north": "betterend:block/mossy_bone_cut",
|
||||||
|
"particle": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"south": "betterend:block/mossy_bone_cut",
|
||||||
|
"up": "betterend:block/sangnum_top",
|
||||||
|
"west": "betterend:block/mossy_bone_side_ver"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube",
|
||||||
|
"textures": {
|
||||||
|
"down": "block/bone_block_top",
|
||||||
|
"east": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"north": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"particle": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"south": "betterend:block/mossy_bone_side_ver",
|
||||||
|
"up": "betterend:block/sangnum_top",
|
||||||
|
"west": "betterend:block/mossy_bone_side_ver"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "betterend:block/amaranita_hyphae"
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/mossy_bone_ver"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 268 B |
Binary file not shown.
After Width: | Height: | Size: 251 B |
Binary file not shown.
After Width: | Height: | Size: 251 B |
Loading…
Add table
Add a link
Reference in a new issue