diff --git a/src/main/java/fathertoast/specialmobs/client/renderer/entity/SpecialCreeperRenderer.java b/src/main/java/fathertoast/specialmobs/client/renderer/entity/SpecialCreeperRenderer.java index 5551e80..40bda55 100644 --- a/src/main/java/fathertoast/specialmobs/client/renderer/entity/SpecialCreeperRenderer.java +++ b/src/main/java/fathertoast/specialmobs/client/renderer/entity/SpecialCreeperRenderer.java @@ -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 diff --git a/src/main/java/fathertoast/specialmobs/client/renderer/entity/layers/SpecialMobEyesLayer.java b/src/main/java/fathertoast/specialmobs/client/renderer/entity/layers/SpecialMobEyesLayer.java new file mode 100644 index 0000000..a524b54 --- /dev/null +++ b/src/main/java/fathertoast/specialmobs/client/renderer/entity/layers/SpecialMobEyesLayer.java @@ -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> extends AbstractEyesLayer { + private final RenderType FALLBACK = RenderType.eyes( new ResourceLocation( "textures/entity/spider_eyes.png" ) ); + + public SpecialMobEyesLayer( IEntityRenderer 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; + } +} \ No newline at end of file diff --git a/src/main/java/fathertoast/specialmobs/common/entity/ISpecialMob.java b/src/main/java/fathertoast/specialmobs/common/entity/ISpecialMob.java index 5fd5abd..754c624 100644 --- a/src/main/java/fathertoast/specialmobs/common/entity/ISpecialMob.java +++ b/src/main/java/fathertoast/specialmobs/common/entity/ISpecialMob.java @@ -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> { /** @return This mob's special data. */ SpecialMobData 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(); } \ No newline at end of file diff --git a/src/main/java/fathertoast/specialmobs/common/entity/SpecialMobData.java b/src/main/java/fathertoast/specialmobs/common/entity/SpecialMobData.java index 1b42d5f..2f526c3 100644 --- a/src/main/java/fathertoast/specialmobs/common/entity/SpecialMobData.java +++ b/src/main/java/fathertoast/specialmobs/common/entity/SpecialMobData.java @@ -142,7 +142,7 @@ public class SpecialMobData> { familyScale = baseScale = familyBaseScale; - //setTextures( entity.getDefaultTextures() ); TODO + setTextures( entity.getDefaultTextures() ); entity.getEntityData().define( renderScale, nextScale() ); } @@ -462,7 +462,7 @@ public class SpecialMobData> { 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() ); diff --git a/src/main/java/fathertoast/specialmobs/common/entity/creeper/DarkCreeperEntity.java b/src/main/java/fathertoast/specialmobs/common/entity/creeper/DarkCreeperEntity.java index 76dbea6..d0b4f61 100644 --- a/src/main/java/fathertoast/specialmobs/common/entity/creeper/DarkCreeperEntity.java +++ b/src/main/java/fathertoast/specialmobs/common/entity/creeper/DarkCreeperEntity.java @@ -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 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; } } \ No newline at end of file diff --git a/src/main/java/fathertoast/specialmobs/common/entity/creeper/_SpecialCreeperEntity.java b/src/main/java/fathertoast/specialmobs/common/entity/creeper/_SpecialCreeperEntity.java index fbf38cf..9cd7649 100644 --- a/src/main/java/fathertoast/specialmobs/common/entity/creeper/_SpecialCreeperEntity.java +++ b/src/main/java/fathertoast/specialmobs/common/entity/creeper/_SpecialCreeperEntity.java @@ -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 ----------------