Jump to content

Recommended Posts

Posted

If you're following my example, the COLOR property is stored in the metadata and as such is already set when Block#getActualState is called. The FACING property is stored in the TileEntity and is the only property that needs to be set in your override of Block#getActualState.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Posted
  On 12/23/2018 at 1:51 AM, Choonster said:

and is the only property that needs to be set in your override of Block#getActualState.

Expand  

That's exactly what I thought. I'm assuming my problem is elsewhere then? I wasn't sure if maybe it's in onBlockPlaced or something.

Posted
  On 12/23/2018 at 7:11 AM, Siqhter said:

That's exactly what I thought. I'm assuming my problem is elsewhere then? I wasn't sure if maybe it's in onBlockPlaced or something.

Expand  

 

What exactly is your current issue? Please post your latest code (or a link to your repository). If it's a model issue, please post your blockstates/model files and your debug.log.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

(Note that you can do it the other way too: store the facing in the metadata and the color in the 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.

Posted
  On 12/23/2018 at 7:55 AM, Choonster said:

 

What exactly is your current issue?

Expand  

On placing the block, it should be 1 of 16 different dye colors. Also the items in the creative menu should each be their own dye color.

 

It's not a model issue, because they render when placed, just not with the correct color (they only render in white, which is the first color in the blockstates colors variants). Also the blocks work fine when applied with dyes (the blocks change to their respective color), so it's probably something in a method that I'm not adding. Below are my Block and TileEntity classes, as well as the blockstate file.

  Reveal hidden contents
  Reveal hidden contents
  Reveal hidden contents

 

Posted
  On 12/26/2018 at 5:09 PM, Siqhter said:

On placing the block, it should be 1 of 16 different dye colors. Also the items in the creative menu should each be their own dye color.

 

It's not a model issue, because they render when placed, just not with the correct color (they only render in white, which is the first color in the blockstates colors variants). Also the blocks work fine when applied with dyes (the blocks change to their respective color), so it's probably something in a method that I'm not adding. Below are my Block and TileEntity classes, as well as the blockstate file.

Expand  

 

This sounds like an issue with the ItemBlock and/or the model registration for the ItemBlock. Please post the code where you instantiate and register the ItemBlock and the code where you register the models for the ItemBlock(or create a repository so that we can see all of your code).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 12/26/2018 at 5:16 PM, Choonster said:

(or create a repository so that we can see all of your code).

Expand  

Yeah sorry I've been meaning to do that. Something got messed up with an old mod's repository and I've been trying to fix it. Anyway this is how I register the block and itemblock, but I feel like that would only be an issue with it registering the texture in the inventory. And I should add, it does register the counter model block fine (on placed, and in the inventory), just not the subitems I create with the getSubItems method in my BlockCounter.java. So I'm pretty sure they're registered correctly.

 

BlockInit.java

  Reveal hidden contents

RegistryHandler.java

  Reveal hidden contents

 

Posted

ItemBlock itself isn't suitable for blocks with variants, you need to use a subclass that overrides Item#getMetadata(int) to convert the item metadata to block metadata and calls Item#setHasSubtypes to mark the item as having variants/subtypes. ItemCloth does these and also overrides Item#getTranslationKey(ItemStack) to add the stack's colour as a suffix to the translation key (unlocalised name) so that each colour can have its own translation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 12/26/2018 at 6:02 PM, Choonster said:

ItemBlock itself isn't suitable for blocks with variants

Expand  

Ah, I didn't realize that. So I would need a separate class that sets hasSubtypes to true, overrides getMetadata, and a getUnlocalizedName method? Pretty much everything in the ItemCloth class?

Posted
  On 12/26/2018 at 6:26 PM, Siqhter said:

Ah, I didn't realize that. So I would need a separate class that sets hasSubtypes to true, overrides getMetadata, and a getUnlocalizedName method? Pretty much everything in the ItemCloth class?

Expand  

 

Yes, or just use ItemCloth.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Got that working. I feel stupid, I had created a class that I planned to use for any block with subtypes, just forgot to register it in the BlockInit class as a new ItemBlock. It was the same type as ItemCloth that you just told me about. The textures in the inventory are still not registering, should I do the same with with a getSubItems subclass? I'm not sure how similar it is toSubBlocks. Thanks.

Posted

Nevermind I actually just got that working as well. I created a SubItems interface with a ResourceLocation method, and registered items that are instances of SubItems in my RegistrationHandler under Items. Thanks for your help on this.

Posted (edited)

Sorry I do have one other question. Using harvestBlock how would I get it to drop the correct color block? Right now it just drops nothing.

Edited by Siqhter
Posted (edited)

What does the code look like right now?

nvm...

Edited by Animus_Surge

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted

You could also have a different block for each colour, the way shulker boxes do

About Me

  Reveal hidden contents

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)

Posted

Well I have heard a couple people on this post say something about switching facing and color properties so that I can store color in the TE. Right now color is in the metadata, but if I instead put it in the TE, than how exactly would I call it in the block class instead of using getMetaFromState and getStateFromMeta?

Posted (edited)

You would use the block pos you would get to get the tile entity at that pos, check if it’s yours & get the data from it.

However, with the ID limit expansion in 1.13 I would just use seperate blocks (not seperate classes) for each colour the way shulker boxes do it (with an enum). Meta is great for facing, but you shouldnt be using a TE for something like this as you can avoid all the overhead of it by just using multiple blocks

Edited by Cadiboo

About Me

  Reveal hidden contents

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)

Posted (edited)
  On 12/27/2018 at 5:45 AM, Cadiboo said:

You would use the block pos you would get to get the tile entity at that pos, check if it’s yours & get the data from it.

Expand  

Would this go in getActualState?

Edited by Siqhter
Posted

Yes

About Me

  Reveal hidden contents

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)

Posted

Ok, thanks. And just to check I defined my color in the TE as

  Reveal hidden contents

 

It doesn't need to be an integer or is this alright?

 

Posted
  On 12/27/2018 at 5:45 AM, Cadiboo said:

However, with the ID limit expansion in 1.13 I would just use seperate blocks (not seperate classes) for each colour the way shulker boxes do it (with an enum). Meta is great for facing, but you shouldnt be using a TE for something like this as you can avoid all the overhead of it by just using multiple blocks

Expand  

Ok, I will look into it. For now I am curious, just because I'm trying to switch color and facing so I store color in the TE. (I will end up changing it to what has been recommended). But in getActualState I'm trying to call the TE and get the data from it, but I'm not quite sure how.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    super.getActualState(state, worldIn, pos);
    TileEntityCounter tileEntity = (TileEntityCounter) worldIn.getTileEntity(pos);
    EnumDyeColor color = tileEntity.getColor();

    return state.withProperty(COLOR, color);
}
Posted

Quick update, sorry but I'm still stuck on this. My tileentity for color is:

  Reveal hidden contents

and getActualState:

  Reveal hidden contents

but this only returns RED, obviously, but I don't understand how to get the data from the block.

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.