-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac7de9f
commit 6f12b17
Showing
13 changed files
with
373 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/herobrine/mod/client/renders/InfectedMooshroomEntityRender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.herobrine.mod.client.renders; | ||
|
||
import com.google.common.collect.Maps; | ||
import com.herobrine.mod.HerobrineMod; | ||
import com.herobrine.mod.client.renders.layers.InfectedMooshroomMushroomLayer; | ||
import com.herobrine.mod.entities.InfectedCowEntity; | ||
import com.herobrine.mod.entities.InfectedMooshroomEntity; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererManager; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.client.renderer.entity.model.CowModel; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.util.Util; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import net.minecraftforge.fml.client.registry.IRenderFactory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class InfectedMooshroomEntityRender extends MobRenderer<InfectedMooshroomEntity, CowModel<InfectedMooshroomEntity>> { | ||
private static final Map<InfectedMooshroomEntity.Type, ResourceLocation> field_217774_a = Util.make(Maps.newHashMap(), (p_217773_0_) -> { | ||
p_217773_0_.put(InfectedMooshroomEntity.Type.BROWN, HerobrineMod.location("textures/entity/infected_brown_mooshroom.png")); | ||
p_217773_0_.put(InfectedMooshroomEntity.Type.RED, HerobrineMod.location("textures/entity/infected_red_mooshroom.png")); | ||
}); | ||
|
||
public InfectedMooshroomEntityRender(EntityRendererManager renderManagerIn) { | ||
super(renderManagerIn, new CowModel<>(), 0.7F); | ||
this.addLayer(new InfectedMooshroomMushroomLayer<>(this)); | ||
} | ||
|
||
@NotNull | ||
public ResourceLocation getEntityTexture(@NotNull InfectedMooshroomEntity entity) { | ||
return field_217774_a.get(entity.getMooshroomType()); | ||
} | ||
|
||
public static class RenderFactory implements IRenderFactory { | ||
@Override | ||
public EntityRenderer<? super InfectedMooshroomEntity> createRenderFor(EntityRendererManager manager) { | ||
return new InfectedMooshroomEntityRender(manager); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/herobrine/mod/client/renders/layers/InfectedMooshroomMushroomLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.herobrine.mod.client.renders.layers; | ||
|
||
import com.herobrine.mod.entities.InfectedMooshroomEntity; | ||
import com.mojang.blaze3d.matrix.MatrixStack; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.BlockRendererDispatcher; | ||
import net.minecraft.client.renderer.IRenderTypeBuffer; | ||
import net.minecraft.client.renderer.Vector3f; | ||
import net.minecraft.client.renderer.entity.IEntityRenderer; | ||
import net.minecraft.client.renderer.entity.LivingRenderer; | ||
import net.minecraft.client.renderer.entity.layers.LayerRenderer; | ||
import net.minecraft.client.renderer.entity.model.CowModel; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class InfectedMooshroomMushroomLayer<T extends InfectedMooshroomEntity> extends LayerRenderer<T, CowModel<T>> { | ||
public InfectedMooshroomMushroomLayer(IEntityRenderer<T, CowModel<T>> rendererIn) { | ||
super(rendererIn); | ||
} | ||
|
||
public void render(@NotNull MatrixStack matrixStackIn, @NotNull IRenderTypeBuffer bufferIn, int packedLightIn, @NotNull T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { | ||
if (!entitylivingbaseIn.isChild() && !entitylivingbaseIn.isInvisible()) { | ||
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); | ||
BlockState blockstate = entitylivingbaseIn.getMooshroomType().getRenderState(); | ||
int i = LivingRenderer.getPackedOverlay(entitylivingbaseIn, 0.0F); | ||
matrixStackIn.push(); | ||
matrixStackIn.translate(0.2F, -0.35F, 0.5D); | ||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F)); | ||
matrixStackIn.scale(-1.0F, -1.0F, 1.0F); | ||
matrixStackIn.translate(-0.5D, -0.5D, -0.5D); | ||
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); | ||
matrixStackIn.pop(); | ||
matrixStackIn.push(); | ||
matrixStackIn.translate(0.2F, -0.35F, 0.5D); | ||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(42.0F)); | ||
matrixStackIn.translate(0.1F, 0.0D, -0.6F); | ||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-48.0F)); | ||
matrixStackIn.scale(-1.0F, -1.0F, 1.0F); | ||
matrixStackIn.translate(-0.5D, -0.5D, -0.5D); | ||
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); | ||
matrixStackIn.pop(); | ||
matrixStackIn.push(); | ||
this.getEntityModel().getHead().translateRotate(matrixStackIn); | ||
matrixStackIn.translate(0.0D, -0.7F, -0.2F); | ||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-78.0F)); | ||
matrixStackIn.scale(-1.0F, -1.0F, 1.0F); | ||
matrixStackIn.translate(-0.5D, -0.5D, -0.5D); | ||
blockrendererdispatcher.renderBlock(blockstate, matrixStackIn, bufferIn, packedLightIn, i); | ||
matrixStackIn.pop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.