Fixes, particle behavior
This commit is contained in:
parent
31ced5c19d
commit
34800a80c3
8 changed files with 49 additions and 47 deletions
|
@ -1,9 +1,5 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -19,7 +15,6 @@ import net.minecraft.fluid.Fluid;
|
|||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
|
@ -28,13 +23,11 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEntityProvider, FluidFillable, Waterloggable {
|
||||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
|
||||
|
@ -97,20 +90,6 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti
|
|||
return (Boolean) state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return new BlockEntityHydrothermalVent();
|
||||
|
|
|
@ -16,6 +16,7 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.random.nextInt(32) == 0) {
|
||||
double x = pos.getX() + world.random.nextDouble();
|
||||
double y = pos.getY() + 0.9 + world.random.nextDouble() * 0.3;
|
||||
double z = pos.getZ() + world.random.nextDouble();
|
||||
|
@ -29,4 +30,5 @@ public class BlockEntityHydrothermalVent extends BlockEntity implements Tickable
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package ru.betterend.blocks.entities.render;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
|
@ -16,7 +15,6 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.BlockPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
|
|
|
@ -9,23 +9,49 @@ import net.minecraft.client.particle.SpriteBillboardParticle;
|
|||
import net.minecraft.client.particle.SpriteProvider;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ParticleGeyser extends SpriteBillboardParticle {
|
||||
private Mutable mut = new Mutable();
|
||||
private boolean changeDir = false;
|
||||
private boolean check = true;
|
||||
|
||||
protected ParticleGeyser(ClientWorld world, double x, double y, double z, double vx, double vy, double vz, SpriteProvider sprites) {
|
||||
super(world, x, y, z, vx, vy, vz);
|
||||
setSprite(sprites);
|
||||
this.maxAge = MHelper.randRange(600, 1200, random);
|
||||
this.maxAge = MHelper.randRange(400, 800, random);
|
||||
this.scale = MHelper.randRange(0.5F, 1.0F, random);
|
||||
this.velocityX = vx;
|
||||
this.velocityZ = vz;
|
||||
this.prevPosY = y - 0.125;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.age >= this.maxAge + 40) {
|
||||
this.setColorAlpha((this.maxAge - this.age) / 40F);
|
||||
|
||||
if (this.prevPosY == this.y || this.age > this.maxAge) {
|
||||
this.markDead();
|
||||
}
|
||||
else {
|
||||
if (this.age >= this.maxAge - 200) {
|
||||
this.setColorAlpha((this.maxAge - this.age) / 200F);
|
||||
}
|
||||
|
||||
this.scale += 0.005F;
|
||||
this.velocityY = 0.125;
|
||||
|
||||
if (changeDir) {
|
||||
changeDir = false;
|
||||
this.velocityX += MHelper.randRange(-0.2, 0.2, random);
|
||||
this.velocityZ += MHelper.randRange(-0.2, 0.2, random);
|
||||
}
|
||||
else if (check) {
|
||||
changeDir = world.getBlockState(mut).getFluidState().isEmpty();
|
||||
check = !changeDir;
|
||||
}
|
||||
}
|
||||
super.tick();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ParticleSulphur extends SpriteBillboardParticle {
|
|||
if (this.age <= 40) {
|
||||
this.setColorAlpha(this.age / 40F);
|
||||
}
|
||||
else if (this.age >= this.maxAge + 40) {
|
||||
else if (this.age >= this.maxAge - 40) {
|
||||
this.setColorAlpha((this.maxAge - this.age) / 40F);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import ru.betterend.blocks.BlockEndLotusSeed;
|
|||
import ru.betterend.blocks.BlockEndLotusStem;
|
||||
import ru.betterend.blocks.BlockEndstoneDust;
|
||||
import ru.betterend.blocks.BlockGlowingMoss;
|
||||
import ru.betterend.blocks.BlockHydrothermalVent;
|
||||
import ru.betterend.blocks.BlockLacugroveSapling;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomCap;
|
||||
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
||||
|
@ -39,7 +40,6 @@ import ru.betterend.blocks.BlockPythadendronSapling;
|
|||
import ru.betterend.blocks.BlockShadowBerry;
|
||||
import ru.betterend.blocks.BlockShadowGrass;
|
||||
import ru.betterend.blocks.BlockSulphurCrystal;
|
||||
import ru.betterend.blocks.BlockHydrothermalVent;
|
||||
import ru.betterend.blocks.BlockTenaneaFlowers;
|
||||
import ru.betterend.blocks.BlockTenaneaSapling;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.function.Function;
|
|||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -148,8 +147,8 @@ public class GeyserFeature extends DefaultFeature {
|
|||
mut.setY(mut.getY() + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
mut.set(pos).add(random.nextGaussian() * 4, -halfHeight - 10, random.nextGaussian() * 4);
|
||||
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));
|
||||
int dist = MHelper.floor(6 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
|
||||
BlockState state = world.getBlockState(mut);
|
||||
while (state.isOf(Blocks.WATER)) {
|
||||
|
@ -177,10 +176,7 @@ public class GeyserFeature extends DefaultFeature {
|
|||
};
|
||||
|
||||
REPLACE2 = (state) -> {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(EndBlocks.HYDROTHERMAL_VENT) || state.isOf(EndBlocks.SULPHUR_CRYSTAL)) {
|
||||
return true;
|
||||
}
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
|
|
|
@ -9,8 +9,8 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
@ -103,6 +103,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
|||
|
||||
private boolean isReplaceable(BlockState state) {
|
||||
return state.isIn(EndTags.GEN_TERRAIN)
|
||||
|| state.isOf(EndBlocks.HYDROTHERMAL_VENT)
|
||||
|| state.isOf(EndBlocks.SULPHUR_CRYSTAL)
|
||||
|| state.getMaterial().isReplaceable()
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue