Jump to content

[1.12.2] Custom armor rotates different than player with small arms


Meldexun

Recommended Posts

So i have made a armor with a custom model. The model is tight on the player skin and is working properly with a normal Skin (the 4x12x4 arms from steve).

But with a skin with small arms the arms aren't rotating the same way as my armor. This results in the arms coming out of the armor from the  swing animation.

 

That's the model class:

	ModelRenderer diveRightArm;
		
	public Model() {
      	super(0.0F);
		this.textureWidth = 64;
		this.textureHeight = 64;
      
		diveRightArm = new ModelRenderer(this, 0, 80);
		diveRightArm.addBox(-2.0F, -2.0F, -2.0F, 4, 12, 4, 0.001F);
		diveRightArm.setRotationPoint(0.0F, 0.5F, 0.0F);
		diveRightArm.setTextureSize(textureWidthIn, textureHeightIn);
		diveRightArm.mirror = true;
		setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
	}
	
	@Override
	public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	}

 

The arms should be covered:

2019-04-17_02_12_16.png.ed35de9ff40c1bf72769810640a6d75d.png

Link to comment
Share on other sites

So i found out that when i extend my model class ModelPlayer instead of ModelBiped my model is rotating correctly with the arms. But that results in other problems. For example in multiplayer the armor is just rendered for yourself and others don't see it.

Has anyone experience with that?

Link to comment
Share on other sites

11 hours ago, Xumuk said:

In order not to create new threads, I'll ask my question here.

Make a new thread, having two people with different problems (even if the symptoms are the same) on the same thread never works out so as a general rule make your own thread. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

15 hours ago, Meldexun said:

For example in multiplayer the armor is just rendered for yourself and others don't see it.

Has anyone experience with that?

This usually means that you are using Minecraft#player when you shouldn’t be. Post your new code (all of it)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

3 hours ago, Cadiboo said:

This usually means that you are using Minecraft#player when you shouldn’t be.

I'm never using for this part of my mod.

 

So thats my new model class:

@SideOnly(Side.CLIENT)
public class ModelDivingGear extends ModelPlayer {
	
	ModelRenderer diveRightArm;
	ModelRenderer diveLeftArm;
	
	public ModelDivingGear(float scale, boolean smallArmsIn) {
		super(scale, smallArmsIn);
		this.textureHeight = 128;
		this.textureWidth = 64;
		
		//arms
		if (smallArmsIn) {
			diveRightArm = this.createCube(0, 48 + 32, -2.0F, -2.0F, -2.0F, 3, 12, 4, 0.251F);
			setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
			diveLeftArm = this.createCube(0, 48 + 32, -2.0F, -2.0F, -2.0F, 3, 12, 4, 0.251F);
			setRotation(diveLeftArm, 0.0F, (float) Math.PI, 0.0F);
		} else {
			diveRightArm = this.createCube(0, 48 + 32, -3.0F, -2.0F, -2.0F, 4, 12, 4, 0.251F);
			setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
			diveLeftArm = this.createCube(0, 48 + 32, -3.0F, -2.0F, -2.0F, 4, 12, 4, 0.251F);
			setRotation(diveLeftArm, 0.0F, (float) Math.PI, 0.0F);
		}
		
		bipedRightArm.addChild(diveRightArm);
		bipedLeftArm.addChild(diveLeftArm);
		
	}

	@Override
	public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	}
	
	private void setRotation(ModelRenderer model, float x, float y, float z) {
		model.rotateAngleX = x;
		model.rotateAngleY = y;
		model.rotateAngleZ = z;
	}
	
	private ModelRenderer createCube(int texOffX, int texOffY, float offX, float offY, float offZ, int width, int height, int depth, float scale) {
		ModelRenderer m = new ModelRenderer(this, texOffX, texOffY);
		m.addBox(offX, offY, offZ, width, height, depth, scale);
		m.setRotationPoint(0.0F, 0.0F, 0.0F);
		m.setTextureSize(textureWidth, textureHeight);
		m.mirror = true;
		return m;
	}
	
}

 

Here i create the model:

@EventBusSubscriber(Side.CLIENT)
public class ArmorModels {

	public static ModelDivingGear divingGearModel;
	public static ModelDivingGear divingGearModelSlim;
	public static ModelDivingGearLegs divingGearModelLegs;
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		divingGearModel = new ModelDivingGear(0.0F, false);
		divingGearModelSlim = new ModelDivingGear(0.0F, true);
		divingGearModelLegs = new ModelDivingGearLegs(0.0F);
	}
	
}

 

And i override the getArmorModel method:

	@SideOnly(Side.CLIENT)
	@Override
	public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) {
		return armorSlot == EntityEquipmentSlot.LEGS ? ArmorModels.divingGearModelLegs : entityLiving instanceof EntityPlayer && ((EntityPlayerSP) entityLiving).getSkinType().equals("slim") ? ArmorModels.divingGearModelSlim : ArmorModels.divingGearModel;
	}

 

I thought the getArmorModel method always passes you an EntityPlayerSP when a player is wearing the armor. But it may pass an EntityPlayerMP on servers? Is that right? That the only point that i don't really know about.

Edited by Meldexun
Link to comment
Share on other sites

12 hours ago, Meldexun said:

I thought the getArmorModel method always passes you an EntityPlayerSP when a player is wearing the armor. But it may pass an EntityPlayerMP on servers? Is that right? That the only point that i don't really know about.

Armor models are client side only so it will never pass an EntityPlayerMP. It may pass you an EntityOtherPlayerMP though. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

8 hours ago, Cadiboo said:

Armor models are client side only so it will never pass an EntityPlayerMP. It may pass you an EntityOtherPlayerMP though. 

Yeah, i also found this out already after some testing. So i'm now checking for AbstractClientPlayer (it may be named different). Also i changed my model again and all seems to work fine now. Thank you for the help.

Link to comment
Share on other sites

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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