Skip to content

Commit

Permalink
feat: add new substitution log model
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed May 5, 2022
1 parent 7369d88 commit b68e7d3
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 99 deletions.
19 changes: 19 additions & 0 deletions BLOCKBENCH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Blockbench Help
=========

# Blockbench models
When saving the blockbench models you will have missing imports and package name. Make sure to re-add them.
```java
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.Entity;
```
Also use RenderType.entityCutoutNoCull for if you want the mob to render while your camera is inside the mob.

It also better represets what youll see from blockbench a lot more especially for 0 thick cubes.
1 change: 1 addition & 0 deletions models/SubstitutionLog.bbmodel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"format_version":"4.0","creation_time":1648078165,"model_format":"modded_entity","box_uv":true},"name":"SubstitutionLogModel","geometry_name":"SubstitutionLogModel","modded_entity_version":"1.17","visible_box":[1,1,0],"variable_placeholders":"","resolution":{"width":32,"height":32},"elements":[{"name":"branch","rescale":false,"locked":false,"from":[-4.4,5.500000000000002,-0.5],"to":[-2.4000000000000004,6.500000000000002,0.5],"autouv":0,"color":0,"rotation":[-19.999999999999996,0,0],"origin":[-2.5,6.000000000000002,-5.551115123125783e-17],"uv_offset":[0,15],"faces":{"north":{"uv":[1,16,3,17],"texture":0},"east":{"uv":[0,16,1,17],"texture":0},"south":{"uv":[4,16,6,17],"texture":0},"west":{"uv":[3,16,4,17],"texture":0},"up":{"uv":[3,16,1,15],"texture":0},"down":{"uv":[5,15,3,16],"texture":0}},"uuid":"2a17638f-24ad-b9ca-f436-ae5a8af261b5"},{"name":"leaf","rescale":false,"locked":false,"from":[-5.61731656763491,6.423879532511287,0.15000000000000002],"to":[-3.6173165676349104,8.423879532511286,0.15000000000000002],"autouv":0,"color":3,"rotation":[0,0,-10],"origin":[-4.61731656763491,7.423879532511287,0.15000000000000002],"faces":{"north":{"uv":[0,0,2,2],"texture":0},"east":{"uv":[0,0,0,2],"texture":0},"south":{"uv":[2,0,4,2],"texture":0},"west":{"uv":[2,0,2,2],"texture":0},"up":{"uv":[2,0,0,0],"texture":0},"down":{"uv":[4,0,2,0],"texture":0}},"uuid":"971466d1-29dd-36ba-af7f-0cc581f9010d"},{"name":"log","rescale":false,"locked":false,"from":[-2.4999999999999996,0,-2.4999999999999996],"to":[2.5000000000000004,10,2.5000000000000004],"autouv":0,"color":6,"origin":[4.440892098500626e-16,5,-5.551115123125783e-17],"faces":{"north":{"uv":[5,5,10,15],"texture":0},"east":{"uv":[0,5,5,15],"texture":0},"south":{"uv":[15,5,20,15],"texture":0},"west":{"uv":[10,5,15,15],"texture":0},"up":{"uv":[10,5,5,0],"texture":0},"down":{"uv":[15,0,10,5],"texture":0}},"uuid":"69337f8d-eb96-480d-026c-2392c6c7b66b"}],"outliner":[{"name":"main","origin":[-2.6724388558783034,6.141293177503762,0.04999999999999988],"color":0,"uuid":"695fb92b-8e92-f0c8-c7f2-cc14a6fea135","export":true,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["69337f8d-eb96-480d-026c-2392c6c7b66b","2a17638f-24ad-b9ca-f436-ae5a8af261b5","971466d1-29dd-36ba-af7f-0cc581f9010d"]}],"textures":[{"path":"/home/sekwah/.projects/MC_1_18/Naruto-Mod/src/main/resources/assets/narutomod/textures/entity/jutsu/substitution_log.png","name":"substitution_log.png","folder":"block","namespace":"","id":"0","particle":false,"render_mode":"normal","visible":true,"mode":"bitmap","saved":true,"uuid":"6726496f-f6e9-e127-b4e2-16e7c5481388","relative_path":"../../src/main/resources/assets/narutomod/textures/entity/jutsu/substitution_log.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACGklEQVRYR+1VSytFURReJ3S93VyPxL0GhCivRMJEMdBVpkwYmkn5EQZK/gETZiZEUR5RyjOKXEm5pMRFHqWko2/nu+2Om5yD2dmTfe7ae+31rW99a12jbiLNNDLeZKvr1ZDPFWwpMX1pCRJ5ehPsWPzWbRNzh1Ef+trdjZpRrxmX+S7bvU/Rx3o7KszqogzxeDySmJQqqztn6l2r7U8AxEIMAA3lOZKXnyX3d68yvRJSTFhts2snv2fgOwA4S06Ml+XdK3UNAHTbvzFADRAc6o5FPVATf8LAUE+9eXzxIG11BXJx/RwlZH0/LM1VAfW7OOCT8Zk96W4vl8XtSynze8Xqg/s4HxhdslUWgwCCTUWycRCWbG+KCkoANw8vysYAOgDdB+d9nTXSPzxvHwCcSwt9KrAOAA8SFDLmAgNWH8cAxgZbzamFI0U3s0UgBEQg2rCHziOSlZmuymX14f2RyU17DAAAadUBsATMDExg1Zbmqt3qw/uOAEB8zMCfm6oCwIZvPRC6AazAbvWhgG0DwNBB3XUAu6FrpQXYbu8ev5SHTMXycQxAbzsqXs8SwTAHAEzvDGiHjMBudzhF2xCZQvWn4YhSOL/xKLvDKlLdB3ccA6Dq0dcEwK7AGdTPIcSBxTYkI42VAdWyjhhAEF18TjKJ9Z/yE5uBNqTq9drbFdNPgsW6Y2toOA3ynZ8LwGXAZcBlwGXAZcBl4AMUaIkwf64ZfAAAAABJRU5ErkJggg=="}]}
Original file line number Diff line number Diff line change
@@ -1,58 +1,48 @@
package com.sekwah.narutomod.client.model.entity;
// Made with Blockbench 4.0.3
// Exported for Minecraft version 1.17 with Mojang mappings
// Paste this class into your mod and generate all required imports

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.Model;
import com.sekwah.narutomod.NarutoMod;
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.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.RenderType;

public class SubstitutionLogModel extends Model {

private final ModelPart main;

public SubstitutionLogModel(ModelPart modelPart)
{
super(RenderType::entitySolid);
this.main = modelPart.getChild("main");
}


public static LayerDefinition createLayer() {

MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition main = partdefinition.addOrReplaceChild("main",
CubeListBuilder.create()
.mirror(true)
.texOffs(0, 0)
.addBox(-2F, 0F, -2F, 4, 8, 4)
, PartPose.offsetAndRotation(0F, 5F, 0F, (float) Math.PI, 0F, 0F));

main.addOrReplaceChild("Shape2",
CubeListBuilder.create()
.mirror(true)
.texOffs(16, 0)
.addBox(-0.2666667F, 2F, -1.866667F, 4, 1, 1)
, PartPose.offsetAndRotation(0F, 0F, 0F, 0.4461433F, 0F, 0F));

main.addOrReplaceChild("Shape3",
CubeListBuilder.create()
.mirror(true)
.texOffs(26, 0)
.addBox(2.066667F, 1.733333F, 0F, 2, 2, 0)
, PartPose.offsetAndRotation(0F, 0F, 0F, 0F, 0F, -0.3717861F));

return LayerDefinition.create(meshdefinition, 64, 64);
}

@Override
public void renderToBuffer(PoseStack matrixStack, VertexConsumer vertexConsumer, int p_225598_3_, int p_225598_4_, float p_225598_5_, float p_225598_6_, float p_225598_7_, float p_225598_8_) {
this.main.render(matrixStack, vertexConsumer, p_225598_3_, p_225598_4_, p_225598_5_, p_225598_6_, p_225598_7_, p_225598_8_);
}
}
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;

public class SubstitutionLogModel<T extends Entity> extends EntityModel<T> {
// This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "substitution_log"), "main");
private final ModelPart main;

public SubstitutionLogModel(ModelPart root) {
this.main = root.getChild("main");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition main = partdefinition.addOrReplaceChild("main", CubeListBuilder.create().texOffs(0, 0).addBox(-5.1724F, -3.8587F, -2.55F, 5.0F, 10.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offset(2.6724F, 17.8587F, 0.05F));

PartDefinition leaf_r1 = main.addOrReplaceChild("leaf_r1", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -1.0F, 0.0F, 2.0F, 2.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(1.9449F, -1.2826F, 0.1F, 0.0F, 0.0F, -0.1745F));

PartDefinition branch_r1 = main.addOrReplaceChild("branch_r1", CubeListBuilder.create().texOffs(0, 15).addBox(-0.1F, -0.5F, -0.5F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.1724F, 0.1413F, -0.05F, 0.3491F, 0.0F, 0.0F));

return LayerDefinition.create(meshdefinition, 32, 32);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
main.render(poseStack, buffer, packedLight, packedOverlay);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.sekwah.narutomod.NarutoMod;
import com.sekwah.narutomod.util.ModelUtils;
import net.minecraft.client.model.HumanoidModel;
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.LivingEntity;


public class AnbuMaskModel<T extends LivingEntity> extends HumanoidModel<T> {

public static final ModelLayerLocation LAYER_LOCATION_WITHOUT_EARS =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "anbu_mask_without_ears"), "main");

public static final ModelLayerLocation LAYER_LOCATION =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "anbu_mask"), "main");

private final ModelPart head;

public AnbuMaskModel(ModelPart modelPart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.sekwah.narutomod.NarutoMod;
import com.sekwah.narutomod.util.ModelUtils;
import net.minecraft.client.model.HumanoidModel;
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.LivingEntity;

public class HeadbandModel<T extends LivingEntity> extends HumanoidModel<T>
{
public static final ModelLayerLocation LAYER_LOCATION =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "headband"), "main");
private final ModelPart head;

public HeadbandModel(ModelPart modelPart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.sekwah.narutomod.util.ModelUtils;
import net.minecraft.client.model.HumanoidModel;
import com.sekwah.narutomod.NarutoMod;
import net.minecraft.client.model.Model;
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.client.renderer.RenderType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.resources.ResourceLocation;

public class FireballJutsuModel extends Model
{
public static final ModelLayerLocation LAYER_LOCATION =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "fireball"), "main");
private final ModelPart main;

public FireballJutsuModel(ModelPart modelPart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.sekwah.narutomod.NarutoMod;
import net.minecraft.client.model.Model;
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.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

public class WaterBulletModel extends Model
{
public static final ModelLayerLocation LAYER_LOCATION =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "water_bullet"), "main");
private final ModelPart main;

public WaterBulletModel(ModelPart modelPart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
import com.sekwah.narutomod.client.renderer.entity.jutsuprojectile.FireballJutsuRenderer;
import com.sekwah.narutomod.client.renderer.entity.jutsuprojectile.WaterBulletJutsuRenderer;
import com.sekwah.narutomod.entity.NarutoEntities;
import com.sekwah.narutomod.entity.SubstitutionLogEntity;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
Expand All @@ -32,24 +29,6 @@ public class NarutoRenderEvents {

public static final BlockEntityWithoutLevelRenderer NARUTO_RENDERER = new NarutoRenderer();

public static final ModelLayerLocation ANBU_MASK_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "anbu_mask"), "main");

public static final ModelLayerLocation ANBU_MASK_WITHOUT_EARS_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "anbu_mask_without_ears"), "main");

public static final ModelLayerLocation HEADBAND_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "headband"), "main");

public static final ModelLayerLocation FIREBALL_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "fireball"), "main");

public static final ModelLayerLocation WATER_BULLET_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "water_bullet"), "main");

public static final ModelLayerLocation SUBSTITUTION_LOG_LAYER =
new ModelLayerLocation(new ResourceLocation(NarutoMod.MOD_ID, "substitution_log"), "main");

@SubscribeEvent
public static void entityRenderers(EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(NarutoEntities.KUNAI.get(), KunaiRenderer::new);
Expand Down Expand Up @@ -77,16 +56,16 @@ public static void reloadListener(RegisterClientReloadListenersEvent event) {
@SubscribeEvent
public static void layerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event)
{
event.registerLayerDefinition(ANBU_MASK_LAYER, () -> AnbuMaskModel.createLayer(true));
event.registerLayerDefinition(ANBU_MASK_WITHOUT_EARS_LAYER, () -> AnbuMaskModel.createLayer(false));
event.registerLayerDefinition(HEADBAND_LAYER, HeadbandModel::createLayer);
event.registerLayerDefinition(AnbuMaskModel.LAYER_LOCATION, () -> AnbuMaskModel.createLayer(true));
event.registerLayerDefinition(AnbuMaskModel.LAYER_LOCATION_WITHOUT_EARS, () -> AnbuMaskModel.createLayer(false));
event.registerLayerDefinition(HeadbandModel.LAYER_LOCATION, HeadbandModel::createLayer);

// Jutsu
event.registerLayerDefinition(FIREBALL_LAYER, FireballJutsuModel::createLayer);
event.registerLayerDefinition(WATER_BULLET_LAYER, WaterBulletModel::createLayer);
event.registerLayerDefinition(FireballJutsuModel.LAYER_LOCATION, FireballJutsuModel::createLayer);
event.registerLayerDefinition(WaterBulletModel.LAYER_LOCATION, WaterBulletModel::createLayer);

// Entity
event.registerLayerDefinition(SUBSTITUTION_LOG_LAYER, SubstitutionLogModel::createLayer);
event.registerLayerDefinition(SubstitutionLogModel.LAYER_LOCATION, SubstitutionLogModel::createBodyLayer);
}

/* @SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ public void onResourceManagerReload(ResourceManager resourceManager) {
EntityModelSet modelSet = Minecraft.getInstance().getEntityModels();

((NarutoArmorItem) NarutoItems.RED_ANBU_MASK.get())
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(NarutoRenderEvents.ANBU_MASK_LAYER)))
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(AnbuMaskModel.LAYER_LOCATION)))
.setArmorTexture("textures/models/armor/red_anbu_mask.png");
((NarutoArmorItem) NarutoItems.BLUE_ANBU_MASK.get())
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(NarutoRenderEvents.ANBU_MASK_LAYER)))
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(AnbuMaskModel.LAYER_LOCATION)))
.setArmorTexture("textures/models/armor/blue_anbu_mask.png");
((NarutoArmorItem) NarutoItems.GREEN_ANBU_MASK.get())
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(NarutoRenderEvents.ANBU_MASK_WITHOUT_EARS_LAYER)))
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(AnbuMaskModel.LAYER_LOCATION_WITHOUT_EARS)))
.setArmorTexture("textures/models/armor/green_anbu_mask.png");
((NarutoArmorItem) NarutoItems.MIST_ANBU_MASK.get())
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(NarutoRenderEvents.ANBU_MASK_WITHOUT_EARS_LAYER)))
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(AnbuMaskModel.LAYER_LOCATION_WITHOUT_EARS)))
.setArmorTexture("textures/models/armor/mist_anbu_mask.png");
((NarutoArmorItem) NarutoItems.YELLOW_ANBU_MASK.get())
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(NarutoRenderEvents.ANBU_MASK_WITHOUT_EARS_LAYER)))
.setArmorModel(new AnbuMaskModel(modelSet.bakeLayer(AnbuMaskModel.LAYER_LOCATION_WITHOUT_EARS)))
.setArmorTexture("textures/models/armor/yellow_anbu_mask.png");

setHeadbandRenderer(modelSet, NarutoItems.HEADBAND_BLUE, "textures/models/armor/headband/headband_blue_blank.png");
Expand Down Expand Up @@ -67,7 +67,7 @@ public void onResourceManagerReload(ResourceManager resourceManager) {

private void setHeadbandRenderer(EntityModelSet modelSet, RegistryObject<Item> item, String texture) {
((NarutoArmorItem) item.get())
.setArmorModel(new HeadbandModel(modelSet.bakeLayer(NarutoRenderEvents.HEADBAND_LAYER)))
.setArmorModel(new HeadbandModel(modelSet.bakeLayer(HeadbandModel.LAYER_LOCATION)))
.setArmorTexture(texture);
}
}

0 comments on commit b68e7d3

Please sign in to comment.