Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) {
			Collection<Property<?>> properties = state.getProperties();
			List<BakedQuad> quads = new ArrayList<>();
			for (Map.Entry<String, JsonElement> variantElements : variants.entrySet()) {
				//String JSONVariants = variantElement.getAsString();
				String[] JSONProperties = variantElements.getKey().split(",", 0);
				for (String JSONProperty : JSONProperties) {
					String propertyName = JSONProperty.split("=", 2)[0];
					Integer propertyValue = Integer.valueOf(JSONProperty.split("=", 2)[1]);
					for (Property<?> property : properties) {
						if (!property.getName().equalsIgnoreCase(propertyName) && state.get(property) == propertyValue) {
							TextureAtlasSprite sprite = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(/*variantElements.getValue().getAsJsonObject().get("top").getAsString()*/"block/oak_planks")).getSprite();
							List<TextureAtlasSprite> sprites = new ArrayList<>();

							ExpansionMod.LOGGER.debug(sprite.toString());


							quads.add(buildQuad(Direction.NORTH, sprite,
								1, 1, 0, sprite.getMinU(), sprite.getMinV(),
								1, 0, 0, sprite.getMinU(), sprite.getMaxV(),
								0, 0, 0, sprite.getMaxU(), sprite.getMaxV(),
								0, 1, 0, sprite.getMaxU(), sprite.getMinV()
							));
							quads.add(buildQuad(Direction.SOUTH, sprite,
								0, 1, 1, sprite.getMinU(), sprite.getMinV(),
								0, 0, 1, sprite.getMinU(), sprite.getMaxV(),
								1, 0, 1, sprite.getMaxU(), sprite.getMaxV(),
								1, 1, 1, sprite.getMaxU(), sprite.getMinV()
							));
						}
					}
				}
			}
			ExpansionMod.LOGGER.debug(quads);
			return quads;
		}

private BakedQuad buildQuad(Direction side, TextureAtlasSprite sprite,
		                                   float x0, float y0, float z0, float u0, float v0,
		                                   float x1, float y1, float z1, float u1, float v1,
		                                   float x2, float y2, float z2, float u2, float v2,
		                                   float x3, float y3, float z3, float u3, float v3) {
			BakedQuadBuilder builder = new BakedQuadBuilder(sprite);
			builder.setApplyDiffuseLighting(true);
			builder.setContractUVs(true);
			boolean hasTransform = this.modelTransform.getRotation().isIdentity();
			IVertexConsumer consumer = hasTransform ? new TRSRTransformer(builder, this.modelTransform.getRotation()) : builder;

			builder.setQuadOrientation(side);

			putVertex(consumer, side, x0, y0, z0, u0, v0);
			putVertex(consumer, side, x1, y1, z1, u1, v1);
			putVertex(consumer, side, x2, y2, z2, u2, v2);
			putVertex(consumer, side, x3, y3, z3, u3, v3);

			return builder.build();
		}

		private static void putVertex(IVertexConsumer consumer, Direction side, float x, float y, float z, float u, float v) {
			ImmutableList<VertexFormatElement> elements = consumer.getVertexFormat().getElements();
			for(int e = 0; e <= elements.size() - 1; e ++){
				VertexFormatElement element = elements.get(e);
				switch(element.getUsage()){
					case POSITION :
						consumer.put(e, x, y, z, 1.0f);
						break;
					case COLOR :
						consumer.put(e, 1.0f, 1.0f, 1.0f, 1.0f);
						break;
					case NORMAL :
						float offX = (float) side.getXOffset();
						float offY = (float) side.getYOffset();
						float offZ = (float) side.getZOffset();
						consumer.put(e, offX, offY, offZ, 0.0f);
						break;
					case UV :
						if(element.getIndex() == 0){
							consumer.put(e, u, v, 0f, 1f);
							break;
						}
					default :
						consumer.put(e);
						break;
				}
			}
		}

1894760391_(51).png.f70f8f366e2e9bee7da37ced71d7a2e7.png

With the above code, I'm trying to model the block on the right side of the image. The block on the left is oak_planks. As you can see, the custom model on the right has a single color and no shade. How can I shade this model?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.