nightmare fixes, new scorpion variant with emmesive texture

This commit is contained in:
craisinlord committed 2026-07-05 21:15:27 -05:00
1 parent 33b18c6cd2
commit cab314d30e
12 files changed
+121 -13

No files matched your search

@@ -6,19 +6,39 @@ import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.model.GeoModel;
public class ScorpionModel extends GeoModel<ScorpionEntity> {
private static final ResourceLocation MODEL =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "geo/scorpion.geo.json");
private static final ResourceLocation BLUE_TEXTURE =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/entity/scorpion/scorpion_blue.png");
private static final ResourceLocation GREEN_TEXTURE =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/entity/scorpion/scorpion_green.png");
private static final ResourceLocation BLUE_EMISSIVE_TEXTURE =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/entity/scorpion/scorpion_blue_emissive.png");
private static final ResourceLocation GREEN_EMISSIVE_TEXTURE =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/entity/scorpion/scorpion_green_emissive.png");
private static final ResourceLocation ANIMATION =
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "animations/scorpion.animation.json");
@Override
public ResourceLocation getModelResource(ScorpionEntity animatable) {
return ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "geo/scorpion.geo.json");
return MODEL;
}
@Override
public ResourceLocation getTextureResource(ScorpionEntity animatable) {
return ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/entity/scorpion.png");
return textureFor(animatable);
}
@Override
public ResourceLocation getAnimationResource(ScorpionEntity animatable) {
return ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "animations/scorpion.animation.json");
return ANIMATION;
}
public static ResourceLocation textureFor(ScorpionEntity animatable) {
return animatable.getTextureVariant() == ScorpionEntity.GREEN_VARIANT ? GREEN_TEXTURE : BLUE_TEXTURE;
}
public static ResourceLocation emissiveTextureFor(ScorpionEntity animatable) {
return animatable.getTextureVariant() == ScorpionEntity.GREEN_VARIANT ? GREEN_EMISSIVE_TEXTURE : BLUE_EMISSIVE_TEXTURE;
}
}
@@ -2,13 +2,53 @@ package com.craisinlord.antarchy.content.client.renderer;
import com.craisinlord.antarchy.content.client.model.ScorpionModel;
import com.craisinlord.antarchy.content.entity.ScorpionEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoEntityRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
public class ScorpionRenderer extends GeoEntityRenderer<ScorpionEntity> {
public ScorpionRenderer(EntityRendererProvider.Context context) {
super(context, new ScorpionModel());
this.shadowRadius = 0.6F;
this.addRenderLayer(new ScorpionEmissiveLayer(this));
}
@Override
public RenderType getRenderType(ScorpionEntity animatable, net.minecraft.resources.ResourceLocation texture, @Nullable MultiBufferSource bufferSource, float partialTick) {
return RenderType.entityCutoutNoCull(texture);
}
private static final class ScorpionEmissiveLayer extends GeoRenderLayer<ScorpionEntity> {
private ScorpionEmissiveLayer(GeoEntityRenderer<ScorpionEntity> renderer) {
super(renderer);
}
@Override
public void render(PoseStack poseStack, ScorpionEntity animatable, BakedGeoModel bakedModel, @Nullable RenderType renderType,
MultiBufferSource bufferSource, @Nullable VertexConsumer buffer, float partialTick,
int packedLight, int packedOverlay) {
RenderType emissiveType = RenderType.eyes(ScorpionModel.emissiveTextureFor(animatable));
VertexConsumer emissiveBuffer = bufferSource.getBuffer(emissiveType);
this.getRenderer().reRender(
bakedModel,
poseStack,
bufferSource,
animatable,
emissiveType,
emissiveBuffer,
partialTick,
0xF000F0,
OverlayTexture.NO_OVERLAY,
0xFFFFFFFF
);
}
}
}
@@ -2,8 +2,13 @@ package com.craisinlord.antarchy.content.entity;
import com.craisinlord.antarchy.content.AntarchySoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.Difficulty;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
@@ -13,6 +18,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
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.goal.FloatGoal;
@@ -39,6 +45,11 @@ import org.jetbrains.annotations.Nullable;
public class ScorpionEntity extends Monster implements GeoEntity {
private static final byte ATTACK_ANIM_EVENT = 4;
private static final EntityDataAccessor<Integer> TEXTURE_VARIANT =
SynchedEntityData.defineId(ScorpionEntity.class, EntityDataSerializers.INT);
private static final String TEXTURE_VARIANT_KEY = "TextureVariant";
public static final int BLUE_VARIANT = 0;
public static final int GREEN_VARIANT = 1;
private static final int ATTACK_ANIM_TICKS = 12;
private static final int ATTACK_HIT_TICK = 6;
@@ -82,6 +93,12 @@ public class ScorpionEntity extends Monster implements GeoEntity {
&& Monster.checkMonsterSpawnRules(entityType, level, spawnReason, pos, random);
}
@Override
protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder);
builder.define(TEXTURE_VARIANT, BLUE_VARIANT);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
@@ -93,6 +110,13 @@ public class ScorpionEntity extends Monster implements GeoEntity {
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
}
@Nullable
@Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData) {
this.assignRandomTextureVariant();
return super.finalizeSpawn(level, difficulty, spawnType, spawnGroupData);
}
@Override
public void tick() {
super.tick();
@@ -208,6 +232,22 @@ public class ScorpionEntity extends Monster implements GeoEntity {
return this.geoCache;
}
@Override
public void addAdditionalSaveData(CompoundTag tag) {
super.addAdditionalSaveData(tag);
tag.putInt(TEXTURE_VARIANT_KEY, this.getTextureVariant());
}
@Override
public void readAdditionalSaveData(CompoundTag tag) {
super.readAdditionalSaveData(tag);
if (tag.contains(TEXTURE_VARIANT_KEY)) {
this.setTextureVariant(tag.getInt(TEXTURE_VARIANT_KEY));
} else {
this.assignRandomTextureVariant();
}
}
@Override
protected SoundEvent getAmbientSound() {
return AntarchySoundEvents.SCORPION_AMBIENT.get();
@@ -228,6 +268,18 @@ public class ScorpionEntity extends Monster implements GeoEntity {
return 0.6F;
}
public int getTextureVariant() {
return this.entityData.get(TEXTURE_VARIANT);
}
public void setTextureVariant(int variant) {
this.entityData.set(TEXTURE_VARIANT, variant == GREEN_VARIANT ? GREEN_VARIANT : BLUE_VARIANT);
}
private void assignRandomTextureVariant() {
this.setTextureVariant(this.random.nextBoolean() ? BLUE_VARIANT : GREEN_VARIANT);
}
private final class ScorpionMeleeAttackGoal extends MeleeAttackGoal {
private ScorpionMeleeAttackGoal() {
super(ScorpionEntity.this, 1.15D, true);
@@ -82,6 +82,7 @@ public class NightmareEntity extends Monster implements GeoEntity {
private static final int COMBAT_ROAR_TICKS = 30;
private static final int DEATH_TICKS = 30;
private static final int TARGET_RESET_TICKS = 60;
private static final int MIN_AIRBORNE_TICKS_FOR_FLY_ANIM = 4;
private static final int DREAD_TICKS = 160;
private static final int WEAKNESS_TICKS = 100;
private static final int BLOCK_BREAK_TICKS = 10;
@@ -644,23 +645,18 @@ public class NightmareEntity extends Monster implements GeoEntity {
return;
}
if (this.attackAnimationTicks > 0) {
this.setAnimationState(this.onGround() ? ANIM_ATTACK : ANIM_FLY_ATTACK);
this.setAnimationState(this.isNoGravity() || this.airborneTicks >= MIN_AIRBORNE_TICKS_FOR_FLY_ANIM ? ANIM_FLY_ATTACK : ANIM_ATTACK);
this.groundMoveTicks = 0;
this.tickWingFlapSound();
return;
}
if (this.flyingToTarget) {
this.groundMoveTicks = 0;
if (this.onGround() || this.airborneTicks <= 8) {
this.setAnimationState(ANIM_FLY);
this.wingFlapCooldown = 0;
} else {
this.setAnimationState(ANIM_FLY);
this.tickWingFlapSound();
}
this.setAnimationState(ANIM_FLY);
this.tickWingFlapSound();
return;
}
if (!this.onGround()) {
if (this.isNoGravity() || this.airborneTicks >= MIN_AIRBORNE_TICKS_FOR_FLY_ANIM) {
this.groundMoveTicks = 0;
this.setAnimationState(ANIM_FLY);
this.tickWingFlapSound();
@@ -99,7 +99,7 @@
"pivot": [1, 1, 24],
"cubes": [
{"origin": [-5, 1, 24], "size": [10, 7, 8], "inflate": 0.01, "uv": [28, 35]},
{"origin": [-0.5, 8, 28], "size": [1, 5, 3], "inflate": 0.01, "uv": [28, 35]}
{"origin": [-0.5, 8, 28], "size": [1, 8, 3], "uv": [28, 50]}
]
},
{
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B