Jump to content

(1.12.2) Random Block Rotations


Noob_Master69

Recommended Posts

So I've added an ore to my mod with a custom model. And when I put them side by side, it's pretty plain. Can anybody teach me how to add random block rotations so It's not always the same pattern? 

 

copper_ore.json

{
	"credit": "Made with Blockbench",
	"textures": {
		"1": "imam:blocks/stone",
		"2": "imam:blocks/copper",
		"particle": "imam:blocks/copper"
	},
	"elements": [
		{
			"from": [0, 0, 0],
			"to": [16, 16, 16],
			"faces": {
				"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
				"east": {"uv": [0, 0, 16, 16], "texture": "#1"},
				"south": {"uv": [0, 0, 16, 16], "texture": "#1"},
				"west": {"uv": [0, 0, 16, 16], "texture": "#1"},
				"up": {"uv": [0, 0, 16, 16], "texture": "#1"},
				"down": {"uv": [0, 0, 16, 16], "texture": "#1"}
			}
		},
		{
			"from": [12, 3, -3],
			"to": [17, 9, 4],
			"rotation": {"angle": 45, "axis": "x", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 5, 6], "texture": "#2"},
				"east": {"uv": [0, 0, 7, 6], "texture": "#2"},
				"south": {"uv": [0, 0, 5, 6], "texture": "#2"},
				"west": {"uv": [0, 0, 7, 6], "texture": "#2"},
				"up": {"uv": [0, 0, 5, 7], "texture": "#2"},
				"down": {"uv": [0, 0, 5, 7], "texture": "#2"}
			}
		},
		{
			"from": [6, 1.5, 14.5],
			"to": [11, 8.5, 20.5],
			"rotation": {"angle": -22.5, "axis": "x", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 5, 7], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 7, 6], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 5, 7], "texture": "#2"},
				"west": {"uv": [0, 0, 7, 6], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 5, 6], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 5, 6], "texture": "#2"}
			}
		},
		{
			"from": [-2, 1.5, 2.5],
			"to": [3, 8.5, 8.5],
			"rotation": {"angle": -22.5, "axis": "x", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 5, 7], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 7, 6], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 5, 7], "texture": "#2"},
				"west": {"uv": [0, 0, 7, 6], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 5, 6], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 5, 6], "texture": "#2"}
			}
		},
		{
			"from": [18, 12, 7],
			"to": [25, 18, 14],
			"rotation": {"angle": 45, "axis": "z", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 7, 6], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 7, 6], "rotation": 180, "texture": "#2"},
				"south": {"uv": [0, 0, 7, 6], "rotation": 180, "texture": "#2"},
				"west": {"uv": [0, 0, 7, 6], "rotation": 180, "texture": "#2"},
				"up": {"uv": [0, 0, 7, 7], "texture": "#2"},
				"down": {"uv": [0, 0, 7, 7], "texture": "#2"}
			}
		},
		{
			"from": [3, 7.5, 1.5],
			"to": [10, 16.5, 8.5],
			"rotation": {"angle": -22.5, "axis": "x", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 7, 9], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 9, 7], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 7, 9], "texture": "#2"},
				"west": {"uv": [0, 0, 9, 7], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 7, 7], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 7, 7], "texture": "#2"}
			}
		},
		{
			"from": [7, 4.5, 9.5],
			"to": [13, 13.5, 16.5],
			"rotation": {"angle": 22.5, "axis": "y", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 6, 9], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 9, 7], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 6, 9], "texture": "#2"},
				"west": {"uv": [0, 0, 9, 7], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 6, 7], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 6, 7], "texture": "#2"}
			}
		},
		{
			"from": [0, 11.5, 9.5],
			"to": [6, 17.5, 16.5],
			"rotation": {"angle": 22.5, "axis": "z", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 6, 6], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 6, 7], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 6, 6], "texture": "#2"},
				"west": {"uv": [0, 0, 6, 7], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 6, 7], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 6, 7], "texture": "#2"}
			}
		},
		{
			"from": [1, 0.5, 6.5],
			"to": [7, 6.5, 13.5],
			"rotation": {"angle": 22.5, "axis": "z", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 6, 6], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 6, 7], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 6, 6], "texture": "#2"},
				"west": {"uv": [0, 0, 6, 7], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 6, 7], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 6, 7], "texture": "#2"}
			}
		},
		{
			"from": [10, -6.5, -1.5],
			"to": [16, 0.5, 4.5],
			"rotation": {"angle": -22.5, "axis": "z", "origin": [15.5, 3, 0.5]},
			"faces": {
				"north": {"uv": [0, 0, 6, 7], "rotation": 180, "texture": "#2"},
				"east": {"uv": [0, 0, 7, 6], "rotation": 270, "texture": "#2"},
				"south": {"uv": [0, 0, 6, 7], "texture": "#2"},
				"west": {"uv": [0, 0, 7, 6], "rotation": 90, "texture": "#2"},
				"up": {"uv": [0, 0, 6, 6], "rotation": 180, "texture": "#2"},
				"down": {"uv": [0, 0, 6, 6], "texture": "#2"}
			}
		}
	]
}

 

Link to comment
Share on other sites

In your blockstate json add a couple of "normal" variants with different rotations. For example:
 

{
  "forge_marker": 1,
  "defaults": {
    "model": "modid:modblock"
  },
  "variants": {
    "normal": [
      {
        "model": "modid:modblock"
      },
      {
        "model": "modid:modblock",
        "y": 90
      },
      {
        "model": "modid:modblock",
        "y": 180
      },
      {
        "model": "modid:modblock",
        "y": 270
      }
    ],
    "inventory": [{
      "transform": "forge:default-block"
    }]
  }
}

 

Link to comment
Share on other sites

1 hour ago, ZigTheHedge said:

In your blockstate json add a couple of "normal" variants with different rotations. For example:
 


{
  "forge_marker": 1,
  "defaults": {
    "model": "modid:modblock"
  },
  "variants": {
    "normal": [
      {
        "model": "modid:modblock"
      },
      {
        "model": "modid:modblock",
        "y": 90
      },
      {
        "model": "modid:modblock",
        "y": 180
      },
      {
        "model": "modid:modblock",
        "y": 270
      }
    ],
    "inventory": [{
      "transform": "forge:default-block"
    }]
  }
}

 

so will the code look like this?

Spoiler

{
  "forge_marker": 1,
  "defaults": {
    "model": "imam:copper_ore"
  },
  "variants": {
    "normal": [
      {
        "model": "imam:copper_ore"
      },
      {
        "model": "imam:copper_ore",
        "y": 90
      },
      {
        "model": "imam:copper_ore",
        "y": 180
      },
      {
        "model": "imam:copper_ore",
        "y": 270
      }
    ],
     "inventory": [{
      "transform": "forge:default-block"
    }]
  }
}

 

Link to comment
Share on other sites

By the way, Minecraft vanilla doesn't apply the random rotation thing to ores. You're free to do whatever you want, but I am one of those sorts of people who look at vanilla and tries to match style and ethos. So if vanilla doesn't apply random rotations to ores, then my ores won't have random rotation either. This the closest I've come to having a non-square model, and even then its based on the math behind water, soo...

 

(By the way, don't forget to add your ore blocks and items to the tag system)

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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You can try other builds of Quark/Zeta
    • Hello all, I recently tried to upgrade my Minecraft mod to version 1.21.3, and I seem to have a problem with the `RenderSystem#setShaderColor` method. Here is how the screen is usually supposed to look like: Here is how it looks at present: To further explain, the note labels atop of the note buttons are colored cyan (here) using `RenderSystem#setShaderColor`. The note buttons and labels get their colors from their native texture - white. This means that even though I set the coloring to apply to the label (top), it is applied to the button (bottom). What I conclude is happening then, in essence, is that this method (at least for my case) does not color the blit after - but rather the blit before..?  This also blocks me from later resetting the shader, as I need to set it back to white before the blitting is done, and not when it's done. So like... what? I've tested this further with other components that require this method, and this preceding-like behavior seems to be pretty consistent for them too.   I should mention that all the snippets I am about to show have all worked in past versions. In my class `ClientUtil`, the following methods are defined: public static void setShaderColor(final Color color, final float alpha) { RenderSystem.setShaderColor( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, alpha ); } public static void setShaderColor(final Color color) { setShaderColor(color, 1); } public static void resetShaderColor() { setShaderColor(Color.WHITE); } //... public static RenderType guiRT(final ResourceLocation loc) { return RenderType.guiTextured(loc); } And here is the snippet from `NoteButtonRenderer#renderNote` using it: // "Note" here refers to those symbols in the middle of a note button protected void renderNote(final GuiGraphics gui, final InstrumentThemeLoader themeLoader) { final int noteWidth = noteButton.getWidth()/2, noteHeight = noteButton.getHeight()/2; ClientUtil.setShaderColor((noteButton.isPlaying() && !foreignPlaying) ? themeLoader.notePressed() : themeLoader.noteReleased() ); gui.blit(ClientUtil::guiRT, noteTextureProvider.get(), noteButton.getX() + noteWidth/2, noteButton.getY() + noteHeight/2, 0, 0, noteWidth, noteHeight, noteWidth, noteButton.getHeight()/2 ); ClientUtil.resetShaderColor(); } You may find the full source here. The odd thing is that Minecraft does seem to use this method the regular way I showed, for instance `SkyRenderer#renderSkyDisc` (not sure if I'l allowed to paste it). Could it be that I'm doing something wrong that leads to this issue..? I'm really stumped on this one.  I couldn't really find any change logs or documentation for this rendering API (even in this Fabric blog post), so I'm sorry if this seems obvious or anything.  Either way, any help would be appreciated.
    • This did work. rip Quark Thank you
    • It says Quark Requires zeta. do i just remove Quark? https://mclo.gs/cq799kI
    • It refers to the mod elenaidodge Backup the world and make a test without it
  • Topics

×
×
  • Create New...

Important Information

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