-
Notifications
You must be signed in to change notification settings - Fork 65
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
62a2b19
commit b64e86c
Showing
22 changed files
with
385 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
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
83 changes: 83 additions & 0 deletions
83
src/main/java/com/github/tartaricacid/touhoulittlemaid/client/model/EntityBoxModel.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,83 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.model; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBox; | ||
import com.mojang.blaze3d.matrix.MatrixStack; | ||
import com.mojang.blaze3d.vertex.IVertexBuilder; | ||
import net.minecraft.client.renderer.entity.model.EntityModel; | ||
import net.minecraft.client.renderer.model.ModelRenderer; | ||
|
||
public class EntityBoxModel extends EntityModel<EntityBox> { | ||
private final ModelRenderer bottom; | ||
private final ModelRenderer x1; | ||
private final ModelRenderer x2; | ||
private final ModelRenderer z1; | ||
private final ModelRenderer z2; | ||
private final ModelRenderer top; | ||
|
||
public EntityBoxModel() { | ||
texWidth = 256; | ||
texHeight = 256; | ||
|
||
bottom = new ModelRenderer(this); | ||
bottom.setPos(0.0F, 24.0F, 0.0F); | ||
bottom.texOffs(0, 0).addBox(-15.0F, -1.0F, -15.0F, 30.0F, 1.0F, 30.0F, 0.0F, false); | ||
|
||
x1 = new ModelRenderer(this); | ||
x1.setPos(0.0F, 23.5F, -14.5F); | ||
x1.texOffs(64, 31).addBox(-14.0F, -30.5F, -0.5F, 28.0F, 30.0F, 1.0F, 0.0F, false); | ||
|
||
x2 = new ModelRenderer(this); | ||
x2.setPos(0.0F, 23.5F, 14.5F); | ||
x2.texOffs(64, 31).addBox(-14.0F, -30.5F, -0.5F, 28.0F, 30.0F, 1.0F, 0.0F, false); | ||
|
||
z1 = new ModelRenderer(this); | ||
z1.setPos(14.5F, 23.5F, 0.0F); | ||
z1.texOffs(0, 31).addBox(-0.5F, -30.5F, -15.0F, 1.0F, 30.0F, 30.0F, 0.0F, false); | ||
|
||
z2 = new ModelRenderer(this); | ||
z2.setPos(-14.5F, 23.5F, 0.0F); | ||
z2.texOffs(0, 31).addBox(-0.5F, -30.5F, -15.0F, 1.0F, 30.0F, 30.0F, 0.0F, false); | ||
|
||
top = new ModelRenderer(this); | ||
top.setPos(0.0F, 24.0F, 0.0F); | ||
top.texOffs(0, 0).addBox(-15.0F, -32.0F, -15.0F, 30.0F, 1.0F, 30.0F, 0.0F, false); | ||
top.texOffs(64, 64).addBox(-16.0F, -32.0F, -16.0F, 32.0F, 6.0F, 1.0F, 0.0F, false); | ||
top.texOffs(64, 64).addBox(-16.0F, -32.0F, 15.0F, 32.0F, 6.0F, 1.0F, 0.0F, false); | ||
top.texOffs(32, 61).addBox(-16.0F, -32.0F, -15.0F, 1.0F, 6.0F, 30.0F, 0.0F, false); | ||
top.texOffs(32, 61).addBox(15.0F, -32.0F, -15.0F, 1.0F, 6.0F, 30.0F, 0.0F, false); | ||
} | ||
|
||
@Override | ||
public void setupAnim(EntityBox entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | ||
int stage = entityIn.getOpenStage(); | ||
if (stage == EntityBox.FIRST_STAGE) { | ||
top.visible = true; | ||
x1.xRot = 0; | ||
x2.xRot = 0; | ||
z1.zRot = 0; | ||
z2.zRot = 0; | ||
} else if (stage > EntityBox.SECOND_STAGE) { | ||
top.visible = false; | ||
x1.xRot = 0; | ||
x2.xRot = 0; | ||
z1.zRot = 0; | ||
z2.zRot = 0; | ||
} else { | ||
top.visible = false; | ||
x1.xRot = 0.023998277f * (EntityBox.SECOND_STAGE - stage); | ||
x2.xRot = -0.023998277f * (EntityBox.SECOND_STAGE - stage); | ||
z1.zRot = 0.023998277f * (EntityBox.SECOND_STAGE - stage); | ||
z2.zRot = -0.023998277f * (EntityBox.SECOND_STAGE - stage); | ||
} | ||
} | ||
|
||
@Override | ||
public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { | ||
bottom.render(matrixStack, buffer, packedLight, packedOverlay); | ||
x1.render(matrixStack, buffer, packedLight, packedOverlay); | ||
x2.render(matrixStack, buffer, packedLight, packedOverlay); | ||
z1.render(matrixStack, buffer, packedLight, packedOverlay); | ||
z2.render(matrixStack, buffer, packedLight, packedOverlay); | ||
top.render(matrixStack, buffer, packedLight, packedOverlay); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...java/com/github/tartaricacid/touhoulittlemaid/client/renderer/entity/EntityBoxRender.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,51 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.renderer.entity; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.client.model.EntityBoxModel; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBox; | ||
import com.google.common.collect.Lists; | ||
import com.mojang.blaze3d.matrix.MatrixStack; | ||
import com.mojang.blaze3d.vertex.IVertexBuilder; | ||
import net.minecraft.client.renderer.IRenderTypeBuffer; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererManager; | ||
import net.minecraft.client.renderer.entity.model.EntityModel; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
public class EntityBoxRender extends EntityRenderer<EntityBox> { | ||
private final List<ResourceLocation> texturesGroup = Lists.newArrayList(); | ||
private final EntityModel<EntityBox> boxModel; | ||
|
||
public EntityBoxRender(EntityRendererManager manager) { | ||
super(manager); | ||
boxModel = new EntityBoxModel(); | ||
IntStream.range(0, EntityBox.MAX_TEXTURE_SIZE).forEach(this::addBoxTexture); | ||
} | ||
|
||
@Override | ||
public void render(EntityBox entityBox, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer bufferIn, int packedLight) { | ||
matrixStack.pushPose(); | ||
matrixStack.scale(-1.0F, -1.0F, 1.0F); | ||
matrixStack.translate(0.0, -1.501, 0.0); | ||
boxModel.setupAnim(entityBox, 0, 0, -0.1f, 0, 0); | ||
RenderType renderType = RenderType.entityTranslucent(getTextureLocation(entityBox)); | ||
IVertexBuilder buffer = bufferIn.getBuffer(renderType); | ||
boxModel.renderToBuffer(matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); | ||
matrixStack.popPose(); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureLocation(EntityBox entity) { | ||
return texturesGroup.get(entity.getTextureIndex()); | ||
} | ||
|
||
private void addBoxTexture(int index) { | ||
String fileName = String.format("textures/entity/box/cake_box_%s.png", index); | ||
texturesGroup.add(new ResourceLocation(TouhouLittleMaid.MOD_ID, fileName)); | ||
} | ||
} |
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.