Jump to content

How do i make a block colorable exactly like the leather-armour?


Drachenbauer

Recommended Posts

Hello

i want to make some of my custom blocks colorable exactly like the leather-armour.

 

The basic color should be white and all other colors should have the additional info "dyed" under the block´s name.

it should be able to craft the white ones with a basic-recipe i made and the other colors with a dye added to the receipe or a finished one and a dye in a receipe.

A colored one with a dye in a receipe should change the color a bit, just like leather armour, too

Also it should be possible, to get all colours, wich can be created in a graphic-program, by typing a chat-command, wich includes the name of the block and a number for a color.

 

I already have a white extra-texture for the color changing parts of my blocks.

 

how do i code this?

Link to comment
Share on other sites

It'll depends on how you want to achieve this.

You could create 16 blocks, each matching a vanilla dye color.

 

However, if you want to register all color variants as one block, you can store the color in the block's property, and just specify the color in the variants in the blockstates json.

 

Other alternatives exist, such as how BonsaiTrees handles its coloring: https://github.com/thraaawn/BonsaiTrees/blob/master/src/main/java/org/dave/bonsaitrees/block/BlockBonsaiPot.java

 

As for the crafting, you might have to create an IRecipe implementation.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

how do i store the colors in the blockstates json?

 

And i want to be able to get all 16777216 color shades, a pc can make, by using an ingame-chat-commant with a color-vaule.

 

i added implements IRecipe to one of my block classes and that added some methods there.

How do i use them fo my coloring thing?

Edited by Drachenbauer
Link to comment
Share on other sites

20 hours ago, Drachenbauer said:

how do i store the colors in the blockstates json?

If you want 16777216 color variations you will need a TileEntity + FastTESR/Custom baked model an IBlockColor implementation

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

IBlockColor won't help you store any additional data. You'd still need a TE.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

6 minutes ago, Drachenbauer said:

TE

Tile Entity.

 

6 minutes ago, Drachenbauer said:

How do i implament IRecipe and IBlockColor in the same class?

We've never told you to do that. They are separate.

 

There are plenty of examples out there on tile entities.

If you are looking for how to use a TESR. Here is a tutorial on that: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe21_tileentityspecialrenderer.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

i meaned having connections to boch interfaces in my block-class.

and i found out, i just have to separate their names with a ",", where i implement them:

public class BalloonBlock extends Block implements IRecipe, IBlockColor

 

 

I looked into the ItemArmorDyeable class of the basic Minecraft-stuff and found something about colors there, but i don´t know how to reproduce that in a block-class

 

And where are the recipe-jsons for dying a leather-armour?

There must be something special in the result-area of them, that i need to reproduce in my own dying recipes for my blocks.

 

And how do i create a tile-entity?

Edited by Drachenbauer
Link to comment
Share on other sites

40 minutes ago, Drachenbauer said:

And how do i create a tile-entity?

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

 

40 minutes ago, Drachenbauer said:

I looked into the ItemArmorDyeable class of the basic Minecraft-stuff and found something about colors there, but i don´t know how to reproduce that in a block-class

The effect you are trying to achieve is not remotely similar to the leather armor of vanilla minecraft. I don't see why you are looking in there.

 

40 minutes ago, Drachenbauer said:

and i found out, i just have to separate their names with a ",", where i implement them:


public class BalloonBlock extends Block implements IRecipe, IBlockColor

... wtf?

Please make sure you understand what you are doing before trying to implement your ideas into your code.

Seeing how you want to create 16^6 different colors (and how lost you currently are), I suggest you to ditch the entire "IBlockColor" idea and do everything with tile entities and TESRs instead. You can implement it like how Cadiboo suggested:

On 3/3/2019 at 6:12 PM, Cadiboo said:

If you want 16777216 color variations you will need a TileEntity + FastTESR/Custom baked model

 

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

1 minute ago, Drachenbauer said:

I think, for me the best workflow is to find working samples of my ideas and reproduce them in my mod.

 

Has anyone already got a block with 16777216 colors to work?

1. It is unlikely that someone has created exactly what you are trying to create before. You really should try making it yourself.

2. Judging by your previous posts (which strongly indicate that you have little idea on what is going on), I suspect that you want to copy/paste working code from others. This is highly discouraged on this forum. You need to learn how to create tile entities and TESRs, and work toward your goal yourself. It will not benefit you to just copy code from others.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

1 hour ago, Drachenbauer said:

But i don´t know how the code should look like, if i didn´t see a workung sample before.

Before doing something on this scale, I would suggest to start with making some simpler things..

 

Try to just create a block with a TileEntity. And instead of doing everything at the same time, just log something in your TileEntity#tick. If that works move on to the next thing, like implementing colour data.

 

You can copy/paste all you want, but you'll never get it to work by doing it the way your handling it right now. Some part of the whole thing won't work and you wouldn't even have clue where you need to look for debugging.

 

If you can only learn from examples, then I suggest to look at the link DavidM posted earlier. But try to understand the code instead of just copy/pasting everything

Link to comment
Share on other sites

1 hour ago, Drachenbauer said:

And i also think the same result needs the same piece of code, no matter, who want to have this effect in a mod

And by the way, just copying from someone else without permission is just blately a violation of copyright and disrespectful.

Link to comment
Share on other sites

24 minutes ago, Drachenbauer said:

How do i add a tile entity to a block?

Make a separate class called something like TileEntityColouredBlock that extends TileEntity.

 

Then in your ColouredBlock class that extends from Block, override Block#hasTileEntity and return true.

 

Also override Block#createTileEntity and return a new instance of your TileEntityColouredBlock class.

 

Don't forget to register your TileEntity.

Link to comment
Share on other sites

now i have this:

	@Override
	public boolean hasTileEntity()
	{
		return true;
	}
	
	@Override
	public TileEntity createTileEntity(IBlockState state, IBlockReader world)
	{
		return new TileEntityBlockColors(null)
		{
			
		};
	}

TileEntityBlockColors is the name of my TileEntity-class

should i replace the "null" behind it with something else?

Link to comment
Share on other sites

Yes. But I won't tell you what, because you need to learn how to figure stuff out for yourself. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You may/may not have already read this, but it’s useful - https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a.

You need to fix your error with not being able to see the minecraft library as an attached source before you continue Modding. Everything that mods do is based off vanilla.

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, Blue_Atlas said:

I believe a version of what you are trying to do is this mod, right?

No. His approach is with tile entities, as well as making all 16^6 colors, which is completely different from mod in the link.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

4 minutes ago, Drachenbauer said:

how do i learn that?

You know... probably... learn from the tutorial I've given you at least 3 times?

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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




×
×
  • Create New...

Important Information

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