Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd
This commit is contained in:
commit
7584321c47
8 changed files with 184 additions and 31 deletions
|
@ -9,10 +9,8 @@ import com.google.common.collect.Maps;
|
|||
import net.fabricmc.fabric.api.client.model.ModelProviderContext;
|
||||
import net.fabricmc.fabric.api.client.model.ModelProviderException;
|
||||
import net.fabricmc.fabric.api.client.model.ModelResourceProvider;
|
||||
|
||||
import net.minecraft.client.render.model.UnbakedModel;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class EndModelProvider implements ModelResourceProvider {
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.enchantment.EnchantmentHelper;
|
|||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.mob.EndermanEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import ru.betterend.effects.EndEnchantments;
|
||||
import ru.betterend.effects.EndStatusEffects;
|
||||
|
||||
|
|
|
@ -6,12 +6,14 @@ import net.minecraft.world.gen.GenerationStep.Feature;
|
|||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.world.structures.EndStructureFeature;
|
||||
import ru.betterend.world.structures.features.StructureGiantMossyGlowshroom;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
import ru.betterend.world.structures.piece.MountainPiece;
|
||||
import ru.betterend.world.structures.piece.VoxelPiece;
|
||||
|
||||
public class StructureRegistry {
|
||||
public static final StructurePieceType VOXEL_PIECE = register("voxel", VoxelPiece::new);
|
||||
public static final StructurePieceType MOUNTAIN_PIECE = register("mountain_piece", MountainPiece::new);
|
||||
public static final StructurePieceType CAVE_PIECE = register("cave_piece", CavePiece::new);
|
||||
|
||||
public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8);
|
||||
|
||||
|
|
|
@ -93,6 +93,10 @@ public class MHelper {
|
|||
return (float) Math.sqrt(lengthSqr(x, y));
|
||||
}
|
||||
|
||||
public static double length(double x, double y) {
|
||||
return Math.sqrt(lengthSqr(x, y));
|
||||
}
|
||||
|
||||
public static float dot(float x1, float y1, float z1, float x2, float y2, float z2) {
|
||||
return x1 * x2 + y1 * y2 + z1 * z2;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
POS.setX(x);
|
||||
int x2 = x - blockPos.getX();
|
||||
|
@ -95,10 +94,16 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
z2 *= z2;
|
||||
int mz = z - maskMinZ;
|
||||
if (!mask[mx][mz]) {
|
||||
for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) {
|
||||
double size = 1;
|
||||
for (int y = blockPos.getY(); y <= blockPos.getY() + 20; y++) {
|
||||
POS.setY(y);
|
||||
int add = y - blockPos.getY();
|
||||
double r = add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75);
|
||||
double add = y - blockPos.getY();
|
||||
if (add > 5) {
|
||||
size *= 0.8;
|
||||
add = 5;
|
||||
}
|
||||
double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) - 1.0 / size;
|
||||
if (r > 0) {
|
||||
r *= r;
|
||||
if (x2 + z2 <= r) {
|
||||
state = world.getBlockState(POS);
|
||||
|
@ -117,6 +122,10 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
|||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.structures.piece.CavePiece;
|
||||
import ru.betterend.world.structures.piece.MountainPiece;
|
||||
|
||||
public class StructureMountain extends StructureFeatureBase {
|
||||
|
@ -32,7 +33,27 @@ public class StructureMountain extends StructureFeatureBase {
|
|||
if (y > 5) {
|
||||
float radius = MHelper.randRange(50, 100, random);
|
||||
float height = radius * MHelper.randRange(0.8F, 1.2F, random);
|
||||
this.children.add(new MountainPiece(new BlockPos(x, y, z), radius, height, random.nextInt()));
|
||||
MountainPiece piece = new MountainPiece(new BlockPos(x, y, z), radius, height, random.nextInt());
|
||||
this.children.add(piece);
|
||||
|
||||
int count = (int) (radius / 15);
|
||||
for (int i = 0; i < count; i++) {
|
||||
double px = random.nextGaussian() * radius * 0.5 + x;
|
||||
double pz = random.nextGaussian() * radius * 0.5 + z;
|
||||
float rad = MHelper.randRange(10, 30, random);
|
||||
|
||||
int posX = MHelper.floor(px);
|
||||
int posZ = MHelper.floor(pz);
|
||||
|
||||
int minY = chunkGenerator.getHeight(posX, posZ, Type.WORLD_SURFACE_WG);
|
||||
if (minY > 56) {
|
||||
int maxY = MHelper.floor(piece.getProtoHeight(posX, minY, posZ) - rad);
|
||||
if (maxY > 20) {
|
||||
int posY = MHelper.randRange(20, maxY, random);
|
||||
this.children.add(new CavePiece(new BlockPos(posX, posY, posZ), rad, random.nextInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setBoundingBoxFromChildren();
|
||||
}
|
||||
|
|
107
src/main/java/ru/betterend/world/structures/piece/CavePiece.java
Normal file
107
src/main/java/ru/betterend/world/structures/piece/CavePiece.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
import net.minecraft.structure.StructureManager;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.registry.StructureRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class CavePiece extends BasePiece {
|
||||
private OpenSimplexNoise noise;
|
||||
private BlockPos center;
|
||||
private float radius;
|
||||
|
||||
public CavePiece(BlockPos center, float radius, int id) {
|
||||
super(StructureRegistry.CAVE_PIECE, id);
|
||||
this.center = center;
|
||||
this.radius = radius;
|
||||
this.noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
makeBoundingBox();
|
||||
}
|
||||
|
||||
public CavePiece(StructureManager manager, CompoundTag tag) {
|
||||
super(StructureRegistry.CAVE_PIECE, tag);
|
||||
makeBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, StructureAccessor arg, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
int x1 = MHelper.max(this.boundingBox.minX, blockBox.minX);
|
||||
int z1 = MHelper.max(this.boundingBox.minZ, blockBox.minZ);
|
||||
int x2 = MHelper.min(this.boundingBox.maxX, blockBox.maxX);
|
||||
int z2 = MHelper.min(this.boundingBox.maxZ, blockBox.maxZ);
|
||||
int y1 = this.boundingBox.minY;
|
||||
int y2 = this.boundingBox.maxY;
|
||||
|
||||
double hr = radius * 0.75;
|
||||
double nr = radius * 0.25;
|
||||
Mutable pos = new Mutable();
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xsq = x - center.getX();
|
||||
xsq *= xsq;
|
||||
pos.setX(x);
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
int zsq = z - center.getZ();
|
||||
zsq *= zsq;
|
||||
pos.setZ(z);
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
int ysq = y - center.getY();
|
||||
ysq *= 1.6;
|
||||
ysq *= ysq;
|
||||
pos.setY(y);
|
||||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||
double r2 = r - 4.5;
|
||||
double dist = xsq + ysq + zsq;
|
||||
if (dist < r2 * r2) {
|
||||
if (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
}
|
||||
}
|
||||
else if (dist < r * r) {
|
||||
if (world.getBlockState(pos).getMaterial().isReplaceable()) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, Blocks.END_STONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toNbt(CompoundTag tag) {
|
||||
tag.put("center", NbtHelper.fromBlockPos(center));
|
||||
tag.putFloat("radius", radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fromNbt(CompoundTag tag) {
|
||||
center = NbtHelper.toBlockPos(tag.getCompound("center"));
|
||||
radius = tag.getFloat("radius");
|
||||
noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
|
||||
}
|
||||
|
||||
private void makeBoundingBox() {
|
||||
int minX = MHelper.floor(center.getX() - radius);
|
||||
int minY = MHelper.floor(center.getY() - radius);
|
||||
int minZ = MHelper.floor(center.getZ() - radius);
|
||||
int maxX = MHelper.floor(center.getX() + radius + 1);
|
||||
int maxY = MHelper.floor(center.getY() + radius + 1);
|
||||
int maxZ = MHelper.floor(center.getZ() + radius + 1);
|
||||
this.boundingBox = new BlockBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
|
@ -87,18 +87,10 @@ public class MountainPiece extends BasePiece {
|
|||
if (maxY > 0) {
|
||||
maxY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
|
||||
maxY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
|
||||
//float rigid = Math.abs(1F - (float) noise.eval(px * 0.1, pz * 0.1)) * maxY / 20F - 0.5F;
|
||||
maxY += minY;
|
||||
//float surf = maxY - 3;
|
||||
for (int y = minY; y < maxY; y++) {
|
||||
pos.setY(y);
|
||||
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
||||
/*if (y > surf && rigid > 0.5) {
|
||||
chunk.setBlockState(pos, BlockRegistry.AURORA_CRYSTAL.getDefaultState(), false);
|
||||
}
|
||||
else {
|
||||
chunk.setBlockState(pos, Blocks.END_STONE.getDefaultState(), false);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +139,27 @@ public class MountainPiece extends BasePiece {
|
|||
return true;
|
||||
}
|
||||
|
||||
public int getProtoHeight(int px, int py, int pz) {
|
||||
int px2 = px - center.getX();
|
||||
px2 *= px2;
|
||||
|
||||
int pz2 = pz - center.getZ();
|
||||
pz2 *= pz2;
|
||||
float dist = px2 + pz2;
|
||||
|
||||
dist = 1 - (float) Math.pow(dist / r2, 0.3);
|
||||
if (py > 56) {
|
||||
float maxY = dist * height;
|
||||
if (maxY > 0) {
|
||||
maxY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
|
||||
maxY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
|
||||
return MHelper.floor(maxY + py * ((float) MathHelper.clamp((py - 57) / 7F, 0, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
return py;
|
||||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.END_HIGHLANDS) {
|
||||
return -4;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue