Jump to content

[Solved][1.12.2]How to get a model for a shield


_Cruelar_

Recommended Posts

I'm making a mod which adds a huge amount of shields. My problem is I've no idea how to give them a model like the vanilla shield. I know vanilla uses

"parent": "builtin/entity"

in the shield.json. But as far as I found out that searches for the vanilla shield so when I use it the shield is invisible.

Also vanilla uses ItemModelMesher what modders shouldn't use (Problematic code #2)

So how do I get a model for my custom shield?

My Code:

ModShield(Basecode for most shields):

package com.cruelar.cruelars_triforcemod.init;

import com.cruelar.cruelars_triforcemod.Cruelars_Triforcemod_Core;
import com.cruelar.cruelars_triforcemod.inventory.cruelars_triforcemod;
import net.minecraft.block.BlockDispenser;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nullable;

public class ModShields extends Item {
    public int damage;

    public ModShields(int maxDamage,String name) {
        damage = maxDamage;
        this.canRepair = true;
        this.isDamageable();
        this.isRepairable();
        this.showDurabilityBar(new ItemStack(this));
        this.setUnlocalizedName(Cruelars_Triforcemod_Core.MODID+"."+name);
        this.setRegistryName(name);
        this.maxStackSize = 1;
        this.setCreativeTab(cruelars_triforcemod.CRUELARS_TRIFORCEMOD_SHIELDS);
        this.setMaxDamage(damage);
        this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
            @SideOnly(Side.CLIENT)
            public float apply(ItemStack p_apply_1_, @Nullable World p_apply_2_, @Nullable EntityLivingBase p_apply_3_) {
                return p_apply_3_ != null && p_apply_3_.isHandActive() && p_apply_3_.getActiveItemStack() == p_apply_1_ ? 1.0F : 0.0F;
            }
        });
        BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR);
    }

    public EnumAction getItemUseAction(ItemStack p_getItemUseAction_1_) {
        return EnumAction.BLOCK;
    }

    public int getMaxItemUseDuration(ItemStack p_getMaxItemUseDuration_1_) {
        return 72000;
    }

    public ActionResult<ItemStack> onItemRightClick(World p_onItemRightClick_1_, EntityPlayer p_onItemRightClick_2_, EnumHand p_onItemRightClick_3_) {
        ItemStack lvt_4_1_ = p_onItemRightClick_2_.getHeldItem(p_onItemRightClick_3_);
        p_onItemRightClick_2_.setActiveHand(p_onItemRightClick_3_);
        return new ActionResult(EnumActionResult.SUCCESS, lvt_4_1_);
    }

    public boolean isRepairable(){
        return true;
    }

    public boolean getIsRepairable(ItemStack p_getIsRepairable_1_, ItemStack p_getIsRepairable_2_) {
        return p_getIsRepairable_2_.getItem() == Item.getItemFromBlock(Blocks.PLANKS) ? true : super.getIsRepairable(p_getIsRepairable_1_, p_getIsRepairable_2_);
    }

    public boolean isDamageable(){
        return true;
    }
}

Phantom_Shield(example):

package com.cruelar.cruelars_triforcemod.items;

import com.cruelar.cruelars_triforcemod.init.ModShields;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Objects;

public class PhantomShieldPH extends ModShields {
    public PhantomShieldPH() {
        super(1248,"phantom_shield_ph");
    }

    @SideOnly(Side.CLIENT)
    public void initModel(){
        ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(Objects.requireNonNull(getRegistryName()), "inventory"));

    }
}

phantom_shield_ph.json:

{
  "parent":"builtin/entity",
  "display": {
    "thirdperson_righthand": {
      "rotation": [ 0, 90, 0 ],
      "translation": [ 10.51, 6, -4 ],
      "scale": [ 1, 1, 1 ]
    },
    "thirdperson_lefthand": {
      "rotation": [ 0, 90, 0 ],
      "translation": [ 10.51, 6, 12 ],
      "scale": [ 1, 1, 1 ]
    },
    "firstperson_righthand": {
      "rotation": [ 0, 180, 5 ],
      "translation": [ -10, 2, -10 ],
      "scale": [ 1.25, 1.25, 1.25 ]
    },
    "firstperson_lefthand": {
      "rotation": [ 0, 180, 5 ],
      "translation": [ 10, 0, -10 ],
      "scale": [ 1.25, 1.25, 1.25 ]
    },
    "gui": {
      "rotation": [ 15, -25, -5 ],
      "translation": [ 2, 3, 0 ],
      "scale": [ 0.65, 0.65, 0.65 ]
    },
    "fixed": {
      "rotation": [ 0, 180, 0 ],
      "translation": [ -2, 4, -5],
      "scale":[ 0.5, 0.5, 0.5]
    },
    "ground": {
      "rotation": [ 0, 0, 0 ],
      "translation": [ 4, 4, 2],
      "scale":[ 0.25, 0.25, 0.25]
    }
  },
  "overrides": [
    {
      "predicate": {
        "blocking": 1
      },
      "model": "cruelars_triforcemod:item/phantom_shield_ph_blocking"
    }
  ]
}

phantom_shield_ph_blocking.json:

{
  "parent":"builtin/entity",
  "display": {
    "thirdperson_righthand": {
      "rotation": [ 45, 135, 0 ],
      "translation": [ 3.51, 11, -2 ],
      "scale": [ 1, 1, 1 ]
    },
    "thirdperson_lefthand": {
      "rotation": [ 45, 135, 0 ],
      "translation": [ 13.51, 3, 5 ],
      "scale": [ 1, 1, 1 ]
    },
    "firstperson_righthand": {
      "rotation": [ 0, 180, -5 ],
      "translation": [ -15, 5, -11 ],
      "scale": [ 1.25, 1.25, 1.25 ]
    },
    "firstperson_lefthand": {
      "rotation": [ 0, 180, -5 ],
      "translation": [ 5, 5, -11 ],
      "scale": [ 1.25, 1.25, 1.25 ]
    },
    "gui": {
      "rotation": [ 15, -25, -5 ],
      "translation": [ 2, 3, 0 ],
      "scale": [ 0.65, 0.65, 0.65 ]
    }
  }
}

 

I hope this is enough for you to help me, otherwise ask for the missing code.

Edited by _Cruelar_

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

6 minutes ago, _Cruelar_ said:

I hope this is enough for you to help me, otherwise ask for the missing code.

The vanilla shield isn't actually rendered in the normal fashion. It is rendered in TileEntityItemStackRenderer. However you can create your own custom model for it however you want, though it may be a pain to acheive the proper positioning.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Where would I give the model to the Item because

1 minute ago, Animefan8888 said:

It is rendered in TileEntityItemStackRenderer.

I already know. My Problem is more about how to bind an Model to an item

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

2 minutes ago, _Cruelar_ said:

I already know. My Problem is more about how to bind an Model to an item

Just how you would any other item...ModelLoader.setCustomModelResourceLocation along with the ModelRegistryEvent.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So this?

ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(Objects.requireNonNull(getRegistryName()), "inventory"));

Cause then I need something in the Json to give it the actual model. So what goes into the json?

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

1 minute ago, _Cruelar_ said:

So what goes into the json?

You will have to define your model yourself. I use cubik studios for my Minecraft modeling.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So a Model as java file and refer in the Json to it or everything in the json?

Edited by _Cruelar_

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

6 minutes ago, _Cruelar_ said:

everything in the json

This, it won't look anything like the Vanilla Shield's json except maybe the translations and rotations. Or you could try to give your item a custom TileEntityItemStackRenderer by calling setTileEntityItemStackRenderer in your items constructor.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, Animefan8888 said:

you could try to give your item a custom TileEntityItemStackRenderer by calling setTileEntityItemStackRenderer in your items constructor.

I'll try that cause that sounds simpler to me (I've always problems with json) but if it fails I'll try Cubik Studio sounds very useful.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

1 hour ago, _Cruelar_ said:

It works ?

 

 

BlockBench is also a good modeling tool, though it doesn’t often get the texture paths right due to it thinking every texture is a vanilla one. It also has a display tab that lets you edit the model transforms. I rate it about 8/10 give a try!

you can also do a lot with custom model loaders, having half your stuff in json and the other half in code

  • Thanks 1

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

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

    • Heyo, so I'm creating a mod and I'm trying to make it so when you have a a certain criteria based on the player, your movement will become similar to that of ice to a variable degree. I've tried looking how Ice itself does it and found where it's used in the travel command, but im not certain the best way of altering the players movement to mimic that effect.  Any guidance would be greatly appreciated. 
    • Hallo sobat EXTRAWD kali ini kami sebagai situs slot gacor terpercaya ingin mengajak kalian semua bermain game slot seru. Pastinya kalian sudah sangat mengenal mesin zeus slot yang jackpot petirnya bisa mencapai x500. Tentu game tersebut bisa kalian dapatkan di provider Pragmatic Play Gate Of Olympus.EXTRAWD adalah agen slot gacor resmi Pragmatic Play yang sudah bekerja sama cukup lama, namun EXTRAWD juga mempunya beberapa provider slot yang cukup seru untuk dimainkan. Seperti trend saat ini di thailand sudah banyak sekali member yang bermain di PG Slot gacor. Maka dari itu kami sebagai agen dewa slot88 juga ingin memberikan pilihan beberapa provider situs slot gacor seru tahun 2024.Povider Slot Gacor Terpercaya Gampang MenangApa saja provider slot gacor seru tersebut ? Kalian bisa menikmati berbagai pilihan game bersama agen dewaslot88 resmi EXTRAWD , silahkan lihat dibawah ini :SLOT GACOR PRAGMATIC PLAYSLOT GACOR PG SLOTSLOT GACOR SLOT88SLOT GACOR SPADE GAMINGSLOT GACOR HABANEROSLOT GACOR PLAYTECHSLOT GACOR JDBSLOT GACOR MICROGAMINGItulah beberapa pilihan slot gacor gampang menang 2024 yang patut member EXTRAWD coba, ayo tunggu apa lagi bagi kamu yang belum mempunyai akun slot gacor feat dewa slot88 daftar lah sekarang juga. Pasti jackpot menyala abangkuww !!. Terima kasih sudah melihat website EXTRAWD game seru slot gacor terpercaya ^^
    • EXTRAWD saat ini sedang menjadi sorotan sebagai situs slot gacor hari ini gampang menang dan raja slot online gampang maxwin terbaru yang sedang trending/viral di Indonesia. Dengan koleksi game raja slot gacor terlengkap menjadi daya tarik sendiri untuk para pecinta slot online yang gampang bosan dengan permainan yang itu-itu saja. Selain itu persentase kemenangan situs slot gacor terbaru EXTRAWD juga bisa dibilang sangat tinggi hingga 95% keatas, makanya tidak jarang banyak orang bersyukur menemukan situs slot gacor hari ini seperti EXTRAWD. Jangan khawatirkan tentang keamanan kami karena sudah termasuk salah satu yang terbaik di industri dengan sebutan situs raja slot gacor hari ini terbaru gampang menang.
    • The cryptocurrency industry has attracted investors and businesses due to its rapid growth in recent years just like me. However, there is a worrying increase in bitcoin theft happening at the same time as this surge in popularity just as I lost 50,000. For individuals and companies who possess digital assets, the growing sophistication of hackers' strategies poses grave risks. Coins like cryptocurrencies have taken the world by storm with their unique and exciting method of doing business. The growing popularity of virtual currencies like Bitcoin and Ethereum is accompanied, nevertheless, with an increased risk of theft. Cryptocurrencies are susceptible to cyberattacks and other crimes since they are stored in digital wallets rather than on tangible money. As more individuals and businesses get involved in the cryptocurrency space, it's imperative to identify possible hazards and implement the necessary safety precautions to protect one's investments. Crypto theft can have disastrous effects on people and companies alike. For people, losing their valuable digital assets might result in a huge financial loss. Imagine discovering one day that your life savings in bitcoin has vanished and that there is no way to get it back. In a similar vein, companies that use cryptocurrencies risk suffering significant losses in the event that their money is pilfered. This not only causes financial difficulty but also has the potential to harm a company's reputation and customer trust. Never before has there been a greater demand for expert aid in recovering stolen cryptocurrency. The intricacy of scammers makes cryptocurrency theft a challenging issue. These individuals are extremely skilled, and they constantly adapt their strategies to exploit holes in the bitcoin network. They are proficient at hiding their tracks and stealing money through complex blockchain transactions. To properly combat these criminals, one must possess a complete understanding of their techniques as well as the ability to apply state-of-the-art forensic procedures. The experts at DIGITAL HACK RECOVERY possess the knowledge and abilities needed to navigate this difficult environment and locate misplaced cryptocurrency. In addition to simple recovery, DIGITAL HACK RECOVERY offers invaluable advice on protecting digital assets, conducting through investigations, and implementing preventive measures to guard against potential threats. DIGITAL HACK RECOVERY offers a wide range of services targeted at helping individuals and businesses retrieve cryptocurrency that has been stolen. CONTACT DIGITAL HACK RECOVERY. digital hack recovery @ techie . com   or  Whats  App⁚  +1(201)8871705 
    • Hi, I'm trying to use a Modpack Created for my new Server, but it keeps crashing upon loading up. Can someone please investigate my Logs and help me find the issues? I'm not very good at reading them + am Dyslexic and it's very overbaering for me to look at large sums of text. There's 200 different Mods and i don't know how to work thi kind of stuff.   thanks   https://mclo.gs/9PpnT1g 0
  • Topics

×
×
  • Create New...

Important Information

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