Cleanup
This commit is contained in:
parent
42f8754912
commit
a51470210e
19 changed files with 0 additions and 880 deletions
|
@ -1,13 +0,0 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
|
||||
public class BlockSounds {
|
||||
public static final SoundType TERRAIN_SOUND = new SoundType(1.0F, 1.0F,
|
||||
SoundEvents.STONE_BREAK,
|
||||
SoundEvents.WART_BLOCK_STEP,
|
||||
SoundEvents.STONE_PLACE,
|
||||
SoundEvents.STONE_HIT,
|
||||
SoundEvents.STONE_FALL);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.bclib.blocks.BaseBlock;
|
||||
|
||||
public class TerminiteBlock extends BaseBlock {
|
||||
public TerminiteBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.WARPED_WART_BLOCK)
|
||||
.hardness(7F)
|
||||
.resistance(9F)
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.METAL));
|
||||
}
|
||||
}
|
|
@ -12,8 +12,6 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
@ -26,7 +24,6 @@ import net.minecraft.world.entity.Pose;
|
|||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.control.MoveControl;
|
||||
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -158,38 +155,4 @@ public class CubozoaEntity extends AbstractSchoolingFish {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class CubozoaMoveControl extends MoveControl {
|
||||
CubozoaMoveControl(CubozoaEntity owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (this.mob.isEyeInFluid(FluidTags.WATER)) {
|
||||
this.mob.setDeltaMovement(this.mob.getDeltaMovement().add(0.0D, 0.005D, 0.0D));
|
||||
}
|
||||
|
||||
if (this.operation == MoveControl.Operation.MOVE_TO && !this.mob.getNavigation().isDone()) {
|
||||
float f = (float) (this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED));
|
||||
this.mob.setSpeed(Mth.lerp(0.125F, this.mob.getSpeed(), f));
|
||||
double d = this.wantedX - this.mob.getX();
|
||||
double e = this.wantedY - this.mob.getY();
|
||||
double g = this.wantedZ - this.mob.getZ();
|
||||
if (e != 0.0D) {
|
||||
double h = (double) Mth.sqrt(d * d + e * e + g * g);
|
||||
this.mob.setDeltaMovement(this.mob.getDeltaMovement().add(0.0D, (double) this.mob.getSpeed() * (e / h) * 0.1D, 0.0D));
|
||||
}
|
||||
|
||||
if (d != 0.0D || g != 0.0D) {
|
||||
float i = (float) (Mth.atan2(g, d) * 57.2957763671875D) - 90.0F;
|
||||
this.mob.yRot = this.rotlerp(this.mob.yRot, i, 90.0F);
|
||||
this.mob.yBodyRot = this.mob.yRot;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.mob.setSpeed(0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
public class AdornIntegration extends ModIntegration {
|
||||
public AdornIntegration() {
|
||||
super("adorn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
//Class<?> adornBlockBuilder = getClass("juuxel.adorn.api.block.AdornBlockBuilder");
|
||||
//Class<?> blockVariantWood = getClass("juuxel.adorn.api.block.BlockVariant$Wood");
|
||||
//Class<?> blockVariant = getClass("juuxel.adorn.api.block.BlockVariant");
|
||||
|
||||
//Object testVariant = newInstance(blockVariantWood, BetterEnd.MOD_ID + "/mossy_glowshroom");
|
||||
//Method create = getMethod(adornBlockBuilder, "create", blockVariant);
|
||||
//Object builder = executeMethod(adornBlockBuilder, create, testVariant);
|
||||
//getAndExecuteRuntime(builder, "withEverything");
|
||||
//getAndExecuteRuntime(builder, "registerIn", BetterEnd.MOD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomes() {}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package ru.betterend.integration;
|
||||
|
||||
public class ExtraPiecesIntegration extends ModIntegration {
|
||||
public ExtraPiecesIntegration() {
|
||||
super("extrapieces");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
//Class<?> pieceSets = getClass("com.shnupbups.extrapieces.core.PieceSets");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomes() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package ru.betterend.integration.byg.biomes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
|
||||
import ru.bclib.world.biomes.BCLBiomeDef;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.integration.byg.features.BYGFeatures;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class EterialGrove extends EndBiome {
|
||||
public EterialGrove() {
|
||||
super(makeDef());
|
||||
}
|
||||
|
||||
private static BCLBiomeDef makeDef() {
|
||||
Biome biome = Integrations.BYG.getBiome("ethereal_islands");
|
||||
BiomeSpecialEffects effects = biome.getSpecialEffects();
|
||||
|
||||
BCLBiomeDef def = new BCLBiomeDef(BetterEnd.makeID("eterial_grove"))
|
||||
.setSurface(biome.getGenerationSettings().getSurfaceBuilder().get())
|
||||
.addFeature(BYGFeatures.BIG_ETHER_TREE);
|
||||
|
||||
if (BetterEnd.isClient()) {
|
||||
SoundEvent loop = effects.getAmbientLoopSoundEvent().get();
|
||||
SoundEvent music = effects.getBackgroundMusic().get().getEvent();
|
||||
SoundEvent additions = effects.getAmbientAdditionsSettings().get().getSoundEvent();
|
||||
SoundEvent mood = effects.getAmbientMoodSettings().get().getSoundEvent();
|
||||
def.setLoop(loop).setMusic(music).setAdditions(additions).setMood(mood);
|
||||
}
|
||||
|
||||
for (MobCategory group: MobCategory.values()) {
|
||||
List<SpawnerData> list = biome.getMobSettings().getMobs(group);
|
||||
list.forEach((entry) -> {
|
||||
def.addMobSpawn(entry);
|
||||
});
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
package ru.betterend.integration.byg.features;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import ru.bclib.api.TagAPI;
|
||||
import ru.bclib.sdf.PosInfo;
|
||||
import ru.bclib.sdf.SDF;
|
||||
import ru.bclib.sdf.operator.SDFDisplacement;
|
||||
import ru.bclib.sdf.operator.SDFFlatWave;
|
||||
import ru.bclib.sdf.operator.SDFSmoothUnion;
|
||||
import ru.bclib.sdf.primitive.SDFCappedCone;
|
||||
import ru.bclib.sdf.primitive.SDFSphere;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.util.SplineHelper;
|
||||
import ru.bclib.world.features.DefaultFeature;
|
||||
import ru.betterend.integration.Integrations;
|
||||
|
||||
public class GreatNightshadeTreeFeature extends DefaultFeature {
|
||||
private static final List<Vector3f> BRANCH;
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos,
|
||||
NoneFeatureConfiguration config) {
|
||||
if (!world.getBlockState(pos.below()).getBlock().is(TagAPI.END_GROUND))
|
||||
return false;
|
||||
|
||||
BlockState log = Integrations.BYG.getDefaultState("nightshade_log");
|
||||
BlockState wood = Integrations.BYG.getDefaultState("nightshade_wood");
|
||||
BlockState leaves = Integrations.BYG.getDefaultState("nightshade_leaves").setValue(LeavesBlock.DISTANCE, 1);
|
||||
BlockState leaves_flower = Integrations.BYG.getDefaultState("flowering_nightshade_leaves")
|
||||
.setValue(LeavesBlock.DISTANCE, 1);
|
||||
|
||||
Function<BlockPos, BlockState> splinePlacer = (bpos) -> {
|
||||
return log;
|
||||
};
|
||||
Function<BlockState, Boolean> replace = (state) -> {
|
||||
return state.is(TagAPI.END_GROUND) || state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().isReplaceable();
|
||||
};
|
||||
Function<PosInfo, BlockState> post = (info) -> {
|
||||
if (info.getState().equals(log) && (!info.getStateUp().equals(log) || !info.getStateDown().equals(log))) {
|
||||
return wood;
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
Function<BlockState, Boolean> ignore = (state) -> {
|
||||
return state.equals(log) || state.equals(wood);
|
||||
};
|
||||
|
||||
int height = MHelper.randRange(40, 60, random);
|
||||
List<Vector3f> trunk = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, height / 4);
|
||||
SplineHelper.offsetParts(trunk, random, 0.8F, 0, 0.8F);
|
||||
|
||||
if (!SplineHelper.canGenerate(trunk, pos, world, replace)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = height >> 2;
|
||||
float start = trunk.size() / 3F;
|
||||
float delta = trunk.size() * 0.6F;
|
||||
float max = height - 7;
|
||||
for (int i = 0; i < count; i++) {
|
||||
float scale = (float) (count - i) / count * 15;
|
||||
Vector3f offset = SplineHelper.getPos(trunk, (float) i / count * delta + start);
|
||||
if (offset.y() > max) {
|
||||
break;
|
||||
}
|
||||
List<Vector3f> branch = SplineHelper.copySpline(BRANCH);
|
||||
SplineHelper.rotateSpline(branch, i * 1.3F);
|
||||
SplineHelper.scale(branch, scale);
|
||||
SplineHelper.offsetParts(branch, random, 0.3F, 0.3F, 0.3F);
|
||||
SplineHelper.offset(branch, offset);
|
||||
SplineHelper.fillSpline(branch, world, wood, pos, replace);
|
||||
}
|
||||
SplineHelper.fillSpline(trunk, world, log, pos, ignore);
|
||||
|
||||
SDF sdf = SplineHelper.buildSDF(trunk, 2.3F, 0.8F, splinePlacer);
|
||||
SDF roots = new SDFSphere().setRadius(2F).setBlock(log);
|
||||
roots = new SDFFlatWave().setIntensity(2F).setRaysCount(MHelper.randRange(5, 7, random))
|
||||
.setAngle(random.nextFloat() * MHelper.PI2).setSource(roots);
|
||||
sdf = new SDFSmoothUnion().setRadius(2F).setSourceA(sdf).setSourceB(roots);
|
||||
sdf.setReplaceFunction(replace).addPostProcess(post).fillRecursive(world, pos);
|
||||
Vector3f last = SplineHelper.getPos(trunk, trunk.size() - 1.75F);
|
||||
for (int y = 0; y < 8; y++) {
|
||||
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
|
||||
BlocksHelper.setWithoutUpdate(world, p, y == 4 ? wood : log);
|
||||
}
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
BlockPos p = pos.offset(last.x() + 0.5, last.y() + y, last.z() + 0.5);
|
||||
if (world.isEmptyBlock(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves);
|
||||
}
|
||||
float radius = (1 - y / 16F) * 3F;
|
||||
int rad = (int) (radius + 1);
|
||||
radius *= radius;
|
||||
for (int x = -rad; x <= rad; x++) {
|
||||
int x2 = x * x;
|
||||
for (int z = -rad; z <= rad; z++) {
|
||||
int z2 = z * z;
|
||||
if (x2 + z2 < radius - random.nextFloat() * rad) {
|
||||
BlockPos lp = p.offset(x, 0, z);
|
||||
if (world.isEmptyBlock(lp)) {
|
||||
BlocksHelper.setWithoutUpdate(world, lp, leaves);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
Function<PosInfo, BlockState> leavesPost1 = (info) -> {
|
||||
if (info.getState().equals(log) || info.getState().equals(wood)) {
|
||||
for (int x = -6; x < 7; x++) {
|
||||
int ax = Math.abs(x);
|
||||
mut.setX(x + info.getPos().getX());
|
||||
for (int z = -6; z < 7; z++) {
|
||||
int az = Math.abs(z);
|
||||
mut.setZ(z + info.getPos().getZ());
|
||||
for (int y = -6; y < 7; y++) {
|
||||
int ay = Math.abs(y);
|
||||
int d = ax + ay + az;
|
||||
if (d < 7) {
|
||||
mut.setY(y + info.getPos().getY());
|
||||
BlockState state = info.getState(mut);
|
||||
if (state.getBlock() instanceof LeavesBlock) {
|
||||
int distance = state.getValue(LeavesBlock.DISTANCE);
|
||||
if (d < distance) {
|
||||
info.setState(mut, state.setValue(LeavesBlock.DISTANCE, d));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
Function<PosInfo, BlockState> leavesPost2 = (info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getState().getValue(LeavesBlock.DISTANCE);
|
||||
if (distance > MHelper.randRange(2, 4, random)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
for (Direction d : BlocksHelper.DIRECTIONS) {
|
||||
int airCount = 0;
|
||||
if (info.getState(d).isAir()) {
|
||||
airCount++;
|
||||
}
|
||||
if (airCount > 5) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
if (random.nextInt(8) == 0) {
|
||||
return leaves_flower.setValue(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
};
|
||||
|
||||
SDF canopy = new SDFCappedCone().setRadius1(12F).setRadius2(1f).setHeight(height * 0.3F).setBlock(leaves);
|
||||
canopy = new SDFDisplacement().setFunction((vec) -> {
|
||||
return MHelper.randRange(-3F, 3F, random);
|
||||
}).setSource(canopy);
|
||||
canopy.addPostProcess(leavesPost1).addPostProcess(leavesPost2).fillRecursiveIgnore(world,
|
||||
pos.offset(0, height * 0.75, 0), ignore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
BRANCH = Lists.newArrayList(new Vector3f(0, 0, 0), new Vector3f(0.25F, 0.1F, 0), new Vector3f(0.40F, 0.2F, 0),
|
||||
new Vector3f(0.50F, 0.4F, 0), new Vector3f(0.55F, 0.6F, 0));
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemUtils;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.level.Level;
|
||||
import ru.bclib.items.ModelProviderItem;
|
||||
|
||||
public class DrinkItem extends ModelProviderItem {
|
||||
public DrinkItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAnim getUseAnimation(ItemStack stack) {
|
||||
return UseAnim.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||
return ItemUtils.useDrink(world, user, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level world, LivingEntity user) {
|
||||
if (user instanceof ServerPlayer) {
|
||||
ServerPlayer serverPlayerEntity = (ServerPlayer) user;
|
||||
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
|
||||
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
|
||||
}
|
||||
|
||||
if (user instanceof Player && !((Player) user).abilities.instabuild) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
user.removeAllEffects();
|
||||
}
|
||||
|
||||
return stack.isEmpty() ? new ItemStack(Items.GLASS_BOTTLE) : stack;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.RecordItem;
|
||||
import ru.bclib.client.models.ItemModelProvider;
|
||||
|
||||
public class EndDiscItem extends RecordItem implements ItemModelProvider {
|
||||
public EndDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
||||
super(comparatorOutput, sound, settings);
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import ru.bclib.client.models.ItemModelProvider;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
||||
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||
super(type, primaryColor, secondaryColor, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_SPAWN_EGG, resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
package ru.betterend.noise;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
public class VoronoiNoise {
|
||||
private static final Random RANDOM = new Random();
|
||||
final int seed;
|
||||
|
||||
public VoronoiNoise() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public VoronoiNoise(int seed) {
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
private int getSeed(int x, int y, int z) {
|
||||
int h = seed + x * 374761393 + y * 668265263 + z;
|
||||
h = (h ^ (h >> 13)) * 1274126177;
|
||||
return h ^ (h >> 16);
|
||||
}
|
||||
|
||||
public double sample(double x, double y, double z) {
|
||||
int ix = MHelper.floor(x);
|
||||
int iy = MHelper.floor(y);
|
||||
int iz = MHelper.floor(z);
|
||||
|
||||
float px = (float) (x - ix);
|
||||
float py = (float) (y - iy);
|
||||
float pz = (float) (z - iz);
|
||||
|
||||
float d = 10;
|
||||
|
||||
for (int pox = -1; pox < 2; pox++) {
|
||||
for (int poy = -1; poy < 2; poy++) {
|
||||
for (int poz = -1; poz < 2; poz++) {
|
||||
RANDOM.setSeed(getSeed(pox + ix, poy + iy, poz + iz));
|
||||
float pointX = pox + RANDOM.nextFloat();
|
||||
float pointY = poy + RANDOM.nextFloat();
|
||||
float pointZ = poz + RANDOM.nextFloat();
|
||||
float d2 = MHelper.lengthSqr(pointX - px, pointY - py, pointZ - pz);
|
||||
if (d2 < d) {
|
||||
d = d2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Math.sqrt(d);
|
||||
}
|
||||
|
||||
public Random getRandom(double x, double y, double z) {
|
||||
int ix = MHelper.floor(x);
|
||||
int iy = MHelper.floor(y);
|
||||
int iz = MHelper.floor(z);
|
||||
|
||||
float px = (float) (x - ix);
|
||||
float py = (float) (y - iy);
|
||||
float pz = (float) (z - iz);
|
||||
|
||||
float d = 10;
|
||||
|
||||
int posX = 0;
|
||||
int posY = 0;
|
||||
int posZ = 0;
|
||||
|
||||
for (int pox = -1; pox < 2; pox++) {
|
||||
for (int poy = -1; poy < 2; poy++) {
|
||||
for (int poz = -1; poz < 2; poz++) {
|
||||
RANDOM.setSeed(getSeed(pox + ix, poy + iy, poz + iz));
|
||||
float pointX = pox + RANDOM.nextFloat();
|
||||
float pointY = poy + RANDOM.nextFloat();
|
||||
float pointZ = poz + RANDOM.nextFloat();
|
||||
float d2 = MHelper.lengthSqr(pointX - px, pointY - py, pointZ - pz);
|
||||
if (d2 < d) {
|
||||
d = d2;
|
||||
posX = pox;
|
||||
posY = poy;
|
||||
posZ = poz;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
posX += ix;
|
||||
posY += iy;
|
||||
posZ += iz;
|
||||
|
||||
int seed = MHelper.getSeed(posY, posX, posZ);
|
||||
RANDOM.setSeed(seed);
|
||||
|
||||
return RANDOM;
|
||||
}
|
||||
|
||||
public BlockPos[] getPos(double x, double y, double z, double scale) {
|
||||
int ix = MHelper.floor(x);
|
||||
int iy = MHelper.floor(y);
|
||||
int iz = MHelper.floor(z);
|
||||
|
||||
float px = (float) (x - ix);
|
||||
float py = (float) (y - iy);
|
||||
float pz = (float) (z - iz);
|
||||
|
||||
float d = 10;
|
||||
float selX = 0;
|
||||
float selY = 0;
|
||||
float selZ = 0;
|
||||
float selXPre = 0;
|
||||
float selYPre = 0;
|
||||
float selZPre = 0;
|
||||
|
||||
for (int pox = -1; pox < 2; pox++) {
|
||||
for (int poy = -1; poy < 2; poy++) {
|
||||
for (int poz = -1; poz < 2; poz++) {
|
||||
RANDOM.setSeed(getSeed(pox + ix, poy + iy, poz + iz));
|
||||
float pointX = pox + RANDOM.nextFloat();
|
||||
float pointY = poy + RANDOM.nextFloat();
|
||||
float pointZ = poz + RANDOM.nextFloat();
|
||||
float d2 = MHelper.lengthSqr(pointX - px, pointY - py, pointZ - pz);
|
||||
if (d2 < d) {
|
||||
d = d2;
|
||||
selXPre = selX;
|
||||
selYPre = selY;
|
||||
selZPre = selZ;
|
||||
selX = pointX;
|
||||
selY = pointY;
|
||||
selZ = pointZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos p1 = new BlockPos((ix + (double) selX) * scale, (iy + (double) selY) * scale, (iz + (double) selZ) * scale);
|
||||
BlockPos p2 = new BlockPos((ix + (double) selXPre) * scale, (iy + (double) selYPre) * scale, (iz + (double) selZPre) * scale);
|
||||
return new BlockPos[] {p1, p2};
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package ru.betterend.particle;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class GlowingSphereParticleEffect implements ParticleOptions {
|
||||
private final float red;
|
||||
private final float green;
|
||||
private final float blue;
|
||||
|
||||
public GlowingSphereParticleEffect(float red, float green, float blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleType<?> getType() {
|
||||
return EndParticles.GLOWING_SPHERE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNetwork(FriendlyByteBuf buf) {
|
||||
buf.writeFloat(this.red);
|
||||
buf.writeFloat(this.green);
|
||||
buf.writeFloat(this.blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeToString() {
|
||||
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue);
|
||||
}
|
||||
|
||||
public float getRed() {
|
||||
return this.red;
|
||||
}
|
||||
|
||||
public float getGreen() {
|
||||
return this.green;
|
||||
}
|
||||
|
||||
public float getBlue() {
|
||||
return this.blue;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package ru.betterend.util;
|
||||
|
||||
public class WorldDataUtil {
|
||||
/*private static CompoundTag root;
|
||||
private static File saveFile;
|
||||
|
||||
public static void load(File file) {
|
||||
saveFile = file;
|
||||
if (file.exists()) {
|
||||
try {
|
||||
root = NbtIo.readCompressed(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("World data loading failed", e);
|
||||
root = new CompoundTag();
|
||||
}
|
||||
return;
|
||||
}
|
||||
root = new CompoundTag();
|
||||
}
|
||||
|
||||
public static CompoundTag getRootTag() {
|
||||
return root;
|
||||
}
|
||||
|
||||
public static CompoundTag getCompoundTag(String path) {
|
||||
String[] parts = path.split("\\.");
|
||||
CompoundTag tag = root;
|
||||
for (String part: parts) {
|
||||
if (tag.contains(part)) {
|
||||
tag = tag.getCompound(part);
|
||||
}
|
||||
else {
|
||||
CompoundTag t = new CompoundTag();
|
||||
tag.put(part, t);
|
||||
tag = t;
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void saveFile() {
|
||||
try {
|
||||
NbtIo.writeCompressed(root, saveFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
BetterEnd.LOGGER.error("World data saving failed", e);
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
public class CavePlantFeature extends FullHeightScatterFeature {
|
||||
private final Block plant;
|
||||
|
||||
public CavePlantFeature(Block plant, int radius) {
|
||||
super(radius);
|
||||
this.plant = plant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
|
||||
return plant.canSurvive(world.getBlockState(blockPos), world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
|
||||
BlocksHelper.setWithoutUpdate(world, blockPos, plant);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package ru.betterend.world.generator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
public class WeighTree {
|
||||
private final Node root;
|
||||
|
||||
public WeighTree(List<EndBiome> biomes) {
|
||||
root = getNode(biomes);
|
||||
}
|
||||
|
||||
public EndBiome getBiome(float value) {
|
||||
return root.getBiome(value);
|
||||
}
|
||||
|
||||
private Node getNode(List<EndBiome> biomes) {
|
||||
int size = biomes.size();
|
||||
if (size == 1) {
|
||||
return new Leaf(biomes.get(0));
|
||||
}
|
||||
else if (size == 2) {
|
||||
EndBiome first = biomes.get(0);
|
||||
return new Branch(first.getGenChance(), new Leaf(first), new Leaf(biomes.get(1)));
|
||||
}
|
||||
else {
|
||||
int index = size >> 1;
|
||||
float separator = biomes.get(index).getGenChance();
|
||||
Node a = getNode(biomes.subList(0, index + 1));
|
||||
Node b = getNode(biomes.subList(index, size));
|
||||
return new Branch(separator, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class Node {
|
||||
abstract EndBiome getBiome(float value);
|
||||
}
|
||||
|
||||
private class Branch extends Node {
|
||||
final float separator;
|
||||
final Node min;
|
||||
final Node max;
|
||||
|
||||
public Branch(float separator, Node min, Node max) {
|
||||
this.separator = separator;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
EndBiome getBiome(float value) {
|
||||
return value < separator ? min.getBiome(value) : max.getBiome(value);
|
||||
}
|
||||
}
|
||||
|
||||
private class Leaf extends Node {
|
||||
final EndBiome biome;
|
||||
|
||||
Leaf(EndBiome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
EndBiome getBiome(float value) {
|
||||
return biome;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package ru.betterend.world.processors;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class DestructionStructureProcessor extends StructureProcessor {
|
||||
private int chance = 4;
|
||||
|
||||
public void setChance(int chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
|
||||
if (!structureBlockInfo2.state.is(EndBlocks.ETERNAL_PEDESTAL) && !structureBlockInfo2.state.is(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && MHelper.RANDOM.nextInt(chance) == 0) {
|
||||
return null;
|
||||
}
|
||||
return structureBlockInfo2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StructureProcessorType<?> getType() {
|
||||
return StructureProcessorType.RULE;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package ru.betterend.world.processors;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
|
||||
|
||||
public class TerrainStructureProcessor extends StructureProcessor {
|
||||
@Override
|
||||
public StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlacementData) {
|
||||
BlockPos bpos = structureBlockInfo2.pos;
|
||||
if (structureBlockInfo2.state.is(Blocks.END_STONE) && worldView.isEmptyBlock(bpos.above())) {
|
||||
BlockState top = worldView.getBiome(structureBlockInfo2.pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
return new StructureBlockInfo(bpos, top, structureBlockInfo2.nbt);
|
||||
}
|
||||
return structureBlockInfo2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StructureProcessorType<?> getType() {
|
||||
return StructureProcessorType.RULE;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package ru.betterend.world.surface;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
|
||||
public class DoubleBlockSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBaseConfiguration> {
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141);
|
||||
private SurfaceBuilderBaseConfiguration config1;
|
||||
private SurfaceBuilderBaseConfiguration config2;
|
||||
|
||||
private DoubleBlockSurfaceBuilder() {
|
||||
super(SurfaceBuilderBaseConfiguration.CODEC);
|
||||
}
|
||||
|
||||
public DoubleBlockSurfaceBuilder setBlock1(Block block) {
|
||||
BlockState stone = Blocks.END_STONE.defaultBlockState();
|
||||
config1 = new SurfaceBuilderBaseConfiguration(block.defaultBlockState(), stone, stone);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DoubleBlockSurfaceBuilder setBlock2(Block block) {
|
||||
BlockState stone = Blocks.END_STONE.defaultBlockState();
|
||||
config2 = new SurfaceBuilderBaseConfiguration(block.defaultBlockState(), stone, stone);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderBaseConfiguration surfaceBlocks) {
|
||||
noise = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, random);
|
||||
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise, defaultBlock, defaultFluid, seaLevel, seed, noise > 0 ? config1 : config2);
|
||||
}
|
||||
|
||||
public static DoubleBlockSurfaceBuilder register(String name) {
|
||||
return Registry.register(Registry.SURFACE_BUILDER, name, new DoubleBlockSurfaceBuilder());
|
||||
}
|
||||
|
||||
public ConfiguredSurfaceBuilder<SurfaceBuilderBaseConfiguration> configured() {
|
||||
BlockState stone = Blocks.END_STONE.defaultBlockState();
|
||||
return this.configured(new SurfaceBuilderBaseConfiguration(config1.getTopMaterial(), stone, stone));
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
"ArmorStandRendererMixin",
|
||||
"ClientRecipeBookMixin",
|
||||
"MinecraftClientMixin",
|
||||
"ContextGsonAccessor",
|
||||
"PlayerRendererMixin",
|
||||
"WorldRendererMixin",
|
||||
"MusicTrackerMixin",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue