Jump to content

Recommended Posts

Posted

I'm trying to render a custom helmet and the helmet rotates fine horizontally but it seems that it rotates on the x/z as well when I look vertically.

 

Here's a picture of what's happening:

https://imgur.com/a/TOYUDqb

 

Item class:

public class MythusArmorVar2 extends ArmorItem
{
    public MythusArmorVar2(IArmorMaterial mat, EquipmentSlotType slot)
    {
        super(mat, slot, new Properties().group(Mythus.MYTHUS_TAB));
    }

    @Nullable
    @Override
    public <A extends BipedModel<?>> A getArmorModel(LivingEntity ent, ItemStack stack, EquipmentSlotType slot, A _default) {
        if(!stack.isEmpty())
        {
            if(stack.getItem() instanceof ArmorItem)
            {
                KabutoHelmModel helm_model = new KabutoHelmModel(1);
                helm_model.bipedHead.showModel = slot == EquipmentSlotType.HEAD;

                helm_model.isChild = _default.isChild;
                helm_model.isSneak = _default.isSneak;
                helm_model.isSitting = _default.isSitting;
                helm_model.rightArmPose = _default.rightArmPose;
                helm_model.leftArmPose = _default.leftArmPose;

                return (A) helm_model;
            }
        }
        return null;
    }
}

 

Model Class:

public class KabutoHelmModel extends BipedModel<LivingEntity> {

	private final ModelRenderer basehelm;

	public KabutoHelmModel(float scale) {
		super(scale,0, 64, 64);
		textureWidth = 64;
		textureHeight = 64;

		basehelm = new ModelRenderer(this);
		basehelm.setRotationPoint(0.0F, 24.0F, 0.0F);
		basehelm.setTextureOffset(34, 0).addBox(-4.0F, -32.0F, -5.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(26, 16).addBox(4.0F, -32.0F, -4.0F, 1.0F, 4.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(23, 0).addBox(5.0F, -28.0F, -4.0F, 1.0F, 2.0F, 9.0F, 0.0F, false);
		basehelm.setTextureOffset(5, 25).addBox(4.0F, -30.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(60, 0).addBox(2.0F, -28.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(36, 16).addBox(-3.0F, -28.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(52, 4).addBox(-1.0F, -28.0F, -5.0F, 2.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(36, 21).addBox(-2.0F, -26.0F, -5.0F, 4.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(48, 9).addBox(1.0F, -27.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(53, 0).addBox(-2.0F, -27.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 19).addBox(-5.0F, -30.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 21).addBox(5.0F, -30.0F, -5.0F, 2.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 12).addBox(-7.0F, -30.0F, -5.0F, 2.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 9).addBox(7.0F, -30.0F, -4.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 0).addBox(-8.0F, -30.0F, -4.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 21).addBox(-6.0F, -28.0F, -4.0F, 1.0F, 2.0F, 9.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 9).addBox(-7.0F, -26.0F, -4.0F, 1.0F, 2.0F, 10.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 16).addBox(-6.0F, -26.0F, 5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 26).addBox(5.0F, -26.0F, 5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 3).addBox(-5.0F, -28.0F, 4.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 0).addBox(4.0F, -28.0F, 4.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 12).addBox(6.0F, -26.0F, -4.0F, 1.0F, 2.0F, 10.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 24).addBox(-5.0F, -32.0F, -4.0F, 1.0F, 4.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(30, 31).addBox(-4.0F, -32.0F, 4.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(22, 28).addBox(-5.0F, -28.0F, 5.0F, 10.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 11).addBox(-6.0F, -26.0F, 6.0F, 12.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 14).addBox(-3.0F, -29.0F, -6.0F, 6.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(34, 5).addBox(-3.0F, -31.0F, -6.0F, 6.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 0).addBox(-4.0F, -33.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(18, 13).addBox(-5.0F, -35.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(17, 9).addBox(-6.0F, -37.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(22, 24).addBox(3.0F, -33.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 16).addBox(2.0F, -33.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 9).addBox(3.0F, -35.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(5, 9).addBox(4.0F, -37.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 4).addBox(-3.0F, -33.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(4, 16).addBox(-4.0F, -35.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 16).addBox(-5.0F, -37.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(15, 24).addBox(4.0F, -35.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(11, 24).addBox(5.0F, -37.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 0).addBox(-4.0F, -33.0F, -4.0F, 8.0F, 1.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 33).addBox(-1.0F, -34.0F, 0.0F, 2.0F, 1.0F, 2.0F, 0.0F, false);
		this.bipedHead.addChild(basehelm);
	}

	@Override
	public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
		basehelm.setRotationPoint(0.0F, 24.0F, 0.0F);
		basehelm.render(matrixStack, buffer, packedLight, packedOverlay);
	}

	//TODO figure out why it isn't working
	@Override
	public void setRotationAngles(LivingEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		super.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
		this.basehelm.copyModelAngles(this.bipedHead);
	}
}

 

Posted

Howdy

 

You might find this link useful - it is a working example of how model rotations work, including an 'interactive' tool for adjusting your model parameters by typing commands- makes it a lot easier to tweak the render translations and rotations.

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe80_model_renderer

 

Off the cuff- the rotation point is probably not correct.  i.e. when your head tilts back, the y origin of rotation in your model doesn't correspond to the centre of rotation of the head.

 

-TGG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.