[Feature] Renewable smaragdant
Merge pull request #97 from Necrontyrr/budding-smaragdant
This commit is contained in:
commit
503c55549d
10 changed files with 115 additions and 4 deletions
|
@ -0,0 +1,66 @@
|
||||||
|
package org.betterx.betterend.blocks;
|
||||||
|
|
||||||
|
import org.betterx.bclib.interfaces.tools.AddMineablePickaxe;
|
||||||
|
import org.betterx.bclib.util.BlocksHelper;
|
||||||
|
import org.betterx.betterend.blocks.basis.LitPillarBlock;
|
||||||
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.material.Fluids;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.level.material.PushReaction;
|
||||||
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BuddingSmaragdantCrystalBlock extends LitPillarBlock implements AddMineablePickaxe {
|
||||||
|
public BuddingSmaragdantCrystalBlock() {
|
||||||
|
super(FabricBlockSettings.of(Material.GLASS)
|
||||||
|
.luminance(15)
|
||||||
|
.hardness(1F)
|
||||||
|
.resistance(1F)
|
||||||
|
.noOcclusion()
|
||||||
|
.sound(SoundType.AMETHYST)
|
||||||
|
.randomTicks());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PushReaction getPistonPushReaction(BlockState blockState) {
|
||||||
|
return PushReaction.DESTROY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public void randomTick(BlockState blockState, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||||
|
Direction dir = BlocksHelper.randomDirection(random);
|
||||||
|
BlockPos side = pos.relative(dir);
|
||||||
|
BlockState sideState = world.getBlockState(side);
|
||||||
|
if (random.nextInt(20) == 0) {
|
||||||
|
if (canShardGrowAtState(sideState)) {
|
||||||
|
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState()
|
||||||
|
.setValue(SmaragdantCrystalShardBlock.WATERLOGGED, sideState.getFluidState().getType() == Fluids.WATER)
|
||||||
|
.setValue(SmaragdantCrystalShardBlock.FACING, dir);
|
||||||
|
world.setBlockAndUpdate(side, shard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canShardGrowAtState(BlockState blockState) {
|
||||||
|
return blockState.isAir() || blockState.is(Blocks.WATER) && blockState.getFluidState().getAmount() == 8;
|
||||||
|
}
|
||||||
|
}
|
|
@ -489,6 +489,12 @@ public class CraftingRecipes {
|
||||||
.setOutputCount(4)
|
.setOutputCount(4)
|
||||||
.addMaterial('#', EndBlocks.DRAGON_BONE_BLOCK)
|
.addMaterial('#', EndBlocks.DRAGON_BONE_BLOCK)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
BCLRecipeBuilder.crafting(BetterEnd.makeID("smaragdant_crystal"), EndBlocks.SMARAGDANT_CRYSTAL)
|
||||||
|
.checkConfig(Configs.RECIPE_CONFIG)
|
||||||
|
.setShape("##", "##")
|
||||||
|
.addMaterial('#', EndBlocks.SMARAGDANT_CRYSTAL_SHARD)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerLantern(String name, Block lantern, Block slab) {
|
private static void registerLantern(String name, Block lantern, Block slab) {
|
||||||
|
|
|
@ -638,6 +638,7 @@ public class EndBlocks {
|
||||||
"smaragdant_crystal",
|
"smaragdant_crystal",
|
||||||
SMARAGDANT_CRYSTAL
|
SMARAGDANT_CRYSTAL
|
||||||
);
|
);
|
||||||
|
public static final Block BUDDING_SMARAGDANT_CRYSTAL = registerBlock("budding_smaragdant_crystal", new BuddingSmaragdantCrystalBlock());
|
||||||
|
|
||||||
public static final Block RESPAWN_OBELISK = registerBlock("respawn_obelisk", new RespawnObeliskBlock());
|
public static final Block RESPAWN_OBELISK = registerBlock("respawn_obelisk", new RespawnObeliskBlock());
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package org.betterx.betterend.world.features.terrain;
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
|
import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
|
||||||
import org.betterx.bclib.util.BlocksHelper;
|
import org.betterx.bclib.util.BlocksHelper;
|
||||||
import org.betterx.bclib.util.MHelper;
|
import org.betterx.bclib.util.MHelper;
|
||||||
|
import org.betterx.betterend.blocks.BuddingSmaragdantCrystalBlock;
|
||||||
|
import org.betterx.betterend.blocks.SmaragdantCrystalShardBlock;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||||
|
|
||||||
|
@ -14,6 +16,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.material.Fluids;
|
||||||
|
|
||||||
public class SmaragdantCrystalFeature extends DefaultFeature {
|
public class SmaragdantCrystalFeature extends DefaultFeature {
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,6 +33,7 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
|
||||||
int count = MHelper.randRange(15, 30, random);
|
int count = MHelper.randRange(15, 30, random);
|
||||||
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState();
|
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState();
|
||||||
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState();
|
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState();
|
||||||
|
BlockState buddingCrystal = EndBlocks.BUDDING_SMARAGDANT_CRYSTAL.defaultBlockState();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
mut.set(pos)
|
mut.set(pos)
|
||||||
.move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
.move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
|
||||||
|
@ -42,10 +47,26 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
|
||||||
mut.setY(mut.getY() - 1);
|
mut.setY(mut.getY() - 1);
|
||||||
state = world.getBlockState(mut);
|
state = world.getBlockState(mut);
|
||||||
}
|
}
|
||||||
if (state.is(CommonBlockTags.GEN_END_STONES) && !world.getBlockState(mut.above())
|
if (state.is(CommonBlockTags.GEN_END_STONES) && world.getBlockState(mut.above()).isAir()) {
|
||||||
.is(crystal.getBlock())) {
|
|
||||||
for (int j = 0; j <= dist; j++) {
|
for (int j = 0; j <= dist; j++) {
|
||||||
|
if (random.nextInt(8) == 0) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, buddingCrystal);
|
||||||
|
for (Direction k : BlocksHelper.HORIZONTAL) {
|
||||||
|
BlockPos sidePos = mut.relative(k);
|
||||||
|
BlockState sideState = world.getBlockState(sidePos);
|
||||||
|
if (BuddingSmaragdantCrystalBlock.canShardGrowAtState(sideState)) {
|
||||||
|
if (random.nextBoolean()) {
|
||||||
|
BlockState attachedShard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState()
|
||||||
|
.setValue(SmaragdantCrystalShardBlock.WATERLOGGED,
|
||||||
|
sideState.getFluidState().getType() == Fluids.WATER)
|
||||||
|
.setValue(SmaragdantCrystalShardBlock.FACING, k);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, sidePos, attachedShard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, crystal);
|
BlocksHelper.setWithoutUpdate(world, mut, crystal);
|
||||||
|
}
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
}
|
}
|
||||||
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
boolean waterlogged = !world.getFluidState(mut).isEmpty();
|
||||||
|
|
|
@ -670,6 +670,7 @@
|
||||||
"block.betterend.sandy_jadestone_tiles": "Sandy Jadestone Tiles",
|
"block.betterend.sandy_jadestone_tiles": "Sandy Jadestone Tiles",
|
||||||
"block.betterend.sandy_jadestone_wall": "Sandy Jadestone Wall",
|
"block.betterend.sandy_jadestone_wall": "Sandy Jadestone Wall",
|
||||||
"block.betterend.smaragdant_crystal": "Smaragdant Crystal",
|
"block.betterend.smaragdant_crystal": "Smaragdant Crystal",
|
||||||
|
"block.betterend.budding_smaragdant_crystal": "Budding Smaragdant Crystal",
|
||||||
"block.betterend.smaragdant_crystal_shard": "Smaragdant Crystal Shard",
|
"block.betterend.smaragdant_crystal_shard": "Smaragdant Crystal Shard",
|
||||||
"block.betterend.virid_jadestone": "Virid Jadestone",
|
"block.betterend.virid_jadestone": "Virid Jadestone",
|
||||||
"block.betterend.virid_jadestone_bricks": "Virid Jadestone Bricks",
|
"block.betterend.virid_jadestone_bricks": "Virid Jadestone Bricks",
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube",
|
||||||
|
"textures": {
|
||||||
|
"down": "betterend:block/budding_smaragdant_crystal_top",
|
||||||
|
"east": "betterend:block/budding_smaragdant_crystal_side",
|
||||||
|
"north": "betterend:block/budding_smaragdant_crystal_side",
|
||||||
|
"particle": "betterend:block/budding_smaragdant_crystal_side",
|
||||||
|
"south": "betterend:block/budding_smaragdant_crystal_side",
|
||||||
|
"up": "betterend:block/budding_smaragdant_crystal_top",
|
||||||
|
"west": "betterend:block/budding_smaragdant_crystal_side"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/budding_smaragdant_crystal"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 264 B |
Binary file not shown.
After Width: | Height: | Size: 268 B |
|
@ -349,6 +349,7 @@
|
||||||
"betterend:aeternium_ingot",
|
"betterend:aeternium_ingot",
|
||||||
"betterend:sulphuric_rock_flower_pot",
|
"betterend:sulphuric_rock_flower_pot",
|
||||||
"betterend:umbrella_tree_gate",
|
"betterend:umbrella_tree_gate",
|
||||||
"betterend:jellyshroom_composter"
|
"betterend:jellyshroom_composter",
|
||||||
|
"betterend:smaragdant_crystal"
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue