Skip to content

Commit

Permalink
envoy ?
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed May 1, 2024
1 parent 01f5542 commit bb7c928
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@
import net.id.paradiselost.client.model.armor.PhoenixArmorModel;
import net.id.paradiselost.client.model.block.DungeonSwitchModel;
import net.id.paradiselost.client.model.entity.*;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.util.Identifier;

import java.util.Map;

@Environment(EnvType.CLIENT)
public class ParadiseLostModelLayers {

public static final TexturedModelData INNER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(new Dilation(0.5F), 0.0F), 64, 32);
public static final TexturedModelData OUTER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(new Dilation(1.0F), 0.0F), 64, 32);

public static final Map<EntityModelLayer, TexturedModelData> ENTRIES = Maps.newHashMap();

public static final EntityModelLayer HELLENROSE = register("hellenrose", "main", ParadiseLostPlantModel.getTexturedModelData());
public static final EntityModelLayer ENVOY = register("envoy", "main", EnvoyEntityModel.getTexturedModelData());
public static final EntityModelLayer ENVOY_INNER_ARMOR = register("envoy", "inner_armor", INNER_ARMOR_MODEL_DATA);
public static final EntityModelLayer ENVOY_OUTER_ARMOR = register("envoy", "outer_armor", OUTER_ARMOR_MODEL_DATA);
public static final EntityModelLayer PARADISE_HARE = register("corsican_hare", "main", ParadiseHareModel.getTexturedModelData());
public static final EntityModelLayer MOA = register("moa", "main", MoaModel.getTexturedModelData());
public static final EntityModelLayer AMBYST = register("ambyst", "main", AmbystModel.getTexturedModelData());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.id.paradiselost.client.model.entity;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.id.paradiselost.entities.hostile.EnvoyEntity;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.SkeletonEntityModel;

@Environment(EnvType.CLIENT)
public class EnvoyEntityModel<T extends EnvoyEntity> extends SkeletonEntityModel<T> {
public EnvoyEntityModel(ModelPart modelPart) {
super(modelPart);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.id.paradiselost.client.model.entity;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.id.paradiselost.ParadiseLost;
import net.id.paradiselost.entities.hostile.EnvoyEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.EyesFeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.util.math.MatrixStack;

@Environment(EnvType.CLIENT)
public class EnvoyEyesFeatureRenderer<T extends EnvoyEntity> extends EyesFeatureRenderer<T, EnvoyEntityModel<T>> {

private static final RenderLayer TEXTURE = RenderLayer.getEyes(ParadiseLost.locate("textures/entity/envoy/envoy_enlightened_eyes.png"));

public EnvoyEyesFeatureRenderer(FeatureRendererContext<T, EnvoyEntityModel<T>> featureRendererContext) {
super(featureRendererContext);
}

public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
if (entity.getEnlightened()) {
super.render(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
}
}

@Override
public RenderLayer getEyesTexture() {
return TEXTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.id.incubus_core.blocklikeentities.api.client.BlockLikeEntityRenderer;
import net.id.paradiselost.client.rendering.entity.hostile.EnvoyEntityRenderer;
import net.id.paradiselost.client.rendering.entity.hostile.HellenroseRenderer;
import net.id.paradiselost.client.rendering.entity.passive.ParadiseHareRenderer;
import net.id.paradiselost.client.rendering.entity.passive.MoaEntityRenderer;
Expand All @@ -21,6 +22,7 @@ public static void initClient() {

// hostile
register(ParadiseLostEntityTypes.HELLENROSE, HellenroseRenderer::new);
register(ParadiseLostEntityTypes.ENVOY, EnvoyEntityRenderer::new);

// passive
register(ParadiseLostEntityTypes.MOA, MoaEntityRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.id.paradiselost.client.rendering.entity.hostile;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.id.paradiselost.ParadiseLost;
import net.id.paradiselost.client.model.ParadiseLostModelLayers;
import net.id.paradiselost.client.model.entity.EnvoyEyesFeatureRenderer;
import net.id.paradiselost.entities.hostile.EnvoyEntity;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.SkeletonEntityRenderer;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.util.Identifier;

@Environment(EnvType.CLIENT)
public class EnvoyEntityRenderer extends SkeletonEntityRenderer {
private static final Identifier TEXTURE = ParadiseLost.locate("textures/entity/envoy/envoy.png");
private static final Identifier TEXTURE_ENLIGHTENED = ParadiseLost.locate("textures/entity/envoy/envoy_enlightened.png");

public EnvoyEntityRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, ParadiseLostModelLayers.ENVOY, ParadiseLostModelLayers.ENVOY_INNER_ARMOR, ParadiseLostModelLayers.ENVOY_OUTER_ARMOR);
this.addFeature(new EnvoyEyesFeatureRenderer(this));
}

public Identifier getTexture(AbstractSkeletonEntity entity) {
if (((EnvoyEntity) entity).getEnlightened()) {
return TEXTURE_ENLIGHTENED;
}
return TEXTURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.id.paradiselost.ParadiseLost;
import net.id.paradiselost.entities.block.FloatingBlockEntity;
import net.id.paradiselost.entities.block.SliderEntity;
import net.id.paradiselost.entities.hostile.EnvoyEntity;
import net.id.paradiselost.entities.hostile.HellenroseEntity;
import net.id.paradiselost.entities.passive.ParadiseHareEntity;
import net.id.paradiselost.entities.passive.ParadiseLostAnimalEntity;
Expand All @@ -24,6 +25,7 @@
import net.minecraft.entity.ai.brain.sensor.SensorType;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.SkeletonEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
Expand All @@ -50,6 +52,8 @@ public class ParadiseLostEntityTypes {
// Hostile
public static final EntityType<HellenroseEntity> HELLENROSE = add("hellenrose", of(HellenroseEntity::new, MONSTER, changing(1f, 1f), 5),
attributes(HellenroseEntity::createHellenroseAttributes), spawnRestrictions(HellenroseEntity::canSpawn));
public static final EntityType<EnvoyEntity> ENVOY = add("envoy", of(EnvoyEntity::new, MONSTER, changing(1f, 2f), 7),
attributes(EnvoyEntity::createEnvoyAttributes), spawnRestrictions(EnvoyEntity::canMobSpawn));

// passive
public static final EntityType<MoaEntity> MOA = add("moa", of(MoaEntity::new, CREATURE, changing(1.0F, 2.0F), 5),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package net.id.paradiselost.entities.hostile;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.SkeletonEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;

public class EnvoyEntity extends SkeletonEntity {
private static final TrackedData<Boolean> ENLIGHTENED;

public EnvoyEntity(EntityType<? extends EnvoyEntity> entityType, World world) {
super(entityType, world);
}

public boolean getEnlightened() {
return this.dataTracker.get(ENLIGHTENED);
}

protected void initDataTracker() {
super.initDataTracker();
this.dataTracker.startTracking(ENLIGHTENED, false);
}

protected void initEquipment(Random random, LocalDifficulty localDifficulty) {
}

public boolean tryAttack(Entity target) {
if (!super.tryAttack(target)) {
return false;
} else {
if (target instanceof LivingEntity) {
((LivingEntity) target).addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 200), this);
}
return true;
}
}
public static DefaultAttributeContainer.Builder createEnvoyAttributes() {
return createHostileAttributes()
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2D);
}

@Override
public void writeCustomDataToNbt(NbtCompound compound) {
super.writeCustomDataToNbt(compound);
compound.putBoolean("Enlightened", this.dataTracker.get(ENLIGHTENED));
}

@Override
public void readCustomDataFromNbt(NbtCompound compound) {
super.readCustomDataFromNbt(compound);
this.dataTracker.set(ENLIGHTENED, compound.getBoolean("Enlightened"));
}

static {
ENLIGHTENED = DataTracker.registerData(EnvoyEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
}
}
Loading

0 comments on commit bb7c928

Please sign in to comment.