-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
369 additions
and
0 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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/github/tartaricacid/touhoulittlemaid/client/model/EntityYukkuriModel.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,48 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.model; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
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.*; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.monster.Slime; | ||
|
||
public class EntityYukkuriModel extends EntityModel<Slime> { | ||
public static final ModelLayerLocation LAYER = new ModelLayerLocation(new ResourceLocation(TouhouLittleMaid.MOD_ID, "main"), "yukkuri"); | ||
private final ModelPart bone; | ||
|
||
public EntityYukkuriModel(ModelPart root) { | ||
this.bone = root.getChild("bone"); | ||
} | ||
|
||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
PartDefinition bone = partdefinition.addOrReplaceChild("bone", CubeListBuilder.create().texOffs(0, 18).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 0).addBox(-4.5F, -8.5F, -4.5F, 9.0F, 9.0F, 9.0F, new CubeDeformation(0.0F)) | ||
.texOffs(38, 0).mirror().addBox(3.0F, -3.75F, -5.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(-0.35F)).mirror(false) | ||
.texOffs(38, 0).addBox(-5.0F, -3.75F, -5.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(-0.35F)) | ||
.texOffs(0, 0).addBox(-1.5F, -11.0F, -2.0F, 2.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); | ||
PartDefinition bone2 = bone.addOrReplaceChild("bone2", CubeListBuilder.create().texOffs(48, 14).addBox(-0.8195F, -2.0F, 0.1061F, 7.0F, 4.0F, 1.0F, new CubeDeformation(-0.2F)), PartPose.offsetAndRotation(0.0F, -6.5F, 4.0F, 0.0F, -0.1745F, -0.4363F)); | ||
PartDefinition bone3 = bone.addOrReplaceChild("bone3", CubeListBuilder.create().texOffs(48, 14).mirror().addBox(-6.1805F, -2.0F, 0.1061F, 7.0F, 4.0F, 1.0F, new CubeDeformation(-0.2F)).mirror(false), PartPose.offsetAndRotation(0.0F, -6.5F, 4.0F, 0.0F, 0.1745F, 0.4363F)); | ||
PartDefinition bone4 = bone.addOrReplaceChild("bone4", CubeListBuilder.create().texOffs(50, 20).addBox(-0.3195F, -2.0F, 0.1061F, 6.0F, 4.0F, 1.0F, new CubeDeformation(-0.3F)), PartPose.offsetAndRotation(0.0F, -6.5F, 4.0F, 0.0F, -0.1745F, 2.7053F)); | ||
PartDefinition bone5 = bone.addOrReplaceChild("bone5", CubeListBuilder.create().texOffs(50, 20).mirror().addBox(-5.6805F, -2.0F, 0.1061F, 6.0F, 4.0F, 1.0F, new CubeDeformation(-0.3F)).mirror(false), PartPose.offsetAndRotation(0.0F, -6.5F, 4.0F, 0.0F, 0.1745F, -2.7053F)); | ||
PartDefinition bone6 = bone.addOrReplaceChild("bone6", CubeListBuilder.create().texOffs(48, 0).addBox(0.1F, -3.5F, -3.3F, 2.0F, 7.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(3.0F, -3.0F, 1.0F, 0.0F, 0.0F, -0.2618F)); | ||
PartDefinition bone7 = bone.addOrReplaceChild("bone7", CubeListBuilder.create().texOffs(48, 0).mirror().addBox(-2.1F, -3.5F, -3.3F, 2.0F, 7.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-3.0F, -3.0F, 1.0F, 0.0F, 0.0F, 0.2618F)); | ||
PartDefinition bone8 = bone.addOrReplaceChild("bone8", CubeListBuilder.create().texOffs(54, 35).addBox(-2.0F, -0.6042F, -1.0909F, 4.0F, 9.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -8.0F, 6.0F, 0.1745F, 0.0F, 0.0F)); | ||
return LayerDefinition.create(meshdefinition, 64, 64); | ||
} | ||
|
||
@Override | ||
public void setupAnim(Slime slime, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | ||
} | ||
|
||
@Override | ||
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { | ||
bone.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...github/tartaricacid/touhoulittlemaid/client/renderer/entity/EntityYukkuriSlimeRender.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,50 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.renderer.entity; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.client.model.EntityYukkuriModel; | ||
import com.github.tartaricacid.touhoulittlemaid.config.subconfig.VanillaConfig; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.client.renderer.entity.SlimeRenderer; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.monster.Slime; | ||
|
||
public class EntityYukkuriSlimeRender extends MobRenderer<Slime, EntityYukkuriModel> { | ||
private static final ResourceLocation TEXTURE = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/entity/yukkuri.png"); | ||
private final SlimeRenderer vanillaRender; | ||
|
||
public EntityYukkuriSlimeRender(EntityRendererProvider.Context context) { | ||
super(context, new EntityYukkuriModel(context.bakeLayer(EntityYukkuriModel.LAYER)), 0.25F); | ||
this.vanillaRender = new SlimeRenderer(context); | ||
} | ||
|
||
@Override | ||
public void render(Slime slime, float yaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) { | ||
if (VanillaConfig.REPLACE_SLIME_MODEL.get()) { | ||
renderYukkuri(slime, yaw, partialTicks, poseStack, buffer, packedLight); | ||
} else { | ||
vanillaRender.render(slime, yaw, partialTicks, poseStack, buffer, packedLight); | ||
} | ||
} | ||
|
||
private void renderYukkuri(Slime slime, float yaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) { | ||
this.shadowRadius = 0.25F * (float) slime.getSize(); | ||
super.render(slime, yaw, partialTicks, poseStack, buffer, packedLight); | ||
} | ||
|
||
protected void scale(Slime slime, PoseStack poseStack, float partialTicks) { | ||
poseStack.scale(0.999F, 0.999F, 0.999F); | ||
poseStack.translate(0.0F, 0.001F, 0.0F); | ||
float slimeSize = (float) slime.getSize(); | ||
float tmp = Mth.lerp(partialTicks, slime.oSquish, slime.squish) / (slimeSize * 0.5F + 1.0F); | ||
float scale = 1.0F / (tmp + 1.0F); | ||
poseStack.scale(scale * slimeSize, 1.0F / scale * slimeSize, scale * slimeSize); | ||
} | ||
|
||
public ResourceLocation getTextureLocation(Slime slime) { | ||
return TEXTURE; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...ub/tartaricacid/touhoulittlemaid/client/renderer/entity/ReplaceExperienceOrbRenderer.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,76 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.renderer.entity; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.config.subconfig.VanillaConfig; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Axis; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.ExperienceOrbRenderer; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.ExperienceOrb; | ||
import org.joml.Matrix3f; | ||
import org.joml.Matrix4f; | ||
|
||
public class ReplaceExperienceOrbRenderer extends EntityRenderer<ExperienceOrb> { | ||
private static final ResourceLocation POINT_ITEM_TEXTURE = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/entity/point_item.png"); | ||
private static final RenderType RENDER_TYPE = RenderType.entityCutoutNoCull(POINT_ITEM_TEXTURE); | ||
private final ExperienceOrbRenderer vanillaRender; | ||
|
||
public ReplaceExperienceOrbRenderer(EntityRendererProvider.Context context) { | ||
super(context); | ||
this.shadowRadius = 0.15F; | ||
this.shadowStrength = 0.75F; | ||
this.vanillaRender = new ExperienceOrbRenderer(context); | ||
} | ||
|
||
protected int getBlockLightLevel(ExperienceOrb pEntity, BlockPos pPos) { | ||
return Mth.clamp(super.getBlockLightLevel(pEntity, pPos) + 7, 0, 15); | ||
} | ||
|
||
@Override | ||
public void render(ExperienceOrb orb, float pEntityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) { | ||
if (VanillaConfig.REPLACE_XP_TEXTURE.get()) { | ||
renderPointItem(orb, pEntityYaw, partialTicks, poseStack, buffer, packedLight); | ||
} else { | ||
vanillaRender.render(orb, pEntityYaw, partialTicks, poseStack, buffer, packedLight); | ||
} | ||
} | ||
|
||
private void renderPointItem(ExperienceOrb orb, float pEntityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) { | ||
poseStack.pushPose(); | ||
int icon = orb.getIcon(); | ||
float texU1 = (float) (icon % 4 * 16) / 64.0F; | ||
float texU2 = (float) (icon % 4 * 16 + 16) / 64.0F; | ||
float texV2 = (float) (icon / 4 * 16) / 64.0F; | ||
float texV1 = (float) (icon / 4 * 16 + 16) / 64.0F; | ||
poseStack.translate(0.0F, 0.1F, 0.0F); | ||
poseStack.mulPose(this.entityRenderDispatcher.cameraOrientation()); | ||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F)); | ||
poseStack.scale(0.3F, 0.3F, 0.3F); | ||
VertexConsumer consumer = buffer.getBuffer(RENDER_TYPE); | ||
PoseStack.Pose lasted = poseStack.last(); | ||
Matrix4f pose = lasted.pose(); | ||
Matrix3f normal = lasted.normal(); | ||
vertex(consumer, pose, normal, -0.5F, -0.25F, 255, 255, 255, texU1, texV1, packedLight); | ||
vertex(consumer, pose, normal, 0.5F, -0.25F, 255, 255, 255, texU2, texV1, packedLight); | ||
vertex(consumer, pose, normal, 0.5F, 0.75F, 255, 255, 255, texU2, texV2, packedLight); | ||
vertex(consumer, pose, normal, -0.5F, 0.75F, 255, 255, 255, texU1, texV2, packedLight); | ||
poseStack.popPose(); | ||
super.render(orb, pEntityYaw, partialTicks, poseStack, buffer, packedLight); | ||
} | ||
|
||
private static void vertex(VertexConsumer pConsumer, Matrix4f pMatrix, Matrix3f pMatrixNormal, float pX, float pY, int pRed, int pGreen, int pBlue, float pTexU, float pTexV, int pPackedLight) { | ||
pConsumer.vertex(pMatrix, pX, pY, 0.0F).color(pRed, pGreen, pBlue, 128).uv(pTexU, pTexV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(pPackedLight).normal(pMatrixNormal, 0.0F, 1.0F, 0.0F).endVertex(); | ||
} | ||
|
||
public ResourceLocation getTextureLocation(ExperienceOrb pEntity) { | ||
return POINT_ITEM_TEXTURE; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
.../com/github/tartaricacid/touhoulittlemaid/client/renderer/item/ReplaceableBakedModel.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,72 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.renderer.item; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.block.model.BakedQuad; | ||
import net.minecraft.client.renderer.block.model.ItemOverrides; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.item.ItemDisplayContext; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
public class ReplaceableBakedModel implements BakedModel { | ||
private final BakedModel rawBakedModel; | ||
private final BakedModel replacedBakedModel; | ||
private final Supplier<Boolean> isReplace; | ||
|
||
public ReplaceableBakedModel(BakedModel rawBakedModel, BakedModel replacedBakedModel, Supplier<Boolean> isReplace) { | ||
this.rawBakedModel = rawBakedModel; | ||
this.replacedBakedModel = replacedBakedModel; | ||
this.isReplace = isReplace; | ||
} | ||
|
||
@Override | ||
public List<BakedQuad> getQuads(@Nullable BlockState pState, @Nullable Direction pDirection, RandomSource random) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public boolean useAmbientOcclusion() { | ||
return rawBakedModel.useAmbientOcclusion(); | ||
} | ||
|
||
@Override | ||
public boolean isGui3d() { | ||
return rawBakedModel.isGui3d(); | ||
} | ||
|
||
@Override | ||
public boolean usesBlockLight() { | ||
return rawBakedModel.usesBlockLight(); | ||
} | ||
|
||
@Override | ||
public boolean isCustomRenderer() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public TextureAtlasSprite getParticleIcon() { | ||
return rawBakedModel.getParticleIcon(); | ||
} | ||
|
||
@Override | ||
public ItemOverrides getOverrides() { | ||
return ItemOverrides.EMPTY; | ||
} | ||
|
||
@Override | ||
public BakedModel applyTransform(ItemDisplayContext type, PoseStack mat, boolean applyLeftHandTransform) { | ||
if (isReplace.get()) { | ||
return this.replacedBakedModel.applyTransform(type, mat, applyLeftHandTransform); | ||
} else { | ||
return this.rawBakedModel.applyTransform(type, mat, applyLeftHandTransform); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...main/java/com/github/tartaricacid/touhoulittlemaid/client/renderer/item/package-info.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,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package com.github.tartaricacid.touhoulittlemaid.client.renderer.item; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
Oops, something went wrong.