Jump to content

Recommended Posts

Posted

Hello Modders,

I have a block with 5 state properties:

public static final SideTypeProperty NORTH_SIDETYPE = SideTypeProperty.create("north_sidetype", SideType.None, SideType.Input, SideType.Output);
public static final SideTypeProperty EAST_SIDETYPE = SideTypeProperty.create("east_sidetype", SideType.None, SideType.Input, SideType.Output);
public static final SideTypeProperty SOUTH_SIDETYPE = SideTypeProperty.create("south_sidetype", SideType.None, SideType.Input, SideType.Output);
public static final SideTypeProperty WEST_SIDETYPE = SideTypeProperty.create("west_sidetype", SideType.None, SideType.Input, SideType.Output);
	
protected RedstoneGate() {
	super(Properties.create(Material.MISCELLANEOUS).zeroHardnessAndResistance().sound(SoundType.WOOD));
	this.setDefaultState(this.stateContainer.getBaseState()
			.with(HORIZONTAL_FACING, Direction.NORTH)
			.with(POWERED, Boolean.valueOf(false))
			.with(NORTH_SIDETYPE, SideType.None)
			.with(EAST_SIDETYPE, SideType.Input)
			.with(SOUTH_SIDETYPE, SideType.Output)
			.with(WEST_SIDETYPE, SideType.Input));
}

At first I made the mistake to note every combination down. This of course was an insane task and I would have to do it for 5 other blocks as well. So the question is how to write an advanced json file that is not insanely long.

I tried it with the multipart style, but the debug log says, that it didn't work. Here it is:

{
	"multipart": [
		{ "apply": { "model": "gates:block/gate_or" }},
		{
			"when": {"facing":"east"},
			"apply": { "y": 90 }
		},
		{
			"when": {"facing":"south"},
			"apply": { "y": 180 }
		},
		{
			"when": {"facing":"west"},
			"apply": { "y": 270 }
		},
		
		{
			"when": {"facing":"west"},
			"apply": { "y": 270 }
		},
		{
			"when": {"north_sidetype":"i"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"north_sidetype":"o"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"east_sidetype":"i"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"east_sidetype":"o"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"south_sidetype":"i"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"south_sidetype":"o"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"west_sidetype":"i"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		},
		{
			"when": {"west_sidetype":"o"},
			"apply": { 
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"overlay": {
						"model":"gates:overlay"
					}
				}
			}
		}
	]
}


Any idea how to do it?

Thanks in advance :)

Posted

Use datagens

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted

Ok thanks,

I tried to do it, but I ran into an issue. I want to overlay a texture when eigher sidetype is input or output:

getVariantBuilder(BlockInit.gate_or).forAllStates(state -> {
	Builder<?> configuredModel = ConfiguredModel.builder();
	
	if(state.get(RedstoneGate.POWERED))
		configuredModel.modelFile(models().singleTexture("gate_or", mcLoc("block/gate_or"), "gate_or", mcLoc("block/gate_or")));
	else
		configuredModel.modelFile(models().singleTexture("gate_or", mcLoc("block/gate_or"), "gate_or", mcLoc("block/gate_or")));
	
	if(state.get(RedstoneGate.EAST_SIDETYPE) == SideType.Input) {
		
	} else if(state.get(RedstoneGate.EAST_SIDETYPE) == SideType.Output) {
		
	}
	
	if(state.get(RedstoneGate.SOUTH_SIDETYPE) == SideType.Input) {
		
	} else if(state.get(RedstoneGate.SOUTH_SIDETYPE) == SideType.Output) {
		
	}

	if(state.get(RedstoneGate.WEST_SIDETYPE) == SideType.Input) {
	
	} else if(state.get(RedstoneGate.WEST_SIDETYPE) == SideType.Output) {
		
	}
			
	if(state.get(RedstoneGate.NORTH_SIDETYPE) == SideType.Input) {
			
	} else if(state.get(RedstoneGate.NORTH_SIDETYPE) == SideType.Output) {
			
	}
	return configuredModel.build();
});

I don't really understand what I have to call for that.

 

I do have the idea, that it would be possibile to do it just in a json, becuase Ender IO does it in 1.12.2 in their BlockMachineBase.json: https://github.com/SleepyTrousers/EnderIO/blob/master/enderio-base/src/main/resources/assets/enderio/blockstates/block_machine_base.json

But I don't know how to work with these submodels and overlays. My take on this looks like this:

{
	"forge_marker": 1,
	"defaults": { "model": "gates:block/gate_or" },
	"variants": {
		"facing": {
			"north": {},
			"south": {"y": 180},
			"west": {"y": 270},
			"east": {"y": 90}
		},
		"powered": {
			"true": { "model": "gates:block/gate_or" },
			"false": { "model": "gates:block/gate_or" }
		},
		"north_sidetype": {
			"i": {
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or"
				}
			},
			"o": {
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or"
				}
			},
			"n": {}
		},
		"east_sidetype": {
			"i": {
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 90
				}
			},
			"o": {
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 90
				}
			},
			"n": {}
		},
		"south_sidetype": {
			"i": {
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 180
				}
			},
			"o": {
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 180
				}
			},
			"n": {}
		},
		"west_sidetype": {
			"i": {
				"textures": {
					"overlay":"gates:blocks/iOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 270
				}
			},
			"o": {
				"textures": {
					"overlay":"gates:blocks/oOverlay"
				},
				"submodel": {
					"model":"gates:block/gate_or",
					"y": 270
				}
			},
			"n": {}
		}
	}
}

But it doesn't work. The log file just says "missing model for variant:" for every variant there is and at the end: "in resourcepack: 'Mod Resources': Missing model, expected to find a string"

And I don't know how would deal with submodels in the BlockStateProvider class

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.