Base textures impl

This commit is contained in:
FatherToast 2022-06-20 14:04:57 -05:00
parent 85e1825e3c
commit ecbe689b1b
6 changed files with 76 additions and 15 deletions

View file

@ -1,6 +1,7 @@
package fathertoast.specialmobs.client.renderer.entity;
import com.mojang.blaze3d.matrix.MatrixStack;
import fathertoast.specialmobs.client.renderer.entity.layers.SpecialMobEyesLayer;
import fathertoast.specialmobs.common.entity.ISpecialMob;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.client.renderer.entity.CreeperRenderer;
@ -23,14 +24,13 @@ public class SpecialCreeperRenderer extends CreeperRenderer {
public SpecialCreeperRenderer( EntityRendererManager rendererManager ) {
super( rendererManager );
baseShadowRadius = shadowRadius;
// addLayer( new LayerSpecialMobEyes<>( this ) ); TODO render layer impl
// addLayer( new LayerSpecialMobOverlay<>( this, new CreeperModel<>( 0.25F ) ) );
// addLayer( new SpecialMobEyesLayer<>( this ) );TODO
// addLayer( new SpecialMobOverlayLayer<>( this, new CreeperModel<>( 0.25F ) ) );
}
@Override
public ResourceLocation getTextureLocation( CreeperEntity entity ) {
return super.getTextureLocation( entity );
//return ((ISpecialMob<?>) entity).getSpecialData().getTexture();TODO textures
return ((ISpecialMob<?>) entity).getSpecialData().getTexture();
}
@Override

View file

@ -0,0 +1,49 @@
package fathertoast.specialmobs.client.renderer.entity.layers;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import fathertoast.specialmobs.common.core.SpecialMobs;
import fathertoast.specialmobs.common.entity.ISpecialMob;
import mcp.MethodsReturnNonnullByDefault;
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.AbstractEyesLayer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
@OnlyIn( Dist.CLIENT )
public class SpecialMobEyesLayer<T extends Entity, M extends EntityModel<T>> extends AbstractEyesLayer<T, M> {
private final RenderType FALLBACK = RenderType.eyes( new ResourceLocation( "textures/entity/spider_eyes.png" ) );
public SpecialMobEyesLayer( IEntityRenderer<T, M> renderer ) {
super( renderer );
}
// I have no clue what all these floats mean, but also I don't really care right now. Would be nice to know eventually.
@Override
public void render( MatrixStack matrixStack, IRenderTypeBuffer buffer, int layer, T entity,
float a, float b, float c, float d, float e, float f ) {
final ResourceLocation eyesTexture = ((ISpecialMob<?>) entity).getSpecialData().getTextureEyes();
if( eyesTexture == null ) return;
//TODO does not work; for some reason, all the transparency renders as white
IVertexBuilder ivertexbuilder = buffer.getBuffer( RenderType.eyes( eyesTexture ) );
this.getParentModel().renderToBuffer( matrixStack, ivertexbuilder, 15728640, OverlayTexture.NO_OVERLAY,
1.0F, 1.0F, 1.0F, 1.0F );
}
@Override
public RenderType renderType() {
SpecialMobs.LOG.warn( "Something is attempting to get eye layer 'render type' for some reason! :(" );
return FALLBACK;
}
}

View file

@ -2,17 +2,21 @@ package fathertoast.specialmobs.common.entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.util.ResourceLocation;
public interface ISpecialMob<T extends LivingEntity & ISpecialMob<T>> {
/** @return This mob's special data. */
SpecialMobData<T> getSpecialData();
/** @return The experience that should be dropped by the entity. */
/** @return The experience that should be dropped by this entity. */
int getExperience();
/** Sets the experience that should be dropped by the entity. */
/** Sets the experience that should be dropped by this entity. */
void setExperience( int xp );
/** Sets the entity's pathfinding malus for a particular node type; negative value is un-walkable. */
void setPathfindingMalus( PathNodeType nodeType, float malus );
/** @return All default textures for this entity. */
ResourceLocation[] getDefaultTextures();
}

View file

@ -142,7 +142,7 @@ public class SpecialMobData<T extends LivingEntity & ISpecialMob<T>> {
familyScale = baseScale = familyBaseScale;
//setTextures( entity.getDefaultTextures() ); TODO
setTextures( entity.getDefaultTextures() );
entity.getEntityData().define( renderScale, nextScale() );
}
@ -462,7 +462,7 @@ public class SpecialMobData<T extends LivingEntity & ISpecialMob<T>> {
tag.putInt( TAG_EXPERIENCE, theEntity.getExperience() );
tag.putByte( TAG_REGENERATION, (byte) healTimeMax );
//tag.putString( TAG_TEXTURE, texture.toString() );TODO textures
tag.putString( TAG_TEXTURE, texture.toString() );
tag.putString( TAG_TEXTURE_EYES, textureEyes == null ? "" : textureEyes.toString() );
tag.putString( TAG_TEXTURE_OVER, textureOverlay == null ? "" : textureOverlay.toString() );

View file

@ -17,6 +17,7 @@ import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EntityExplosionContext;
import net.minecraft.world.Explosion;
@ -134,4 +135,13 @@ public class DarkCreeperEntity extends _SpecialCreeperEntity {
protected void modifyVariantLingeringCloudEffects( List<EffectInstance> potions ) {
potions.add( new EffectInstance( Effects.BLINDNESS, 100 ) );
}
private static final ResourceLocation[] TEXTURES = {
new ResourceLocation( GET_TEXTURE_PATH( "dark" ) ),
new ResourceLocation( GET_TEXTURE_PATH( "dark_eyes" ) )
};
/** @return All default textures for this entity. */
@Override
public ResourceLocation[] getDefaultTextures() { return TEXTURES; }
}

View file

@ -277,15 +277,13 @@ public class _SpecialCreeperEntity extends CreeperEntity implements ISpecialMob<
@Override
public final void setExperience( int xp ) { xpReward = xp; }
static String GET_TEXTURE_PATH( String type ) { return SpecialMobs.TEXTURE_PATH + "creeper/" + type + ".png"; }
private static final ResourceLocation[] TEXTURES = { new ResourceLocation( "textures/entity/creeper/creeper.png" ) };
static String GET_TEXTURE_PATH( String type ) {
return SpecialMobs.TEXTURE_PATH + "creeper/" + type + ".png";
}
// /** @return This entity's default textures. */
// @Override
// public ResourceLocation[] getDefaultTextures() { return TEXTURES; }
/** @return All default textures for this entity. */
@Override
public ResourceLocation[] getDefaultTextures() { return TEXTURES; }
//TODO--------------- SpecialMobData Hooks ----------------