Jump to content

Recommended Posts

Posted

Good evening,

I'm modding a custom sign which is translucent and smaller than the Vanilla's one.

 

  Reveal hidden contents


I've looked for Vanilla classes to mimic the existing BlockSign and its children BlockStandingSign and BlockWallSign. I've also made a custom TileEntitySpecialRenderer and registered it.

(BlockRPSign.java)

  Reveal hidden contents

 

(BlockStandingRPSign.java)

  Reveal hidden contents

 

(BlockWallRPSign.java)

  Reveal hidden contents

 

(ItemRPSign.java)

  Reveal hidden contents

 

(TileEntityRPSignRenderer.java)

  Reveal hidden contents

 

(MyModBlocks.java)

  Reveal hidden contents

 

(MyModItems.java)

  Reveal hidden contents

 

(MyModTileEntities.java)

  Reveal hidden contents


(As you may see, I'm using @jabelar mod structure from the GitHub repo here)

I'm getting a net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException for my standing_rp_sign blockstate with rotation variants. I haven't created any blockstate file for both standing and wall signs since there is an existing TESR which handles the rendering. I've tried to look for a model loading from Vanilla's sign but I didn't find anything. My guess would be to indicate Forge to avoid handling models for those blocks but i don't know how to do that.

Also, since there is no blockstate and no model attached to the blocks, there are random particles emitted when breaking the block. Vanilla sign has woods particles but I can't see any code or model file that indicates the texture to use for particles from Vanilla.


Finally, as you can see in the TESR I'm trying to check the block type from the tileentity (this is done in Vanilla using Block#getBlockType which returns a Block). Is there a better way to do it ?

Thank you for your help.

 

Squirrel ! Squirrel ! Squirrel !

Posted
  On 5/14/2019 at 3:57 PM, Major Squirrel said:

I haven't created any blockstate file for both standing and wall signs

Expand  

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

I'm getting a net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

Expand  

Well, what did you expect? If you haven't created a blockstates file for your block then the game is gonna complain that there isn't one.

Minecraft itself marks the sign as having a "built-in" model and doesn't even attempt to load it's model as a result.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

My guess would be to indicate Forge to avoid handling models for those blocks but i don't know how to do that.

Expand  

Why not just create an "empty" blockstates file? That would also allow you to define the breaking particle.

You could also use a custom implementation of a IStateMapper.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

Also, since there is no blockstate and no model attached to the blocks, there are random particles emitted when breaking the block. Vanilla sign has woods particles but I can't see any code or model file that indicates the texture to use for particles from Vanilla.

 

Expand  

Unfortuntely vanilla is pretty bad when it comes to handling exceptional cases. The particle textures for the sign are hardcoded in BlockModelShapes#getTexture. If you want a particle texture yourself then either use an "empty" model or a custom IBakedModel implementation.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

Finally, as you can see in the TESR I'm trying to check the block type from the tileentity (this is done in Vanilla using Block#getBlockType which returns a Block). Is there a better way to do it ?

Expand  

That's fine.

 

Your code is an insane mess though:

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

return (null);

Expand  

Why re you doing (this)? There is no reason to write your code (like that) or {like that}. Don't do that, it is impossible to read and is absolutely not necessarry.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

protected    BlockRPSign()

Expand  

Why do you have a \t symbol between your modifiers and the names? That makes no sense and is difficult to read. Where did you get that coding style anyway? I have never seen anybody space their code like that.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

extends BlockContainer

Expand  

Don't. There is no need to extend BlockContainer, just extend Block and override Block#createTileEntity and Block#hasTileEntity.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

if (!worldIn.isRemote) { Minecraft.getMinecraft().displayGuiScreen(new GuiRolePlayScreen());

Expand  

This 

   1) Makes no sense

   2) Is reaching across logical sides

   3) Will crash on a server

 

Don't ever do that. Use forge's method(EntityPlayer#openGui) to opeen GUI's. 

Don't reference client-only classes in common code, this will crash the server.

Don't reach across logical sides, that WILL break everything possible. And will crash the server.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

Integer.valueOf(0)

Expand  
  On 5/14/2019 at 3:57 PM, Major Squirrel said:

Integer.valueOf(meta)

Expand  

...Why? It will just return you the said 0. There is no reason to do this. Fix all of these in your code, there are a ton.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

Integer.valueOf(rot.rotate(((Integer)state.getValue(ROTATION)).intValue(), 16)))

Expand  

This is the prime reason why. Do you yourselves understand what's going on here? All of these casts, valueof and stuff are making it impossible to see what's actually going on.

It also wastes CPU cycles and RAM space doing pointless boxing/unboxing operations.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

new IProperty[] {ROTATION}

Expand  

There is no need to explicitly create a new array here. The input variable is a params one already(... modifier).

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

@SubscribeEvent @SideOnly(Side.CLIENT)

Expand  

Don't abuse SideOnly. Have dedicated client-side only event handlers.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

if ("standing_rp_sign".equals(block.getUnlocalizedName().substring(5))) {

Expand  

Dear lord, why? Just compare the block you have to the constant you have in the MyModBlocks. Don't ever do stuff like this.

 

  On 5/14/2019 at 3:57 PM, Major Squirrel said:

int k = te.getBlockMetadata();

Expand  

Don't do that, metadata is gone in 1.13 anyway. Just use the blockstate properties.

 

I am not going to complain about magic numbers in your TESR since you just copied the vanilla sign TESR, but don't use magic numbers in general.

  • Thanks 1
Posted

Good evening,

Thank you @V0idWa1k3r for your answer.
 

  On 5/14/2019 at 4:25 PM, V0idWa1k3r said:

Minecraft itself marks the sign as having a "built-in" model and doesn't even attempt to load it's model as a result.

Expand  

 

I couldn't find it in Vanilla code earlier. Is it in the BlockModelShapes#registerAllBlocks method ?


I guess I will have to create an "empty" blockstates file if I want to override emitted particles anyway.
 

  On 5/14/2019 at 4:25 PM, V0idWa1k3r said:

Use forge's method(EntityPlayer#openGui) to opeen GUI's.

Expand  


Isn't this method supposed to be used when there is a Container attached to the TileEntity ? My TileEntity has no Container, it just has some data stored (TextComponents) in it.

 

For what is left, I simply copied/pasted Vanilla code. Now I've fixed the useless casts, boxing/unboxing, arrays, etc... Thank you for that.

Squirrel ! Squirrel ! Squirrel !

Posted
  On 5/14/2019 at 9:25 PM, Major Squirrel said:

Isn't this method supposed to be used when there is a Container attached to the TileEntity ? My TileEntity has no Container, it just has some data stored (TextComponents) in it.

Expand  

In that case use a proxy. You can't reference client-only classes(Minecraft, Gui) in common code anyways

Posted

I've added "empty" blockstate files and model files like so :

(blockstates/standing_rp_sign.json)

  Reveal hidden contents

 

(blockstates/wall_rp_sign.json)

  Reveal hidden contents

 

(models/block/standing_rp_sign.json and models/block/wall_rp_sign.json)

  Reveal hidden contents

 

It does fix all MissingVariant exceptions as well as emitted particles when signs are destroyed.

 

However, when changing my BlockRPSign from BlockContainer to Block with Block#hasTileEntity and Block#createTileEntity overriden, the render() method from the TESR is not called anymore. Instead, I've made my class extend to Block, implementing ITileEntityProvider. It works now.

 

  On 5/14/2019 at 10:15 PM, V0idWa1k3r said:

In that case use a proxy. You can't reference client-only classes(Minecraft, Gui) in common code anyways

Expand  


What do you mean by proxy ? Sending a packet to the server and the server opens a player GUI ?
 

Squirrel ! Squirrel ! Squirrel !

Posted
  On 5/14/2019 at 10:56 PM, Major Squirrel said:

Instead, I've made my class extend to Block, implementing ITileEntityProvider. It works now.

Expand  

Don't do that either. That class is legacy code that won't work properly.

Show your code(without extending ITileEntityProvider)

 

  On 5/14/2019 at 10:56 PM, Major Squirrel said:

What do you mean by proxy ? Sending a packet to the server and the server opens a player GUI ?

Expand  

https://mcforge.readthedocs.io/en/latest/concepts/sides/#sidedproxy

Posted (edited)
  On 5/14/2019 at 10:59 PM, V0idWa1k3r said:

Show your code(without extending ITileEntityProvider)

Expand  

 

(BlockRPSign.java)

  Reveal hidden contents


It works with the code above, I was overriding the wrong hasTileEntity method (the one without any parameter) , thank you.
 

  On 5/14/2019 at 10:59 PM, V0idWa1k3r said:
Expand  

 

Could you please explain a little more about why you indicate me to use a proxy ? I know this part of code is executed on the server thread and I'm calling clientside code with Minecraft#displayGuiScreen, but I don't find a way to open a GUI remotely of a TileEntity without any Container.

EDIT: is it as simple as using a GuiHandler and returning null in getServerGuiElement ...?

Edited by Major Squirrel

Squirrel ! Squirrel ! Squirrel !

Posted

If you need to open a containerless GUI from the server side, you'll need to send a custom packet to the client.  But if you're doing this from onBlockActivated(), is there a reason you can't just open the GUI if called client-side (maybe you want to do some server-side validation first, I haven't examined your code too closely) ?

Posted
  On 5/15/2019 at 11:16 AM, desht said:

If you need to open a containerless GUI from the server side, you'll need to send a custom packet to the client.  But if you're doing this from onBlockActivated(), is there a reason you can't just open the GUI if called client-side (maybe you want to do some server-side validation first, I haven't examined your code too closely) ?

Expand  

 

The purpose would be to display data stored in the TileEntity, inside a GUI. Then, I guess I would call the server to retrieve the data and to pass it to the GUI ?

Squirrel ! Squirrel ! Squirrel !

Posted
  On 5/15/2019 at 1:28 PM, Major Squirrel said:

 

The purpose would be to display data stored in the TileEntity, inside a GUI. Then, I guess I would call the server to retrieve the data and to pass it to the GUI ?

Expand  

If the data is only needed client-side for GUI display purposes (as opposed to block rendering purposes), you could just have that custom packet sync the necessary data and trigger the GUI opening client-side.  If you do it this, you might also need a way to update any already-open GUIs if any data changes server-side (that's dependent on how you intend your GUI to work).

If the data is also needed for block rendering, it needs to be sync'd in some other way whenever it changes server-side.  Either via vanilla-style TE syncing (getUpdatePacket() / onDataPacket()) or - preferably - via a custom packet.

Posted (edited)
  On 5/15/2019 at 1:47 PM, desht said:

If the data is only needed client-side for GUI display purposes (as opposed to block rendering purposes), you could just have that custom packet sync the necessary data and trigger the GUI opening client-side.

Expand  


Thank you @desht, I will give a try.

Also, I'm trying to avoid using TESR by only using Forge Blockstate format. For the wall sign it is pretty easy as Vanilla blockstate increments rotation every 90 degrees, but for the standing sign it is a little bit more complicated as it has 16 possible rotations.

I've read this post where it is advised to use the Forge Blockstate V1 specs available here but I guess I have difficulties in understanding the specs.

Here is what I got :

 

  Reveal hidden contents

 

The original model for the block (the uniform face is purposely complete beige so I could see where it faces) :

 

  Reveal hidden contents

 

(blockstates/standing_rp_sign.json)

  Reveal hidden contents

 

(block/standing_rp_sign.json)

  Reveal hidden contents

 

I don't really understand what is going on here tbh.

Edited by Major Squirrel

Squirrel ! Squirrel ! Squirrel !

Posted
  On 5/15/2019 at 11:50 PM, V0idWa1k3r said:

You'd need to use a TESR anyway to render the text, so...

Expand  

 

I don't want to render any text on the sign, that is why I would like to avoid using TESR.
 

  On 5/15/2019 at 11:50 PM, V0idWa1k3r said:

Rotation in the blockstates file can only be done by 90 degrees(0, 90, 180, 270).

Expand  

 

According to @diesieben07 in the link I've posted above, the TRSRTransformation rotation can achieve 22.5 degrees increments, that's why I don't really understand.

Squirrel ! Squirrel ! Squirrel !

Posted

TRSRTransformationa can achieve any rotation

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
  On 5/16/2019 at 7:26 AM, Cadiboo said:

TRSRTransformationa can achieve any rotation

Expand  

Yes, but look at my comment:

  On 5/15/2019 at 11:50 PM, V0idWa1k3r said:

Rotation in the blockstates file can only be done by 90 degrees(0, 90, 180, 270).

Expand  

https://minecraft.gamepedia.com/Model#Block_states

 

If you want to acheive a 22.5 increment then you would need to either use a custom IBakedModel or i think you can use a transform key

https://gist.github.com/RainWarrior/0618131f51b8d37b80a6#file-forge-blockstate-v1-specs-L58

Posted (edited)
  On 5/16/2019 at 1:53 PM, V0idWa1k3r said:

Yes, but look at my comment:

  On 5/15/2019 at 11:50 PM, V0idWa1k3r said:

Rotation in the blockstates file can only be done by 90 degrees(0, 90, 180, 270).

Expand  

https://minecraft.gamepedia.com/Model#Block_states

Expand  

 

This is why I use the Forge blockstate format, with Forge marker set as 1.
 

  On 5/16/2019 at 1:53 PM, V0idWa1k3r said:

or i think you can use a transform key

Expand  

 

Well this is exactly what I did in my blockstates file :
 

{
	"forge_marker": 1,
	"defaults": {
		"model": "mymod:standing_rp_sign",
		"uvlock": true
	},
	"variants": {
		"rotation": {
			"0": {
				"transform": { "rotation": { "y": 180 } }
			},
			"1": {
				"transform": { "rotation": { "y": 157.5 } }
			},
			"2": {
				"transform": { "rotation": { "y": 135 } }
			},
			"3": {
				"transform": { "rotation": { "y": 112.5 } }
			},
			"4": {
				"transform": { "rotation": { "y": 90 } }
			},
			"5": {
				"transform": { "rotation": { "y": 67.5 } }
			},
			"6": {
				"transform": { "rotation": { "y": 45 } }
			},
			"7": {
				"transform": { "rotation": { "y": 22.5 } }
			},
			"8": {
				"transform": { "rotation": { "y": 0 } }
			},
			"9": {
				"transform": { "rotation": { "y": 337.5 } }
			},
			"10": {
				"transform": { "rotation": { "y": 315 } }
			},
			"11": {
				"transform": { "rotation": { "y": 292.5 } }
			},
			"12": {
				"transform": { "rotation": { "y": 270 } }
			},
			"13": {
				"transform": { "rotation": { "y": 247.5 } }
			},
			"14": {
				"transform": { "rotation": { "y": 225 } }
			},
			"15": {
				"transform": { "rotation": { "y": 202.5 } }
			}
		}
    }
}

 

Following output :

image.png.2ea5c1a1112098e4d39386ec290c804d.png

Edited by Major Squirrel

Squirrel ! Squirrel ! Squirrel !

Posted

Good evening,

According to some modders on Discord, the only way to use 22.5° degrees rotations properly in blockstates files would be to use OBJ models.

Another solution would be to create 4 models with different rotations and to handle 4 different states per model in blockstates files so that it would handle the 16 rotations (see also this topic).

 

Thank you for helping me !

Squirrel ! Squirrel ! Squirrel !

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.