Jump to content

Can't set name of planks correctly


Jack4096

Recommended Posts

I am trying to set the name of the planks, but I have no idea even after studying the code for hours, how to even add the names of the blocks. Their name is just "planks" but I WANT to concatenate String "planks" with the planks' enum's assigned name, to add an "_", and then add the name of the enum of the plank. Please ask for additional information if my problem seems unclear, and there are no crashes or error messages:

 

public class MagicPlank extends Block implements IHasModel
{
    public static final PropertyEnum<MagicPlank.EnumType> VARIANT = PropertyEnum.<MagicPlank.EnumType>create("variant", MagicPlank.EnumType.class);

    public MagicPlank(String name, Material material)
    {
    	super(material);
    	
    	setUnlocalizedName(name);
        setRegistryName(name);
        
        ModBlocks.BLOCKS.add(this);
		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
        
        this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, MagicPlank.EnumType.MAGIC));
    }

    /**
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
     * returns the metadata of the dropped item based on the old metadata of the block.
     */
    public int damageDropped(IBlockState state)
    {
        return ((MagicPlank.EnumType)state.getValue(VARIANT)).getMetadata();
    }

    /**
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
     */
    public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items)
    {
        for (MagicPlank.EnumType magicplank$enumtype : MagicPlank.EnumType.values())
        {
            items.add(new ItemStack(this, 1, magicplank$enumtype.getMetadata()));
        }
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(VARIANT, MagicPlank.EnumType.byMetadata(meta));
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        return ((MagicPlank.EnumType)state.getValue(VARIANT)).getMapColor();
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((MagicPlank.EnumType)state.getValue(VARIANT)).getMetadata();
    }
    
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VARIANT});
    }

    public static enum EnumType implements IStringSerializable
    {
        MAGIC(0, "magic", MapColor.SAND),
    	MAPLE(1, "maple", MapColor.SAND),
    	REDWOOD(2, "redwood", MapColor.SAND),
    	YEW(3, "yew", MapColor.SAND);
        
        private static final MagicPlank.EnumType[] META_LOOKUP = new MagicPlank.EnumType[values().length];
        private final int meta;
        private final String name;
        private final String unlocalizedName;
        /** The color that represents this entry on a map. */
        private final MapColor mapColor;

        private EnumType(int metaIn, String nameIn, MapColor mapColorIn)
        {
            this(metaIn, nameIn, nameIn, mapColorIn);
        }

        private EnumType(int metaIn, String nameIn, String unlocalizedNameIn, MapColor mapColorIn)
        {
            this.meta = metaIn;
            this.name = nameIn;
            this.unlocalizedName = unlocalizedNameIn;
            this.mapColor = mapColorIn;
        }

        public int getMetadata()
        {
            return this.meta;
        }

        /**
         * The color which represents this entry on a map.
         */
        public MapColor getMapColor()
        {
            return this.mapColor;
        }

        public String toString()
        {
            return this.name;
        }

        public static MagicPlank.EnumType byMetadata(int meta)
        {
            if (meta < 0 || meta >= META_LOOKUP.length)
            {
                meta = 0;
            }

            return META_LOOKUP[meta];
        }

        public String getName()
        {
            return this.name;
        }

        public String getUnlocalizedName()
        {
            return this.unlocalizedName;
        }

        static
        {
            for (MagicPlank.EnumType magicplank$enumtype : values())
            {
                META_LOOKUP[magicplank$enumtype.getMetadata()] = magicplank$enumtype;
            }
        }
        
    }
    
    @Override
    public void registerModels() {
        Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
    }
    
}

 

Link to comment
Share on other sites

15 minutes ago, Jack4096 said:

WANT to concatenate String "planks" with the planks' enum's assigned name, to add an "_", and then add the name of the enum of the plank.

Override getUnlocalizedName(ItemStack) and base it off of the metadata. Then you will have to put multiple entries into your lang file.

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

7 minutes ago, Animefan8888 said:

Override getUnlocalizedName(ItemStack) and base it off of the metadata. Then you will have to put multiple entries into your lang file.

I tried to figure out how to do that, and I couldn't figure out how. Could you please explain?

Link to comment
Share on other sites

1 minute ago, Jack4096 said:

I tried to figure out how to do that, and I couldn't figure out how. Could you please explain?

You will need a custom ItemBlock implementation which I assume you have because your block has metadata. There is where you will override the method I said above.

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

18 hours ago, Jack4096 said:

implements IHasModel

Don’t use IHasModel or anything like it. All items have models and it leads to you writing code over and over again when you could just solve the entire problem in 3 lines of code.

for(Item item: ModItems) {

  ModelLoader.setCustomModelLocation(item, meta, model location);

}

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

On 10/12/2018 at 6:01 PM, Cadiboo said:

Don’t use IHasModel or anything like it. All items have models and it leads to you writing code over and over again when you could just solve the entire problem in 3 lines of code.

for(Item item: ModItems) {

  ModelLoader.setCustomModelLocation(item, meta, model location);

}

I tried to figure out where to put this code, but I couldn't figure it out, could you explain? Please. Also, what exactly would I put for "item" and "model location"?

Edited by Jack4096
Link to comment
Share on other sites

7 minutes ago, Jack4096 said:

what exactly would I put for "item" and "model location"?

You don't have to put anything for "item" since it is a variable already, look at the example provided.

As for "model location" you would put something like

new ModelResourceLocation(item.getRegistryName(), "inventory");

 

8 minutes ago, Jack4096 said:

where to put this code

In your ModelRegistryEvent.

Link to comment
Share on other sites

On 10/14/2018 at 8:53 AM, V0idWa1k3r said:

You don't have to put anything for "item" since it is a variable already, look at the example provided.

As for "model location" you would put something like


new ModelResourceLocation(item.getRegistryName(), "inventory");

 

In your ModelRegistryEvent.

Honestly I have no idea how to write any of the code you guys are suggesting... I have no idea how. Could you guys just help with setting proper names for each plank in the enum? For all 4 plank types? For Magic, Maple, Redwood, and Yew?

Edited by Jack4096
Was changing the question
Link to comment
Share on other sites

put this code

for(Item item: allYourItems) {
	ModelLoader.setCustomModelResourceLocation(item, itemMeta, new ModelResourceLocation(new ResourceLocation(registryNameResourceNamespace, registryNameResourcePath), "normal"));
}

In your ModelRegistryEvent. https://mcforge.readthedocs.io/en/latest/concepts/registries/#registering-things like this

//inside your event subscriber
(@Mod.EventBusSubscriber(value=Side.CLIENT))
public class ClientEventSubscriber {
	@SideOnly(Side.CLIENT)
	@SubscribeEvent
	public (static) void onRegisterModelsEvent(final ModelRegistryEvent event) {
		//model registration code goes here
	}
}

 

Edited by Cadiboo

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

54 minutes ago, Jack4096 said:

Could you guys just help with setting proper names for each plank in the enum? For all 4 plank types? For Magic, Maple, Redwood, and Yew?

 

On 10/11/2018 at 9:34 PM, Animefan8888 said:

You will need a custom ItemBlock implementation which I assume you have because your block has metadata. There is where you will override the method I said above.

 

On 10/11/2018 at 9:24 PM, Animefan8888 said:

Override getUnlocalizedName(ItemStack) and base it off of the metadata. Then you will have to put multiple entries into your lang file.

I did already.

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

Can I reccomend not using metadata? In 1.13 the flattening is happening and all the different types of wood are moving to different blocks (this doesn't mean different classes). 

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

30 minutes ago, Cadiboo said:

Can I reccomend not using metadata?

Of course.

31 minutes ago, Cadiboo said:

In 1.13 the flattening is happening and all the different types of wood are moving to different blocks (this doesn't mean different classes). 

But going by this logic he shouldn't be developing at all, because 1.13 isnt out yet. Because there would be no point in releasing the mod for 1.12 if it uses too many block ids.

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

13 minutes ago, Animefan8888 said:

Of course.

But going by this logic he shouldn't be developing at all, because 1.13 isnt out yet. Because there would be no point in releasing the mod for 1.12 if it uses too many block ids.

I think using 4 ids with an axis variant is better that using 1 id and squeezing 4 variants and the axis into 1 block. To be fair you only need 2 bits for the variant and 1 and a half (2) bits for the axis if your being efficient, still thats your 4 bits used up with space for only 1 more axis/variant.

Edited by Cadiboo

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

2 minutes ago, Cadiboo said:

I think using 4 ids with an axis variant is better that using 1 id and squeezing 4 variants and the axis into 1 block. To be fair you only need 2 bits for the variant and 1 and a half (2) bits for the axis if your being efficient, still thats your 4 bits used up with space for only 1 more axis/variant.

 

On 10/11/2018 at 9:07 PM, Jack4096 said:

planks

 

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

Well, that does change the context a bit.

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

34 minutes ago, Cadiboo said:

Well, that does change the context a bit.

Also, you technically only have to use 12 of the sixteen values you have with metadata to store 4 logs. Therefore you could store 5 logs into one block.

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

1 hour ago, Cadiboo said:

with space for only 1 more axis/variant

 

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

2 hours ago, Cadiboo said:

only need 2 bits for the variant and 1 and a half (2) bits

The thing is, you cant break the bits up like this. Its non sensical. You have four bits(16 values) if you split the bits up like you said then you have 2 bits or four values to store the variant(oak, birch, etc) and then the other 2 bits for the axis where you only use 3 values out of four. Of which you couldn't use as another variant because then you would lose your axis. So instead it is better to express it in numerical values. Whether it's in base 10, 16, or 2.

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

3 hours ago, Cadiboo said:

Can I reccomend not using metadata? In 1.13 the flattening is happening and all the different types of wood are moving to different blocks (this doesn't mean different classes). 

In that case, I will most likely just wait for 1.13 then.

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

    • Tayo4D : Bandar Online Togel Dan Slot Terbesar Di Indonesia     Pemain taruhan Tayo4D yang berkualitas memerlukan platform yang aman, terpercaya, dan mudah digunakan. Dalam era teknologi ini, banyak situs online yang menawarkan layanan taruhan togel 4D, tetapi memilih yang tepat menjadi tuntas. Berikut adalah cara untuk membuat artikel yang membahas tentang situs online terpercaya untuk permainan taruhan togel 4D.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa OLXTOTO telah menetapkan standar baru dalam dunia perjudian dengan menjadi platform terbesar untuk pengalaman gaming yang penuh kemenangan dan kegacoran, sepanjang masa. Dengan fokus yang kuat pada menyediakan permainan yang menghadirkan kesenangan tanpa batas dan peluang kemenangan besar, OLXTOTO telah menjadi pilihan utama bagi para pencinta judi berani di Indonesia. Maxwin: Mengejar Kemenangan Terbesar Maxwin bukan sekadar kata-kata kosong di OLXTOTO. Ini adalah konsep yang ditanamkan dalam setiap aspek permainan yang mereka tawarkan. Dari permainan slot yang menghadirkan jackpot besar hingga berbagai opsi permainan togel dengan hadiah fantastis, para pemain dapat memperoleh peluang nyata untuk mencapai kemenangan terbesar dalam setiap taruhan yang mereka lakukan. OLXTOTO tidak hanya menawarkan kesempatan untuk menang, tetapi juga menjadi wadah bagi para pemain untuk meraih impian mereka dalam perjudian yang berani. Gacor: Keberuntungan yang Tak Tertandingi Keberuntungan seringkali menjadi faktor penting dalam perjudian, dan OLXTOTO memahami betul akan hal ini. Dengan berbagai strategi dan analisis yang disediakan, pemain dapat menemukan peluang gacor yang tidak tertandingi dalam setiap taruhan. Dari hasil togel yang tepat hingga putaran slot yang menguntungkan, OLXTOTO memastikan bahwa setiap taruhan memiliki potensi untuk menjadi momen yang mengubah hidup. Inovasi dan Kualitas Tanpa Batas Tidak puas dengan prestasi masa lalu, OLXTOTO terus berinovasi untuk memberikan pengalaman gaming terbaik kepada para pengguna. Dengan menggabungkan teknologi terbaru dengan desain yang ramah pengguna, platform ini menyajikan antarmuka yang mudah digunakan tanpa mengorbankan kualitas. Setiap pembaruan dan peningkatan dilakukan dengan tujuan tunggal: memberikan pengalaman gaming yang tanpa kompromi kepada setiap pengguna. Komitmen Terhadap Kepuasan Pelanggan Di balik kesuksesan OLXTOTO adalah komitmen mereka terhadap kepuasan pelanggan. Tim dukungan pelanggan yang profesional siap membantu para pemain dalam setiap langkah perjalanan gaming mereka. Dari pertanyaan teknis hingga bantuan dengan transaksi keuangan, OLXTOTO selalu siap memberikan pelayanan terbaik kepada para pengguna mereka. Penutup: Mengukir Sejarah dalam Dunia Perjudian Daring OLXTOTO bukan sekadar platform perjudian berani biasa. Ini adalah ikon dalam dunia perjudian daring Indonesia, sebuah destinasi yang menyatukan kemenangan dan keberuntungan dalam satu tempat yang mengasyikkan. Dengan komitmen mereka terhadap kualitas, inovasi, dan kepuasan pelanggan, OLXTOTO terus mengukir sejarah dalam perjudian dunia berani, menjadi nama yang tak terpisahkan dari pengalaman gaming terbaik. Bersiaplah untuk mengalami sensasi kemenangan terbesar dan keberuntungan tak terduga di OLXTOTO - platform maxwin dan gacor terbesar sepanjang masa.
    • OLXTOTO - Bandar Togel Online Dan Slot Terbesar Di Indonesia OLXTOTO telah lama dikenal sebagai salah satu bandar online terkemuka di Indonesia, terutama dalam pasar togel dan slot. Dengan reputasi yang solid dan pengalaman bertahun-tahun, OLXTOTO menawarkan platform yang aman dan andal bagi para penggemar perjudian daring. DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI Beragam Permainan Togel Sebagai bandar online terbesar di Indonesia, OLXTOTO menawarkan berbagai macam permainan togel. Mulai dari togel Singapura, togel Hongkong, hingga togel Sidney, pemain memiliki banyak pilihan untuk mencoba keberuntungan mereka. Dengan sistem yang transparan dan hasil yang adil, OLXTOTO memastikan bahwa setiap taruhan diproses dengan cepat dan tanpa keadaan. Slot Online Berkualitas Selain togel, OLXTOTO juga menawarkan berbagai permainan slot online yang menarik. Dari slot klasik hingga slot video modern, pemain dapat menemukan berbagai opsi permainan yang sesuai dengan preferensi mereka. Dengan grafis yang memukau dan fitur bonus yang menggiurkan, pengalaman bermain slot di OLXTOTO tidak akan pernah membosankan. Keamanan dan Kepuasan Pelanggan Terjamin Keamanan dan kepuasan pelanggan merupakan prioritas utama di OLXTOTO. Mereka menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan para pemain. Tim dukungan pelanggan yang ramah dan responsif siap membantu pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Promosi dan Bonus Menarik OLXTOTO sering menawarkan promosi dan bonus menarik kepada para pemainnya. Mulai dari bonus selamat datang hingga bonus deposit, pemain memiliki kesempatan untuk meningkatkan kemenangan mereka dengan memanfaatkan berbagai penawaran yang tersedia. Penutup Dengan reputasi yang solid, beragam permainan berkualitas, dan komitmen terhadap keamanan dan kepuasan pelanggan, OLXTOTO tetap menjadi salah satu pilihan utama bagi para pecinta judi online di Indonesia. Jika Anda mencari pengalaman berjudi yang menyenangkan dan terpercaya, OLXTOTO layak dipertimbangkan.
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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