Jump to content

[1.15.2] Can I register a Block to an existing TileEntity?


deerangle

Recommended Posts

13 minutes ago, deerangle said:

I want to create a custom sign block. Ideally, I could just add my Sign blocks to the existing TileEntityType SIGN. Is that possible, or do I have to make my own TileEntity?

Each TileEntityType has a Set<Block> which are the valid Blocks for that TileEntityType. So you will need your own TileEntity. However you can just extend SignTileEntity and override the constructor that takes no Parameters and pass your own TileEntityType into the super constructor.

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 minute ago, Animefan8888 said:

However you can just extend SignTileEntity and override the constructor that takes no Parameters and pass your own TileEntityType into the super constructor.

I'm a little confused on how to do this, as the signature of the constructor for SignTileEntity is this:

public SignTileEntity() {
    super(TileEntityType.SIGN);
}

So I can't pass my own TileEntityType to it.

Link to comment
Share on other sites

6 minutes ago, deerangle said:

So I can't pass my own TileEntityType to it.

 

12 minutes ago, Animefan8888 said:

So you will need your own TileEntity. However you can just extend SignTileEntity and override the constructor that takes no Parameters and pass your own TileEntityType into the super constructor.

 

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

public class BeechSignTileEntity extends SignTileEntity {

    public BeechSignTileEntity() {
        super(Registry.SIGN_TE); // doesn't work
    }

}

I made my own TileEntity. I extended SignTileEntity. However, I can't pass my TileEntityType to the superconstructor because the superconstructor doesn't accept a TileEntityType.

Link to comment
Share on other sites

1 minute ago, diesieben07 said:

That is not how constructors work.

This is true. Don't I look like a fool.

 

Just now, deerangle said:

I made my own TileEntity. I extended SignTileEntity.

Instead override TileEntity::getType and return your own type.

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

2 minutes ago, diesieben07 said:

This breaks certain mods, because the type will be invalid during AttachCapabilitiesEvent. Do not do this.

Why would the type be invalid during AttachCapabilitiesEvent?

 

AttachCapabilitiiesEvent<TileEntity> gives you the TileEntity object not the TileEntityType and the event is fired when the TileEntity is constructed aka when the block is placed. By then the Type has been registered and the TileEntity::type field is private and there is a TileEntity::getType so no need to use Reflection to access it.

 

I fail to miss how this breaks certain mods.

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

AttachCapabilitiesEvent is fired from the TileEntity constructor. Your own constructor has not ran yet, as such anything in your tile entity class (including a potential TileEntityType field) is not initialized.

I said to override the getType method I assume

public TileEntityType<?> getType() {
  return MyTileEntityTypes.MY_SIGN_TYPE;
}

Would work just fine.

  • Like 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

  • 3 months later...

Can you post your solution? I'm lost on how I'm supposed to pass my custom SignTileEntity to the  SignItem class. I have my custom SignTileEntity extend Minecraft's SignTileEntity and override the TileEntity::GetType so that it returns my custom SignTileEntityType. But my custom SignTileEntity::GetType is never called. When I place my custom SignItem into the world it calls world.getTileEntity which somehow returns Minecraft's SignTileEntity (I tried following it in the debugger and it wouldn't reveal where it gets the tile entity from).

Link to comment
Share on other sites

31 minutes ago, killerjdog51 said:

But my custom SignTileEntity::GetType is never called.

Of course not, because the vanilla sign item places the vanilla sign block, and the vanilla sign block creates the vanilla sign tile entity.

GetType only gets called for the game to determine how to serialize and deserialize the TE's data.

Edited by Draco18s

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

18 hours ago, Draco18s said:

Of course not, because the vanilla sign item places the vanilla sign block, and the vanilla sign block creates the vanilla sign tile entity.

GetType only gets called for the game to determine how to serialize and deserialize the TE's data.

Thank you, I got it working and I really appreciate your help. I can't believe how stupid I was though, I checked the sign blocks to see if there was anything related to tile entities, didn't even notice that they were extending an abstract sign class. This whole time I was looking for how the Item class called the tile entity.

 

The last thing I need then is texturing my sign blocks, Now that I can actually place it in the world I see that they all have the oak texture instead of my custom sign textures (placed in assets/Mod_ID/textures/entity/signs folder)

 

Edit: figured out the texture thing, just had to make a TileEntityRenderer class. 

Edited by killerjdog51
Solved
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.