-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
45 changed files
with
1,132 additions
and
10 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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/fr/hugman/mubble/client/render/MubbleRenderLayers.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,22 @@ | ||
package fr.hugman.mubble.client.render; | ||
|
||
import fr.hugman.mubble.Mubble; | ||
import fr.hugman.mubble.client.render.entity.model.GoombaModel; | ||
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; | ||
import net.minecraft.client.render.entity.model.EntityModelLayer; | ||
|
||
public class MubbleRenderLayers { | ||
public static final EntityModelLayer GOOMBA = createModelLayer("goomba"); | ||
|
||
public static void registerLayers() { | ||
EntityModelLayerRegistry.registerModelLayer(GOOMBA, GoombaModel::getTexturedModelData); | ||
} | ||
|
||
private static EntityModelLayer createModelLayer(String name) { | ||
return new EntityModelLayer(Mubble.id(name), "main"); | ||
} | ||
|
||
private static EntityModelLayer createModelLayer(String name, String layer) { | ||
return new EntityModelLayer(Mubble.id(name), layer); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/fr/hugman/mubble/client/render/MubbleRenderers.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,17 @@ | ||
package fr.hugman.mubble.client.render; | ||
|
||
import fr.hugman.mubble.block.MubbleBlockEntityTypes; | ||
import fr.hugman.mubble.client.render.entity.GoombaRenderer; | ||
import fr.hugman.mubble.entity.MubbleEntityTypes; | ||
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; | ||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; | ||
|
||
public class MubbleRenderers { | ||
public static void registerEntities() { | ||
EntityRendererRegistry.register(MubbleEntityTypes.GOOMBA, GoombaRenderer::new); | ||
} | ||
|
||
public static void registerBlockEntities() { | ||
BlockEntityRendererFactories.register(MubbleBlockEntityTypes.BUMPABLE_BLOCK, BumpableBlockEntityRenderer::new); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/fr/hugman/mubble/client/render/entity/GoombaRenderer.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,37 @@ | ||
package fr.hugman.mubble.client.render.entity; | ||
|
||
import fr.hugman.mubble.client.render.MubbleRenderLayers; | ||
import fr.hugman.mubble.client.render.entity.model.GoombaModel; | ||
import fr.hugman.mubble.entity.GoombaEntity; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import net.minecraft.client.render.entity.MobEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class GoombaRenderer extends MobEntityRenderer<GoombaEntity, GoombaModel> { | ||
public GoombaRenderer(EntityRendererFactory.Context context) { | ||
super(context, new GoombaModel(context.getPart(MubbleRenderLayers.GOOMBA)), 0.4f); | ||
} | ||
|
||
@Override | ||
public Identifier getTexture(GoombaEntity entity) { | ||
return entity.getTexture(); | ||
} | ||
|
||
@Override | ||
public void render(GoombaEntity goomba, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { | ||
if(goomba.isSurprised()) { | ||
this.forceRotation(goomba); | ||
} | ||
super.render(goomba, f, g, matrixStack, vertexConsumerProvider, i); | ||
} | ||
|
||
private void forceRotation(GoombaEntity goomba) { | ||
goomba.prevHeadYaw = goomba.headYaw; | ||
goomba.bodyYaw = goomba.headYaw; | ||
goomba.prevBodyYaw = goomba.bodyYaw; | ||
goomba.prevPitch = goomba.getPitch(); | ||
goomba.prevYaw = goomba.getYaw(); | ||
} | ||
} |
Oops, something went wrong.