Ice stars update
This commit is contained in:
parent
0ddc5e44eb
commit
a6b778b9d7
2 changed files with 38 additions and 32 deletions
|
@ -5,7 +5,6 @@ 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.particle.ParticleEffect;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -13,6 +12,7 @@ import ru.betterend.blocks.basis.BlockBase;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class BlockAncientEmeraldIce extends BlockBase {
|
||||
public BlockAncientEmeraldIce() {
|
||||
|
@ -22,6 +22,18 @@ public class BlockAncientEmeraldIce extends BlockBase {
|
|||
@Override
|
||||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
Direction dir = BlocksHelper.randomDirection(random);
|
||||
|
||||
if (random.nextBoolean()) {
|
||||
int x = MHelper.randRange(-2, 2, random);
|
||||
int y = MHelper.randRange(-2, 2, random);
|
||||
int z = MHelper.randRange(-2, 2, random);
|
||||
BlockPos p = pos.add(x, y, z);
|
||||
if (world.getBlockState(p).isOf(Blocks.WATER)) {
|
||||
world.setBlockState(p, EndBlocks.EMERALD_ICE.getDefaultState());
|
||||
makeParticles(world, p, random);
|
||||
}
|
||||
}
|
||||
|
||||
pos = pos.offset(dir);
|
||||
state = world.getBlockState(pos);
|
||||
if (state.isOf(Blocks.WATER)) {
|
||||
|
@ -35,12 +47,6 @@ public class BlockAncientEmeraldIce extends BlockBase {
|
|||
}
|
||||
|
||||
private void makeParticles(ServerWorld world, BlockPos pos, Random random) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
int side = random.nextInt(3);
|
||||
double x = (side == 0 ? random.nextDouble() : random.nextBoolean() ? 0 : 1) + pos.getX();
|
||||
double y = (side == 1 ? random.nextDouble() : random.nextBoolean() ? 0 : 1) + pos.getY();
|
||||
double z = (side == 2 ? random.nextDouble() : random.nextBoolean() ? 0 : 1) + pos.getZ();
|
||||
world.addParticle(EndParticles.SNOWFLAKE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
world.spawnParticles(EndParticles.SNOWFLAKE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.5, 0.5, 0.5, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue