Vent particles optimization
This commit is contained in:
parent
329a59c7be
commit
b659424952
6 changed files with 66 additions and 8 deletions
|
@ -25,6 +25,7 @@ import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
import ru.betterend.blocks.BlockProperties.HydraluxShape;
|
||||||
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
|
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
import ru.betterend.registry.EndItems;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class BlockHydralux extends BlockUnderwaterPlant {
|
public class BlockHydralux extends BlockUnderwaterPlant {
|
||||||
|
@ -78,7 +79,10 @@ public class BlockHydralux extends BlockUnderwaterPlant {
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
HydraluxShape shape = state.get(SHAPE);
|
HydraluxShape shape = state.get(SHAPE);
|
||||||
if (shape == HydraluxShape.ROOTS) {
|
if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) {
|
||||||
|
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
|
||||||
|
}
|
||||||
|
else if (shape == HydraluxShape.ROOTS) {
|
||||||
return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
return Lists.newArrayList(new ItemStack(EndBlocks.HYDRALUX_SAPLING, MHelper.randRange(1, 2, MHelper.RANDOM)));
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Random;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -22,6 +24,7 @@ import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
|
@ -37,9 +40,11 @@ import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
import ru.betterend.registry.EndParticles;
|
||||||
|
|
||||||
public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable {
|
public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable {
|
||||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||||
|
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 1, 1, 15, 16, 15);
|
||||||
|
|
||||||
public BlockHydrothermalVent() {
|
public BlockHydrothermalVent() {
|
||||||
|
@ -48,12 +53,12 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti
|
||||||
.sounds(BlockSoundGroup.STONE)
|
.sounds(BlockSoundGroup.STONE)
|
||||||
.noCollision()
|
.noCollision()
|
||||||
.requiresTool());
|
.requiresTool());
|
||||||
this.setDefaultState(getDefaultState().with(WATERLOGGED, true));
|
this.setDefaultState(getDefaultState().with(WATERLOGGED, true).with(ACTIVATED, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
builder.add(WATERLOGGED);
|
builder.add(WATERLOGGED, ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,4 +121,20 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti
|
||||||
scheduledTick(state,(ServerWorld) world, pos, world.random);
|
scheduledTick(state,(ServerWorld) world, pos, world.random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||||
|
if (!state.get(ACTIVATED) && random.nextBoolean()) {
|
||||||
|
super.randomDisplayTick(state, world, pos, random);
|
||||||
|
double x = pos.getX() + random.nextDouble();
|
||||||
|
double y = pos.getY() + 0.9 + random.nextDouble() * 0.3;
|
||||||
|
double z = pos.getZ() + random.nextDouble();
|
||||||
|
if (state.get(WATERLOGGED)) {
|
||||||
|
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
world.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (world.random.nextInt(32) == 0) {
|
if (world.random.nextInt(20) == 0) {
|
||||||
double x = pos.getX() + world.random.nextDouble();
|
double x = pos.getX() + world.random.nextDouble();
|
||||||
double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3;
|
double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3;
|
||||||
double z = pos.getZ() + world.random.nextDouble();
|
double z = pos.getZ() + world.random.nextDouble();
|
||||||
BlockState state = getCachedState();
|
BlockState state = getCachedState();
|
||||||
if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
if (state.isOf(EndBlocks.HYDROTHERMAL_VENT) && state.get(BlockHydrothermalVent.ACTIVATED)) {
|
||||||
if (getCachedState().get(BlockHydrothermalVent.WATERLOGGED)) {
|
if (state.get(BlockHydrothermalVent.WATERLOGGED)) {
|
||||||
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
world.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class EndItems {
|
||||||
public final static Item AMBER_GEM = registerItem("amber_gem");
|
public final static Item AMBER_GEM = registerItem("amber_gem");
|
||||||
public final static Item GLOWING_BULB = registerItem("glowing_bulb");
|
public final static Item GLOWING_BULB = registerItem("glowing_bulb");
|
||||||
public final static Item CRYSTALLINE_SULPHUR = registerItem("crystalline_sulphur");
|
public final static Item CRYSTALLINE_SULPHUR = registerItem("crystalline_sulphur");
|
||||||
|
public final static Item HYDRALUX_PETAL = registerItem("hydralux_petal");
|
||||||
|
|
||||||
// Armor //
|
// Armor //
|
||||||
public static final Item TERMINITE_HELMET = registerItem("terminite_helmet", new ArmorItem(EndArmorMaterial.TERMINITE, EquipmentSlot.HEAD, makeSettings()));
|
public static final Item TERMINITE_HELMET = registerItem("terminite_helmet", new ArmorItem(EndArmorMaterial.TERMINITE, EquipmentSlot.HEAD, makeSettings()));
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
|
import ru.betterend.blocks.BlockHydrothermalVent;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
|
@ -150,7 +151,8 @@ public class GeyserFeature extends DefaultFeature {
|
||||||
|
|
||||||
for (int i = 0; i < 150; i++) {
|
for (int i = 0; i < 150; i++) {
|
||||||
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5));
|
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5));
|
||||||
int dist = MHelper.floor(6 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
|
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
|
||||||
|
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
|
||||||
if (dist >= 0) {
|
if (dist >= 0) {
|
||||||
BlockState state = world.getBlockState(mut);
|
BlockState state = world.getBlockState(mut);
|
||||||
while (state.isOf(Blocks.WATER)) {
|
while (state.isOf(Blocks.WATER)) {
|
||||||
|
@ -162,7 +164,37 @@ public class GeyserFeature extends DefaultFeature {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT);
|
state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(BlockHydrothermalVent.ACTIVATED, distRaw < 2);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||||
|
mut.setY(mut.getY() + 1);
|
||||||
|
state = world.getBlockState(mut);
|
||||||
|
while (state.isOf(Blocks.WATER)) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, Blocks.BUBBLE_COLUMN.getDefaultState().with(BubbleColumnBlock.DRAG, false));
|
||||||
|
world.getBlockTickScheduler().schedule(mut, Blocks.BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
|
||||||
|
mut.setY(mut.getY() + 1);
|
||||||
|
state = world.getBlockState(mut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
|
||||||
|
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
|
||||||
|
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
|
||||||
|
if (dist >= 0) {
|
||||||
|
BlockState state = world.getBlockState(mut);
|
||||||
|
while (state.isOf(Blocks.WATER)) {
|
||||||
|
mut.setY(mut.getY() - 1);
|
||||||
|
state = world.getBlockState(mut);
|
||||||
|
}
|
||||||
|
if (state.isIn(EndTags.GEN_TERRAIN)) {
|
||||||
|
for (int j = 0; j <= dist; j++) {
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
|
||||||
|
mut.setY(mut.getY() + 1);
|
||||||
|
}
|
||||||
|
state = EndBlocks.HYDROTHERMAL_VENT.getDefaultState().with(BlockHydrothermalVent.ACTIVATED, distRaw < 2);
|
||||||
|
BlocksHelper.setWithoutUpdate(world, mut, state);
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
state = world.getBlockState(mut);
|
state = world.getBlockState(mut);
|
||||||
while (state.isOf(Blocks.WATER)) {
|
while (state.isOf(Blocks.WATER)) {
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 371 B |
Loading…
Add table
Add a link
Reference in a new issue