-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix piranha & add tortoise (no anim yet)
- Loading branch information
Showing
8 changed files
with
419 additions
and
82 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
320 changes: 320 additions & 0 deletions
320
src/main/java/com/uraneptus/sullysmod/client/animations/TortoiseAnimation.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
86 changes: 66 additions & 20 deletions
86
src/main/java/com/uraneptus/sullysmod/client/model/TortoiseModel.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 |
---|---|---|
@@ -1,37 +1,83 @@ | ||
package com.uraneptus.sullysmod.client.model; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.uraneptus.sullysmod.SullysMod; | ||
import com.uraneptus.sullysmod.common.entities.Tortoise; | ||
import net.minecraft.resources.ResourceLocation; | ||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone; | ||
import software.bernie.geckolib.core.animation.AnimationState; | ||
import software.bernie.geckolib.model.DefaultedEntityGeoModel; | ||
|
||
public class TortoiseModel <T extends Tortoise> extends DefaultedEntityGeoModel<T> { | ||
public TortoiseModel() { | ||
super(SullysMod.modPrefix("tortoise"), true); | ||
import net.minecraft.client.model.EntityModel; | ||
import net.minecraft.client.model.geom.ModelLayerLocation; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
|
||
public class TortoiseModel<E extends Tortoise> extends EntityModel<E> implements RootModel { | ||
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(SullysMod.modPrefix("tortoise"), "main"); | ||
|
||
private final ModelPart root; | ||
private final ModelPart body; | ||
private final ModelPart left_back_leg; | ||
private final ModelPart right_back_leg; | ||
private final ModelPart right_front_leg; | ||
private final ModelPart left_front_leg; | ||
private final ModelPart shell; | ||
private final ModelPart workstation_saddle; | ||
private final ModelPart head; | ||
private final ModelPart tail; | ||
|
||
public TortoiseModel(ModelPart pRoot) { | ||
this.root = pRoot; | ||
this.body = root.getChild("body"); | ||
this.left_back_leg = body.getChild("left_back_leg"); | ||
this.right_back_leg = body.getChild("right_back_leg"); | ||
this.right_front_leg = body.getChild("right_front_leg"); | ||
this.left_front_leg = body.getChild("left_front_leg"); | ||
this.shell = body.getChild("shell"); | ||
this.workstation_saddle = shell.getChild("workstation_saddle"); | ||
this.head = shell.getChild("head"); | ||
this.tail = shell.getChild("tail"); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getModelResource(T object) { | ||
return SullysMod.modPrefix("geo/tortoise.geo.json"); | ||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
|
||
PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 0.0F)); | ||
|
||
body.addOrReplaceChild("left_back_leg", CubeListBuilder.create().texOffs(50, 39).addBox(-2.0F, -1.0F, -3.0F, 5.0F, 6.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(7.0F, -5.0F, 9.0F, 0.0F, -1.1345F, 0.0F)); | ||
body.addOrReplaceChild("right_back_leg", CubeListBuilder.create().texOffs(50, 39).mirror().addBox(-3.0F, -1.0F, -3.0F, 5.0F, 6.0F, 5.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-7.0F, -5.0F, 9.0F, 0.0F, 1.1345F, 0.0F)); | ||
body.addOrReplaceChild("right_front_leg", CubeListBuilder.create().texOffs(50, 39).mirror().addBox(-3.0F, -1.0F, -2.0F, 5.0F, 6.0F, 5.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-7.0F, -5.0F, -9.0F, 0.0F, 0.3927F, 0.0F)); | ||
body.addOrReplaceChild("left_front_leg", CubeListBuilder.create().texOffs(50, 39).addBox(-2.0F, -1.0F, -2.0F, 5.0F, 6.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(7.0F, -5.0F, -9.0F, 0.0F, -0.3927F, 0.0F)); | ||
|
||
PartDefinition shell = body.addOrReplaceChild("shell", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -17.0F, -8.0F, 16.0F, 14.0F, 18.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 32).addBox(-8.0F, -17.0F, -8.0F, 16.0F, 14.0F, 18.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, 0.0F, -0.5F)); | ||
|
||
shell.addOrReplaceChild("workstation_saddle", CubeListBuilder.create().texOffs(0, 64).addBox(-8.0F, -18.0F, -7.0F, 16.0F, 16.0F, 16.0F, new CubeDeformation(0.01F)), PartPose.offset(0.0F, -3.0F, 0.0F)); | ||
|
||
PartDefinition head = shell.addOrReplaceChild("head", CubeListBuilder.create().texOffs(50, 0).addBox(-3.0F, -2.0F, -9.0F, 6.0F, 6.0F, 9.0F, new CubeDeformation(0.0F)) | ||
.texOffs(80, 0).addBox(-3.0F, -2.5F, -9.0F, 6.0F, 6.0F, 9.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, -5.5F, -6.0F)); | ||
|
||
PartDefinition tail = shell.addOrReplaceChild("tail", CubeListBuilder.create(), PartPose.offset(0.0F, -3.0F, 9.0F)); | ||
|
||
//PartDefinition cube_r1 = tail.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 10).addBox(-1.0F, -1.5F, -1.0F, 2.0F, 2.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0F, 1.0F, -0.2182F, 0.0F, 0.0F)); | ||
|
||
return LayerDefinition.create(meshdefinition, 128, 128); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureResource(T object) { | ||
return object.isCraftingTable() ? SullysMod.modPrefix("textures/entity/tortoise/tortoise_crafting.png") : SullysMod.modPrefix("textures/entity/tortoise/tortoise_jukebox.png"); | ||
public void setupAnim(E pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) { | ||
if (!pEntity.hasAppliedWorkstation()) { | ||
this.workstation_saddle.visible = false; | ||
} | ||
//TODO do all the animations | ||
} | ||
|
||
@Override | ||
public ResourceLocation getAnimationResource(T animatable) { | ||
return SullysMod.modPrefix("animations/tortoise.animation.json"); | ||
public void renderToBuffer(PoseStack pPoseStack, VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { | ||
this.root().render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay); | ||
} | ||
|
||
@Override | ||
public void setCustomAnimations(T animatable, long instanceId, AnimationState<T> animationState) { | ||
super.setCustomAnimations(animatable, instanceId, animationState); | ||
CoreGeoBone saddle = getAnimationProcessor().getBone("WorkstationSaddle"); | ||
|
||
saddle.setHidden(!animatable.hasAppliedWorkstation()); | ||
public ModelPart root() { | ||
return this.root; | ||
} | ||
} |
33 changes: 17 additions & 16 deletions
33
src/main/java/com/uraneptus/sullysmod/client/renderer/entities/TortoiseRenderer.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 |
---|---|---|
@@ -1,33 +1,34 @@ | ||
package com.uraneptus.sullysmod.client.renderer.entities; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.uraneptus.sullysmod.SullysMod; | ||
import com.uraneptus.sullysmod.client.model.TortoiseModel; | ||
import com.uraneptus.sullysmod.common.entities.Tortoise; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import software.bernie.geckolib.cache.object.BakedGeoModel; | ||
import software.bernie.geckolib.renderer.GeoEntityRenderer; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class TortoiseRenderer <E extends Tortoise> extends GeoEntityRenderer<E> { | ||
public TortoiseRenderer(EntityRendererProvider.Context renderManager) { | ||
super(renderManager, new TortoiseModel<>()); | ||
this.shadowRadius = 0.75F; | ||
} | ||
public class TortoiseRenderer<E extends Tortoise> extends MobRenderer<E, TortoiseModel<E>> { | ||
private static final ResourceLocation TEXTURE_CRAFTING = SullysMod.modPrefix("textures/entity/tortoise/tortoise_crafting.png"); | ||
private static final ResourceLocation TEXTURE_JUKEBOX = SullysMod.modPrefix("textures/entity/tortoise/tortoise_jukebox.png"); | ||
|
||
//Reduced motionThreshold to detect entities that are moving slowly e.g. Tortoise | ||
@Override | ||
public float getMotionAnimThreshold(E animatable) { | ||
return 0.005F; | ||
public TortoiseRenderer(EntityRendererProvider.Context pContext) { | ||
super(pContext, new TortoiseModel<>(pContext.bakeLayer(TortoiseModel.LAYER_LOCATION)), 0.75F); | ||
} | ||
|
||
@Override | ||
public void preRender(PoseStack poseStack, E animatable, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { | ||
super.preRender(poseStack, animatable, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha); | ||
public void render(E pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight) { | ||
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight); | ||
|
||
if (animatable.isBaby()) { | ||
poseStack.scale(0.15F, 0.15F, 0.15F); | ||
if (pEntity.isBaby()) { | ||
pPoseStack.scale(0.15F, 0.15F, 0.15F); | ||
this.shadowRadius *= 0.15F; | ||
} | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureLocation(E pEntity) { | ||
return pEntity.isCraftingTable() ? TEXTURE_CRAFTING : TEXTURE_JUKEBOX; | ||
} | ||
} |
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