tweaked thoraxis gen

This commit is contained in:
craisinlord committed 2026-09-03 22:06:03 -05:00
1 parent 867fef9d0a
commit bb43425edc
40 files changed
+422 -343

No files matched your search

@@ -14,7 +14,6 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
@@ -47,7 +46,11 @@ public class UpwardFallingBlockEntity extends Entity {
public UpwardFallingBlockEntity(EntityType<UpwardFallingBlockEntity> type, Level level) {
super(type, level);
this.blocksBuilding = true;
// This entity has its own simple upward-flight and landing checks below. Do not
// send it through the normal entity collision solver: Thoraxis can create many of
// these at once while chunks are loading, and swept entity collision is needlessly
// expensive for a block that only collides with the block directly above it.
this.noPhysics = true;
}
@Override
@@ -126,7 +129,7 @@ public class UpwardFallingBlockEntity extends Entity {
double beforeY = getY();
setDeltaMovement(getDeltaMovement().add(0.0, getRiseAccel(), 0.0));
move(MoverType.SELF, getDeltaMovement());
setPos(getX(), getY() + getDeltaMovement().y, getZ());
setDeltaMovement(getDeltaMovement().scale(DRAG));
distanceTraveled += Math.max(0.0, getY() - beforeY);
@@ -154,7 +157,8 @@ public class UpwardFallingBlockEntity extends Entity {
boolean hitScaffolding = above.getBlock() instanceof AntimetalScaffoldingBlock;
if (this.verticalCollision || hitScaffolding) {
boolean hitCeiling = !above.isAir() && !above.getCollisionShape(level(), headPos).isEmpty();
if (hitCeiling || hitScaffolding) {
placeAtLanding(blockState, headPos.below());
return;
}
@@ -3,6 +3,7 @@ package com.craisinlord.antarchy.content.entity.royal;
import com.craisinlord.antarchy.config.AntarchySettings;
import com.craisinlord.antarchy.content.AntarchyObjects;
import com.craisinlord.antarchy.content.AntarchySoundEvents;
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
@@ -21,6 +22,15 @@ public class PrincessEntity extends RoyalMountEntity {
AntarchySettings.princessFollowRange());
}
@Override
protected RoyalBeamElement boltElement(int lateralIndex) {
return switch (lateralIndex) {
case -1 -> RoyalBeamElement.FIRE;
case 1 -> RoyalBeamElement.ICE;
default -> RoyalBeamElement.LIGHTNING;
};
}
@Override
protected String geoName() {
return "princess";
@@ -337,7 +337,7 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
return InteractionResult.sidedSuccess(this.level().isClientSide);
}
if (stack.isEmpty() && this.isSaddled() && !this.isBaby() && !player.isPassenger()) {
if (stack.isEmpty() && !this.isBaby() && !player.isPassenger()) {
if (!this.level().isClientSide) {
this.setOrderedToSit(false);
this.setInSittingPose(false);
@@ -553,7 +553,7 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
@Nullable
@Override
public LivingEntity getControllingPassenger() {
return this.getFirstPassenger() instanceof Player player && this.isSaddled() && this.isOwnedBy(player) ? player : null;
return this.getFirstPassenger() instanceof Player player && this.isOwnedBy(player) ? player : null;
}
@Override
@@ -47,6 +47,15 @@ public class PeachTreeFeature extends Feature<PeachTreeConfiguration> {
}
List<BlockPos> trunkPath = buildTrunkPath(origin, height, random);
for (BlockPos trunkPos : trunkPath) {
for (int dx = 0; dx < trunkWidth; dx++) {
for (int dz = 0; dz < trunkWidth; dz++) {
if (!canReplace(level, trunkPos.offset(dx, 0, dz))) {
return false;
}
}
}
}
Set<BlockPos> logPositions = new LinkedHashSet<>();
Set<BlockPos> leafPositions = new LinkedHashSet<>();
@@ -431,7 +440,7 @@ public class PeachTreeFeature extends Feature<PeachTreeConfiguration> {
private static boolean canReplace(WorldGenLevel level, BlockPos pos) {
BlockState state = level.getBlockState(pos);
return state.isAir() || state.canBeReplaced() || state.getBlock() instanceof LeavesBlock;
return state.isAir() || state.getBlock() instanceof LeavesBlock;
}
private static Direction.Axis axisForSegment(BlockPos from, BlockPos to) {
@@ -0,0 +1,63 @@
package com.craisinlord.antarchy.content.worldgen.thoraxis;
import com.craisinlord.antarchy.Antarchy;
import com.craisinlord.antarchy.content.block.SimpleDirectionalVineBlock;
import com.mojang.serialization.Codec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
/** Places the complete natural-grown shape so every segment gets the body state. */
public final class NaturalDirectionalVineFeature extends Feature<NoneFeatureConfiguration> {
private final ResourceLocation blockId;
private final Direction direction;
private final int minimumLength;
private final int maximumLength;
public NaturalDirectionalVineFeature(Codec<NoneFeatureConfiguration> codec, String blockName,
Direction direction, int minimumLength, int maximumLength) {
super(codec);
this.blockId = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, blockName);
this.direction = direction;
this.minimumLength = minimumLength;
this.maximumLength = maximumLength;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel level = context.level();
BlockPos origin = context.origin();
Block block = BuiltInRegistries.BLOCK.get(this.blockId);
RandomSource random = context.random();
int length = Mth.randomBetweenInclusive(random, this.minimumLength, this.maximumLength);
boolean placed = false;
for (int index = 0; index < length; index++) {
BlockPos pos = origin.relative(this.direction, index);
if (!level.getBlockState(pos).isAir()) {
break;
}
BlockState state = block.defaultBlockState()
.setValue(SimpleDirectionalVineBlock.GROWTH_DIRECTION, this.direction)
.setValue(SimpleDirectionalVineBlock.DISTANCE, Math.min(index, 15))
.setValue(SimpleDirectionalVineBlock.TOP_CAP, this.direction == Direction.UP && index == length - 1)
.setValue(SimpleDirectionalVineBlock.BOTTOM_CAP, this.direction == Direction.DOWN && index == length - 1);
if (!state.canSurvive(level, pos)) {
break;
}
level.setBlock(pos, state, Block.UPDATE_CLIENTS);
placed = true;
}
return placed;
}
}
@@ -22,8 +22,8 @@ public final class ThoraxisBiomeSource extends BiomeSource {
private static final int REGION_DETAIL_SCALE = 41;
private static final int VERTICAL_NOISE_SCALE = 8;
private static final double DUNES_SELECTOR_CUTOFF = 0.38D;
private static final double DREAM_DUNES_SELECTOR_CUTOFF = 0.12D;
private static final double HILLS_SELECTOR_CUTOFF = 0.24D;
private static final double DREAM_DUNES_SELECTOR_CUTOFF = 0.42D;
private static final double HILLS_SELECTOR_CUTOFF = 0.33D;
private static final double NADIR_FOREST_SELECTOR_MIN = 0.54D;
private static final double NADIR_FOREST_SELECTOR_MAX = 0.56D;
private static final ResourceKey<Biome> NIGHTMARE_WASTES = ResourceKey.create(
@@ -53,8 +53,8 @@ public final class ThoraxisBiomeSource extends BiomeSource {
public static final MapCodec<ThoraxisBiomeSource> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
MultiNoiseBiomeSource.DIRECT_CODEC.forGetter(ThoraxisBiomeSource::parameters),
Codec.INT.optionalFieldOf("dream_dunes_max_y", 96).forGetter(ThoraxisBiomeSource::dreamDunesMaxY),
Codec.INT.optionalFieldOf("umbral_hills_max_y", 100).forGetter(ThoraxisBiomeSource::umbralHillsMaxY),
Codec.INT.optionalFieldOf("dream_dunes_max_y", 160).forGetter(ThoraxisBiomeSource::dreamDunesMaxY),
Codec.INT.optionalFieldOf("umbral_hills_max_y", 160).forGetter(ThoraxisBiomeSource::umbralHillsMaxY),
Codec.INT.optionalFieldOf("lucid_pools_min_y", 116).forGetter(ThoraxisBiomeSource::lucidPoolsMinY),
Codec.INT.optionalFieldOf("nadir_forest_min_y", 128).forGetter(ThoraxisBiomeSource::nadirForestMinY)
).apply(instance, ThoraxisBiomeSource::new));
@@ -72,8 +72,8 @@ public class TyphoniteSpikeFeature extends Feature<TyphoniteSpikeConfiguration>
Column column = optional.get();
OptionalInt ceiling = column.getCeiling();
OptionalInt floor = column.getFloor();
boolean canGrowDown = ceiling.isPresent() && isTyphonite(level.getBlockState(pos.atY(ceiling.getAsInt())));
boolean canGrowUp = floor.isPresent() && isTyphonite(level.getBlockState(pos.atY(floor.getAsInt())));
boolean canGrowDown = ceiling.isPresent() && isTyphoniteAnchor(level.getBlockState(pos.atY(ceiling.getAsInt())));
boolean canGrowUp = floor.isPresent() && isTyphoniteAnchor(level.getBlockState(pos.atY(floor.getAsInt())));
if (!canGrowDown && !canGrowUp) {
return false;
}
@@ -194,7 +194,8 @@ public class TyphoniteSpikeFeature extends Feature<TyphoniteSpikeConfiguration>
);
}
private static boolean isTyphonite(BlockState state) {
return BuiltInRegistries.BLOCK.getKey(state.getBlock()).equals(TYPHONITE_ID);
private static boolean isTyphoniteAnchor(BlockState state) {
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(state.getBlock());
return blockId.equals(TYPHONITE_ID) || blockId.equals(ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "verdant_nyxium"));
}
}
@@ -0,0 +1,116 @@
package com.craisinlord.antarchy.content.worldgen.thoraxis;
import com.craisinlord.antarchy.Antarchy;
import com.mojang.serialization.Codec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.PointedDripstoneBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
public final class TyphoniteSwirlFeature extends Feature<NoneFeatureConfiguration> {
private static final ResourceLocation TYPHONITE_SPIKE = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "typhonite_spike");
public TyphoniteSwirlFeature(Codec<NoneFeatureConfiguration> codec) {
super(codec);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel level = context.level();
BlockPos origin = context.origin();
RandomSource random = context.random();
int height = Mth.randomBetweenInclusive(random, 15, 30);
int arms = Mth.randomBetweenInclusive(random, 1, 3);
double twist = (0.18D + random.nextDouble() * 0.22D) * (random.nextBoolean() ? 1.0D : -1.0D);
double radius = 3.0D + random.nextDouble() * 4.0D;
boolean placed = false;
for (int y = 0; y < Math.max(4, height / 3); y++) {
placed |= placeMass(level, origin.above(y), 1 + (y < 3 ? 1 : 0), random);
}
for (int arm = 0; arm < arms; arm++) {
double phase = (Math.PI * 2.0D * arm / arms) + random.nextDouble() * 0.8D;
for (int y = 0; y < height; y++) {
double progress = y / (double) Math.max(1, height - 1);
double angle = phase + y * twist;
double currentRadius = radius * (0.12D + progress * 0.95D) + Math.sin(y * 0.7D + phase) * 1.2D;
int x = Mth.floor(origin.getX() + Math.cos(angle) * currentRadius);
int z = Mth.floor(origin.getZ() + Math.sin(angle) * currentRadius);
BlockPos pos = new BlockPos(x, origin.getY() + y, z);
if (placeMass(level, pos, 1 + (random.nextFloat() < 0.35F ? 1 : 0), random)) {
placed = true;
if (random.nextFloat() < 0.12F) {
placed |= placeSpike(level, pos, random, random.nextBoolean() ? Direction.UP : Direction.DOWN);
}
}
if (random.nextFloat() < 0.18F) {
BlockPos sidePos = pos.offset(random.nextInt(3) - 1, random.nextInt(3) - 1, random.nextInt(3) - 1);
if (placeMass(level, sidePos, 1, random)) {
placed = true;
}
}
}
}
return placed;
}
private static BlockState materialState(RandomSource random, int y, int height) {
String blockName = random.nextFloat() < 0.18F ? "veined_typhonite" : "typhonite";
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, blockName));
return block.defaultBlockState();
}
private static boolean placeIfAir(WorldGenLevel level, BlockPos pos, BlockState state) {
if (!level.getBlockState(pos).isAir()) {
return false;
}
level.setBlock(pos, state, Block.UPDATE_CLIENTS);
return true;
}
private static boolean placeMass(WorldGenLevel level, BlockPos center, int radius, RandomSource random) {
boolean placed = false;
for (int dx = -radius; dx <= radius; dx++) {
for (int dz = -radius; dz <= radius; dz++) {
if (dx * dx + dz * dz > radius * radius + 1 || random.nextFloat() < 0.08F) {
continue;
}
placed |= placeIfAir(level, center.offset(dx, 0, dz), materialState(random, 0, 0));
}
}
return placed;
}
private static boolean placeSpike(WorldGenLevel level, BlockPos pos, RandomSource random, Direction direction) {
Block spike = BuiltInRegistries.BLOCK.get(TYPHONITE_SPIKE);
int length = 2 + random.nextInt(4);
boolean placed = false;
for (int i = 0; i < length; i++) {
BlockPos spikePos = pos.relative(direction, i + 1);
if (!level.getBlockState(spikePos).isAir()) {
break;
}
BlockState state = spike.defaultBlockState()
.setValue(PointedDripstoneBlock.TIP_DIRECTION, direction)
.setValue(PointedDripstoneBlock.THICKNESS, i == length - 1 ? net.minecraft.world.level.block.state.properties.DripstoneThickness.TIP : net.minecraft.world.level.block.state.properties.DripstoneThickness.MIDDLE)
.setValue(PointedDripstoneBlock.WATERLOGGED, false);
if (!state.canSurvive(level, spikePos)) {
break;
}
level.setBlock(spikePos, state, Block.UPDATE_CLIENTS);
placed = true;
}
return placed;
}
}
@@ -1,27 +0,0 @@
package com.craisinlord.antarchy.mixins;
import com.craisinlord.antarchy.Antarchy;
import com.craisinlord.antarchy.config.AntarchySettings;
import com.craisinlord.antarchy.content.entity.UpwardFallingBlockEntity;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(UpwardFallingBlockEntity.class)
public abstract class DreamSandFallingSpeedMixin {
private static final ResourceLocation DREAM_SAND_ID = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "dream_sand");
@Shadow public abstract BlockState getBlockState();
@Inject(method = "getRiseAccel", at = @At("RETURN"), cancellable = true, remap = false)
private void antarchy$slowDreamSandRise(CallbackInfoReturnable<Double> cir) {
if (BuiltInRegistries.BLOCK.getKey(this.getBlockState().getBlock()).equals(DREAM_SAND_ID)) {
cir.setReturnValue(cir.getReturnValue() * AntarchySettings.dreamSandFallingBlockGravityMultiplier());
}
}
}