Emp scorp spawn fix

Wormy caves tweak
Beam maybe fixed??
This commit is contained in:
craisinlord committed 2026-09-13 11:24:50 -05:00
1 parent 9116195853
commit 8b86021a04
12 files changed
+185 -36

No files matched your search

@@ -13,7 +13,7 @@ public class RoyalBeamRenderTypes extends RenderType {
}
public static RenderType beam(ResourceLocation texture) {
return create("royal_beam", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true,
return create("tremorzilla_beam", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true,
CompositeState.builder()
.setTextureState(new TextureStateShard(texture, false, false))
.setShaderState(RenderStateShard.RENDERTYPE_ENERGY_SWIRL_SHADER)
@@ -246,7 +246,7 @@ public class RoyalBossRenderer extends GeoEntityRenderer<RoyalBossEntity> {
beamVertex(vertices, pose, d, minU, maxV, 255);
}
private static void drawBeamImpact(VertexConsumer vertices, org.joml.Matrix4f pose, float z, float size) {
static void drawBeamImpact(VertexConsumer vertices, org.joml.Matrix4f pose, float z, float size) {
PoseStack endpoint = new PoseStack();
endpoint.last().pose().set(pose);
endpoint.translate(0.0D, 0.0D, z);
@@ -325,17 +325,17 @@ public class RoyalBossRenderer extends GeoEntityRenderer<RoyalBossEntity> {
private static void vertex(VertexConsumer vertices, org.joml.Matrix4f pose, Vec3 pos, float u, float v) {
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z)
.setColor(255, 255, 255, 255).setUv(u, v)
.setColor(1.0F, 1.0F, 1.0F, 1.0F).setUv(u, v)
.setOverlay(net.minecraft.client.renderer.texture.OverlayTexture.NO_OVERLAY)
.setLight(0x00F000F0)
.setLight(240)
.setNormal(0.0F, 1.0F, 0.0F);
}
private static void beamVertex(VertexConsumer vertices, org.joml.Matrix4f pose, Vec3 pos, float u, float v, int alpha) {
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z)
.setColor(255, 255, 255, alpha).setUv(u, v)
.setColor(1.0F, 1.0F, 1.0F, alpha / 255.0F).setUv(u, v)
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(0x00F000F0)
.setLight(240)
.setNormal(0.0F, -1.0F, 0.0F);
}
}
@@ -10,6 +10,7 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;
@@ -41,8 +42,17 @@ public class RoyalElementalProjectileRenderer extends GeoEntityRenderer<RoyalEle
@Override
protected void applyRotations(RoyalElementalProjectileEntity entity, PoseStack poseStack, float ageInTicks,
float rotationYaw, float partialTick, float nativeScale) {
float yaw = Mth.rotLerp(partialTick, entity.yRotO, entity.getYRot());
float pitch = Mth.lerp(partialTick, entity.xRotO, entity.getXRot());
Vec3 travel = entity.getDeltaMovement();
float yaw;
float pitch;
if (!entity.isIceball() && travel.lengthSqr() > 1.0E-6D) {
double horizontal = travel.horizontalDistance();
yaw = (float) (Mth.atan2(travel.z, travel.x) * Mth.RAD_TO_DEG) - 90.0F;
pitch = (float) (Mth.atan2(horizontal, travel.y) * Mth.RAD_TO_DEG) - 90.0F;
} else {
yaw = Mth.rotLerp(partialTick, entity.yRotO, entity.getYRot());
pitch = Mth.lerp(partialTick, entity.xRotO, entity.getXRot());
}
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F - yaw));
poseStack.mulPose(Axis.XP.rotationDegrees(-pitch));
if (!entity.isIceball()) {
@@ -73,6 +73,7 @@ public class RoyalMountRenderer extends GeoEntityRenderer<RoyalMountEntity> {
Vec3 side = dir.cross(new Vec3(0.0D, 1.0D, 0.0D));
if (side.lengthSqr() < 1.0E-4D) side = dir.cross(new Vec3(1.0D, 0.0D, 0.0D));
side = side.normalize();
Vec3 side2 = dir.cross(side).normalize();
ResourceLocation outer = QUEEN_OUTER;
ResourceLocation inner = QUEEN_INNER;
ResourceLocation[] endTextures = {QUEEN_END_1, QUEEN_END_2};
@@ -85,17 +86,45 @@ public class RoyalMountRenderer extends GeoEntityRenderer<RoyalMountEntity> {
}
float time = entity.tickCount + partialTick;
float outerV = -time * 0.25F;
org.joml.Matrix4f pose = poseStack.last().pose();
Vec3 side2 = dir.cross(side).normalize();
VertexConsumer outerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(outer));
drawBeamTube(outerBuffer, pose, start, finish, side, side2, 0.44F, 8, outerV, 0.0F, 0.55F, 0.15F, 0);
float innerV = -time * 0.25F * 0.5F;
float yaw = (float) Math.atan2(dir.z, dir.x);
float pitch = (float) Math.acos(dir.y);
poseStack.pushPose();
poseStack.translate(start.x, start.y, start.z);
poseStack.mulPose(com.mojang.math.Axis.YP.rotation((float) (Math.PI * 0.5D - yaw)));
poseStack.mulPose(com.mojang.math.Axis.XP.rotation((float) (-Math.PI * 0.5D + pitch)));
poseStack.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(45.0F));
org.joml.Matrix4f pose = poseStack.last().pose();
VertexConsumer innerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(inner));
drawBeamTube(innerBuffer, pose, start, finish, side, side2, 0.375F, 4, innerV, 1.0F, 0.55F, 0.5F, 255);
float impactSize = 0.375F + 0.09F * Mth.sin(time * 0.6F);
drawLocalBeam(innerBuffer, pose, length, 0.375F, 4, innerV, 0.5F);
VertexConsumer outerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(outer));
drawLocalBeam(outerBuffer, pose, length, 0.44F, 8, outerV, 0.15F);
ResourceLocation endTexture = endTextures[(entity.tickCount / 2) % endTextures.length];
VertexConsumer endBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(endTexture));
drawBeamImpact(endBuffer, pose, finish.subtract(dir.scale(0.375D)), dir, side, side2, impactSize);
RoyalBossRenderer.drawBeamImpact(endBuffer, pose, (float) length - 1.5F, 0.375F);
poseStack.popPose();
}
private static void drawLocalBeam(VertexConsumer vertices, org.joml.Matrix4f pose, double length,
float radius, int sections, float scroll, float uvLengthScale) {
float endV = scroll + (float) length * uvLengthScale;
float previousX = -radius;
float previousY = 0.0F;
float previousU = 0.0F;
for (int i = 0; i <= sections; i++) {
float angle = (float) (Math.PI + Math.PI * 2.0D * i / sections);
float currentX = Mth.cos(angle) * radius;
float currentY = Mth.sin(angle) * radius;
emitBeamQuad(vertices, pose,
new Vec3(previousX * 0.55D, previousY * 0.55D, 0.0D),
new Vec3(previousX, previousY, length),
new Vec3(currentX, currentY, length),
new Vec3(currentX * 0.55D, currentY * 0.55D, 0.0D),
previousU, scroll, i + 1.0F, endV, 255);
previousX = currentX;
previousY = currentY;
previousU = i + 1.0F;
}
}
private static void drawBeamTube(VertexConsumer vertices, org.joml.Matrix4f pose, Vec3 start, Vec3 end,
@@ -153,12 +182,12 @@ public class RoyalMountRenderer extends GeoEntityRenderer<RoyalMountEntity> {
}
private static void vertex(VertexConsumer vertices, org.joml.Matrix4f pose, Vec3 pos, float u, float v) {
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z).setColor(255, 255, 255, 255).setUv(u, v)
.setOverlay(net.minecraft.client.renderer.texture.OverlayTexture.NO_OVERLAY).setLight(0x00F000F0).setNormal(0.0F, 1.0F, 0.0F);
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z).setColor(1.0F, 1.0F, 1.0F, 1.0F).setUv(u, v)
.setOverlay(net.minecraft.client.renderer.texture.OverlayTexture.NO_OVERLAY).setLight(240).setNormal(0.0F, 1.0F, 0.0F);
}
private static void beamVertex(VertexConsumer vertices, org.joml.Matrix4f pose, Vec3 pos, float u, float v, int alpha) {
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z).setColor(255, 255, 255, alpha).setUv(u, v)
.setOverlay(net.minecraft.client.renderer.texture.OverlayTexture.NO_OVERLAY).setLight(0x00F000F0).setNormal(0.0F, -1.0F, 0.0F);
vertices.addVertex(pose, (float) pos.x, (float) pos.y, (float) pos.z).setColor(1.0F, 1.0F, 1.0F, alpha / 255.0F).setUv(u, v)
.setOverlay(net.minecraft.client.renderer.texture.OverlayTexture.NO_OVERLAY).setLight(240).setNormal(0.0F, -1.0F, 0.0F);
}
}
@@ -47,6 +47,8 @@ import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.animatable.GeoEntity;
@@ -108,6 +110,8 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
private static final ResourceKey<Level> THORAXIS_KEY =
ResourceKey.create(Registries.DIMENSION,
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "thoraxis"));
private static final ResourceKey<net.minecraft.world.level.biome.Biome> DREAM_DUNES = ResourceKey.create(
Registries.BIOME, ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "dream_dunes"));
private static final RawAnimation IDLE_ANIM = RawAnimation.begin().thenLoop("idle");
private static final RawAnimation WALK_ANIM = RawAnimation.begin().thenLoop("walk");
@@ -237,11 +241,23 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
if (!level.getLevel().dimension().equals(THORAXIS_KEY)) {
return false;
}
if (ThoraxisUndersideManager.shouldSpawnInvertedOnDreamSand(level, pos)) {
return level.getDifficulty() != Difficulty.PEACEFUL;
if (level.getDifficulty() == Difficulty.PEACEFUL) {
return false;
}
return level.getDifficulty() != Difficulty.PEACEFUL
&& Monster.checkMonsterSpawnRules(entityType, level, spawnReason, pos, random);
if (ThoraxisUndersideManager.shouldSpawnInvertedOnDreamSand(level, pos)) {
return true;
}
// Dream Dunes can use Dream Sandstone as the ceiling surface too. Keep
// the Emperor restricted to a supported underside position, but do
// not require the surface to be the narrower Dream Sand variant.
if (pos.getY() < 0 && level.getBiome(pos).is(DREAM_DUNES) && level.isEmptyBlock(pos)) {
BlockState below = level.getBlockState(pos.below());
BlockState above = level.getBlockState(pos.above());
boolean floorSupport = !below.is(Blocks.BEDROCK) && below.isFaceSturdy(level, pos.below(), Direction.UP);
boolean ceilingSupport = !above.is(Blocks.BEDROCK) && above.isFaceSturdy(level, pos.above(), Direction.DOWN);
return floorSupport || ceilingSupport;
}
return Monster.checkMonsterSpawnRules(entityType, level, spawnReason, pos, random);
}
@Override
@@ -2,6 +2,7 @@ package com.craisinlord.antarchy.content.entity;
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.QueenEntity;
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
@@ -27,7 +27,9 @@ import net.minecraft.world.entity.vehicle.DismountHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
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.levelgen.Heightmap;
import net.minecraft.world.level.portal.DimensionTransition;
import net.minecraft.world.phys.Vec3;
@@ -254,12 +256,7 @@ public final class AntTeleportHelper {
return safeArrivalPos;
}
if (destination.hasChunkAt(preferredPos)) {
BlockPos fallbackPos = player.adjustSpawnLocation(destination, preferredPos);
return Vec3.atBottomCenterOf(fallbackPos);
}
return Vec3.atBottomCenterOf(getClampedFallbackPosition(destination, preferredPos));
return createEmergencyArrivalPlatform(destination, preferredPos);
}
@Nullable
@@ -414,4 +411,31 @@ public final class AntTeleportHelper {
int maxY = destination.getMaxBuildHeight() - 1;
return new BlockPos(preferredPos.getX(), Mth.clamp(preferredPos.getY(), minY, maxY), preferredPos.getZ());
}
/**
* Last-resort landing location for custom dimensions whose generated spawn
* area has no valid player-sized space. The normal search always runs first;
* this only modifies terrain when there is no safe generated location.
*/
private static Vec3 createEmergencyArrivalPlatform(ServerLevel destination, BlockPos preferredPos) {
BlockPos center = getClampedFallbackPosition(destination, preferredPos);
int minY = destination.getMinBuildHeight() + 1;
int maxY = destination.getMaxBuildHeight() - 2;
center = new BlockPos(center.getX(), Mth.clamp(center.getY(), minY, maxY), center.getZ());
destination.getChunkAt(center);
BlockState platformState = Blocks.STONE.defaultBlockState();
for (int xOffset = -2; xOffset <= 2; xOffset++) {
for (int zOffset = -2; zOffset <= 2; zOffset++) {
BlockPos column = center.offset(xOffset, 0, zOffset);
destination.setBlock(column.below(), platformState, Block.UPDATE_ALL);
for (int yOffset = 0; yOffset <= 3; yOffset++) {
destination.removeBlock(column.above(yOffset), false);
}
}
}
return Vec3.atBottomCenterOf(center);
}
}
@@ -89,6 +89,8 @@ public class KingEntity extends RoyalBossEntity {
private static final int BEHAVIOR_SCORE_CAP = 12;
/** Keep the tree-bound patrol safely inside the authored tree footprint. */
private static final double TREE_ORBIT_RADIUS = 128.0D;
private static final double TREE_RETURN_RADIUS = 192.0D;
private static final double TREE_RETURN_RELEASE_RADIUS = 144.0D;
private static final double TREE_ORBIT_ANGLE_STEP = 0.014D;
private static final int TREE_ORBIT_PATH_SAMPLES = 16;
@@ -102,6 +104,7 @@ public class KingEntity extends RoyalBossEntity {
private double treePatrolMaximumY;
private double treePatrolAngle;
private boolean treePatrolBound;
private boolean returningToTree;
private int patrolCooldownTicks;
private int decreeCooldownTicks;
private int activeDecreeTicks;
@@ -360,6 +363,10 @@ public class KingEntity extends RoyalBossEntity {
@Override
public void tick() {
if (!this.level().isClientSide && this.shouldReturnToTree()) {
this.returningToTree = true;
this.setTarget(null);
}
super.tick();
if (this.level().isClientSide) {
return;
@@ -372,6 +379,21 @@ public class KingEntity extends RoyalBossEntity {
ServerLevel serverLevel = (ServerLevel) this.level();
this.iceBuildup.entrySet().removeIf(entry -> serverLevel.getEntity(entry.getKey()) == null);
if (this.iceBuildup.size() > 16) this.iceBuildup.clear();
if (this.returningToTree) {
this.setTarget(null);
this.decreeRetreatPressure = false;
if (this.treePatrolBound && this.treePatrolCenter != null) {
this.setRoyalFlying(true);
if (this.isWithinTreeReturnReleaseRadius()) {
this.returningToTree = false;
} else {
this.tickTreePatrol();
return;
}
} else {
this.returningToTree = false;
}
}
LivingEntity target = this.getTarget();
if (target != null && !this.isDeadOrDying() && this.level() instanceof ServerLevel level) {
this.trackBehavior(target);
@@ -426,6 +448,25 @@ public class KingEntity extends RoyalBossEntity {
}
}
private boolean shouldReturnToTree() {
return this.treePatrolBound && this.treePatrolCenter != null
&& this.horizontalDistanceToTreeSqr() > TREE_RETURN_RADIUS * TREE_RETURN_RADIUS;
}
private boolean isWithinTreeReturnReleaseRadius() {
return this.treePatrolCenter != null
&& this.horizontalDistanceToTreeSqr() <= TREE_RETURN_RELEASE_RADIUS * TREE_RETURN_RELEASE_RADIUS;
}
private double horizontalDistanceToTreeSqr() {
if (this.treePatrolCenter == null) {
return 0.0D;
}
double dx = this.getX() - this.treePatrolCenter.x;
double dz = this.getZ() - this.treePatrolCenter.z;
return dx * dx + dz * dz;
}
@Nullable
private Vec3 findTreePatrolWaypoint(Vec3 center, double angle) {
for (int attempt = 0; attempt < 10; attempt++) {
@@ -174,6 +174,9 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
private final PathNavigation flyingNavigation;
private int locomotionDecisionTicks = 80;
private boolean landingForCombat;
@Nullable
private Vec3 aerialCombatAnchor;
private int aerialCombatAnchorTicks;
@Nullable
private Entity[] multipartParts;
@@ -452,10 +455,12 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
}
this.tickCombatLocomotionMode(primaryTarget);
boolean aeriallyStabilized = this.steerTowardTarget(primaryTarget);
if (!aeriallyStabilized) {
this.getLookControl().setLookAt(primaryTarget, 30.0F, 30.0F);
}
this.assignHeadTargets(primaryTarget);
this.tickRoyalBeam(primaryTarget);
this.steerTowardTarget(primaryTarget);
this.tickBodyCrush();
Phase phase = this.phase();
@@ -649,7 +654,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
return true;
}
private void steerTowardTarget(LivingEntity target) {
private boolean steerTowardTarget(LivingEntity target) {
double dx = target.getX() - this.getX();
double dz = target.getZ() - this.getZ();
double horizontalDistance = Math.sqrt(dx * dx + dz * dz);
@@ -666,14 +671,36 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
double approachSpeed = anyHeadInBiteRange ? 1.0D : this.biteApproachSpeed();
if (!this.isRoyalFlying()) {
this.aerialCombatAnchor = null;
this.aerialCombatAnchorTicks = 0;
if (atStandoff) {
this.getNavigation().stop();
} else {
this.getMoveControl().setWantedPosition(wanted.x, target.getY(), wanted.z, approachSpeed);
}
return;
return false;
}
double verticalDistance = Math.abs(target.getY() + target.getBbHeight() * 0.5D
- (this.getY() + this.getBbHeight() * 0.5D));
if (!this.landingForCombat && verticalDistance > 6.0D) {
if (this.aerialCombatAnchor == null || this.aerialCombatAnchorTicks-- <= 0) {
double anchorX = this.getX();
double anchorZ = this.getZ();
if (horizontalDistance > 10.0D) {
anchorX = wanted.x;
anchorZ = wanted.z;
}
this.aerialCombatAnchor = new Vec3(anchorX, this.getY(), anchorZ);
this.aerialCombatAnchorTicks = 20;
}
Vec3 anchor = this.aerialCombatAnchor;
this.getMoveControl().setWantedPosition(anchor.x, anchor.y, anchor.z, Math.min(approachSpeed, 0.85D));
return true;
}
this.aerialCombatAnchor = null;
this.aerialCombatAnchorTicks = 0;
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
double groundBelowTarget = this.groundYBelow(wanted.x, wanted.z);
double wantedY = this.landingForCombat
@@ -689,6 +716,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
} else {
this.getMoveControl().setWantedPosition(wanted.x, wantedY, wanted.z, approachSpeed);
}
return false;
}
private void tickCombatLocomotionMode(LivingEntity target) {
@@ -179,8 +179,8 @@
0.9
],
"depth": [
0.15,
2.0
-2.0,
-0.1
],
"offset": 0.0
},
@@ -83,7 +83,7 @@ public class MultipartPartEntity extends Entity implements MultipartPartAccess {
Vec3 right = new Vec3(forward.z, 0.0D, -forward.x);
Vec3 localOffset = new Vec3(
forward.x * definition.forwardOffset() + right.x * definition.lateralOffset(),
definition.yOffset() + (AntarchyGravityApi.isGravityInverted(parent) ? definition.height() : 0.0D),
definition.yOffset(),
forward.z * definition.forwardOffset() + right.z * definition.lateralOffset());
Vec3 offset = AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset, AntarchyGravityApi.getGravityDirection(parent));
Vec3 position = parent.position().add(offset);
@@ -86,7 +86,7 @@ public class MultipartPartEntity extends PartEntity<Entity> implements OwnableEn
Vec3 right = new Vec3(forward.z, 0.0D, -forward.x);
Vec3 localOffset = new Vec3(
forward.x * this.definition.forwardOffset() + right.x * this.definition.lateralOffset(),
this.definition.yOffset() + (AntarchyGravityApi.isGravityInverted(parent) ? this.definition.height() : 0.0D),
this.definition.yOffset(),
forward.z * this.definition.forwardOffset() + right.z * this.definition.lateralOffset());
Vec3 offset = AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset, AntarchyGravityApi.getGravityDirection(parent));
Vec3 position = parent.position().add(offset);