Very strangely almost got something to render for fairy "eye" layer - not what we want, but interesting enough to save.

This commit is contained in:
Ammon Lauritzen 2020-09-07 08:09:53 -05:00
parent 111b76b691
commit a6c909d375
4 changed files with 69 additions and 8 deletions

View File

@ -0,0 +1,52 @@
package org.mcupdater.fairies.client.model;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.model.IHasHead;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.LivingEntity;
import org.mcupdater.fairies.entity.FairyEntity;
public class LayerFairyEyes<T extends LivingEntity, M extends EntityModel<T> & IHasHead> extends LayerRenderer<T, M> {
public LayerFairyEyes(IEntityRenderer<T, M> entityRendererIn) {
super(entityRendererIn);
bipedHead = new ModelRenderer(entityRendererIn.getEntityModel(), 40, 0);
bipedHead.addBox(-3F, -6F, -3F, 6, 6, 6, 0.01F);
bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F);
}
@Override
public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
setRotationAngles(netHeadYaw, headPitch);
bipedHead.render(matrixStackIn, bufferIn.getBuffer(RenderType.getSolid()), packedLightIn, 0, 1.0f, 1.0f, 1.0f, 1.0f);
}
public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
bipedHead.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
}
public void setRotationAngles(float netHeadYaw, float headPitch) {
bipedHead.rotateAngleY = netHeadYaw / (180F / (float)Math.PI);
bipedHead.rotateAngleX = headPitch / (180F / (float)Math.PI);
if (flymode)
{
bipedHead.rotationPointZ = -3F;
bipedHead.rotationPointY = 19.75F;
}
else
{
bipedHead.rotationPointZ = 0.0F;
bipedHead.rotationPointY = 12F;
}
}
public boolean flymode;
public ModelRenderer bipedHead;
}

View File

@ -5,7 +5,6 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.client.renderer.entity.model.IHasHead;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.mcupdater.fairies.entity.FairyEntity;
public class ModelFairyEyes extends BipedModel<FairyEntity> implements IHasHead

View File

@ -3,14 +3,12 @@ package org.mcupdater.fairies.client.renderer;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.layers.HeadLayer;
import net.minecraft.client.renderer.entity.layers.HeldItemLayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.mcupdater.fairies.FairyFactions;
import org.mcupdater.fairies.client.model.ModelFairy;
import org.mcupdater.fairies.client.model.ModelFairyEyes;
import org.mcupdater.fairies.client.model.ModelFairyProps;
import org.mcupdater.fairies.client.model.ModelFairyProps2;
import org.mcupdater.fairies.client.model.*;
import org.mcupdater.fairies.entity.FairyEntity;
public class RenderFairy extends MobRenderer<FairyEntity, ModelFairy> {
@ -23,6 +21,8 @@ public class RenderFairy extends MobRenderer<FairyEntity, ModelFairy> {
public RenderFairy(EntityRendererManager renderManagerIn, ModelFairy entityModelIn, float shadowSizeIn) {
super(renderManagerIn, entityModelIn, shadowSizeIn);
this.addLayer(new HeldItemLayer<>(this));
//this.addLayer(new HeadLayer<FairyEntity, ModelFairy>(this, 1));
this.addLayer(new LayerFairyEyes<>(this));
this.fairyModel = entityModelIn;
this.fairyModel2 = new ModelFairyProps();

View File

@ -5,8 +5,12 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.goal.LookAtGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.mcupdater.fairies.FairyConfig;
@ -21,13 +25,19 @@ public class FairyEntity extends AnimalEntity {
public FairyEntity(EntityType<? extends FairyEntity> fairy, World world) {
super(fairy, world);
// appearance and variety
skinVariant = rand.nextInt(4);
isQueen = false;
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new WaterAvoidingRandomWalkingGoal(this, this.getAIMoveSpeed()));
int p = 0;
this.goalSelector.addGoal(++p, new SwimGoal(this));
// this.goalSelector.addGoal(++p, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
this.goalSelector.addGoal(++p, new LookAtGoal(this, PlayerEntity.class, 8.0F));
this.goalSelector.addGoal(++p, new LookRandomlyGoal(this));
}
@Override
@ -45,12 +55,12 @@ public class FairyEntity extends AnimalEntity {
public static AttributeModifierMap.MutableAttribute getAttributes() {
double max_health = 15.0D;
double movement_speed = 1.0D;
double movement_speed = 0.25D;
// NOTE: this may not work since the attributes are only got at initial load time?
if (FairyConfig.SPEC.isLoaded()) {
max_health = FairyConfig.GENERAL.healthBase.get();
movement_speed = FairyConfig.GENERAL.speedBase.get();
movement_speed *= FairyConfig.GENERAL.speedBase.get();
}
return MobEntity.func_233666_p_()