Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/21 in all areas

  1. Why the fauk does your renderer change what blocks are in the world? That's not the job of a renderer.
    1 point
  2. Gasp, you're not on the server.
    1 point
  3. You need to check before casting, like we usually do. https://mcforge.readthedocs.io/en/latest/concepts/sides/#performing-side-specific-operations
    1 point
  4. After you have your crop block, then look into how the lilypad item works.
    1 point
  5. I don't think this gives you water as a below block but rather a block that is waterlogged. Check how lily pads work.
    1 point
  6. Ah ha! It worked! Thank you everybody for the incredible help! Here is a fairly detailed solution to the problem for anybody's reference: 1) Make your block tex multi-layered. TheGreyGhost has an excellent tutorial of this under mbe05 of Minecraft By Example. Be sure to register one layer as a RenderType.getCutout() and one as a RenderType.getTranslucent(), and to adjust the .json file accordingly. /* In charge of client initialization */ private void onClientSetup(final FMLClientSetupEvent event) { ... // Render type registry for glowing blocks RenderTypeLookup.setRenderLayer(MinenauticaBlocks.WRITHING_WEED, Minenautica::getDoubleLayer); ... } // Double layer render lookup public static boolean getDoubleLayer(RenderType layerToCheck) { return layerToCheck == RenderType.getCutout() || layerToCheck == RenderType.getTranslucent(); } 2) Create and register a custom IBakedModel. We need to register a custom IBakedModel because we will need to manually update the light value of the quads on the translucent layer of the model. Again, Minecraft By Example has an excellent tutorial of this under mbe04. I would use the CamouflageBakedModel as reference, as we will be using the standard model of the block, just with a modification to the quads. 3) Alter the getQuads method. We will be altering this method to check which render layer we are currently on, and then altering the quads on the translucent layer. We are most interested with the vertexData of BakedQuad, which holds the following data, again from Minecraft By Example: // vertexData[i + 0] = Float.floatToRawIntBits(positionIn.getX()); // vertexData[i + 1] = Float.floatToRawIntBits(positionIn.getY()); // vertexData[i + 2] = Float.floatToRawIntBits(positionIn.getZ()); // vertexData[i + 3] = shadeColor; // vertexData[i + 4] = Float.floatToRawIntBits(textureU)); // vertexData[i + 5] = Float.floatToRawIntBits(textureV)); // vertexData[i + 6] = baked lighting (blocklight + skylight) // vertexData[i + 7] = normal; There are four groups of these eight pieces of data, and we are concerned which changing the 7th element in each of these groups that correspond with the baked lighting value. It is critical to note that to account for both the block light and sky light, the value of baked lighting is a 32-bit integer, where the upper 16 bits contain the sky lighting * 16 and the lower 16 bits contain the block lighting * 16. So, for example, the brightest baked lighting value would be 2^16 * 15 * 16 + 15 * 16 = 15728880. We will run through each BakedQuad in the model and set the baked lighting values to this new baked lighting value. For a more detailed explanation, here is a good link. @Override @Nonnull public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { List<BakedQuad> quads = this.model.getQuads(state, side, rand); if(MinecraftForgeClient.getRenderLayer() == RenderType.getTranslucent()) { for(int i = 0; i < quads.size(); i++) { BakedQuad quad = quads.get(i); int[] vertexData = quad.getVertexData(); for(int j = 0; j < 4; j++) { vertexData[8 * j + 6] = getLightValue(15, 15); } quads.set(i, new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.func_187508_a(), quad.shouldApplyDiffuseLighting())); } } return quads; } /* * Return the light value for a given sky lighting and block lighting * A 32-bit integer, with the upper bits skyLighting*16 and the lower bits blockLighting*16 */ private static final int UPPER_HALF = 65536; // 2^16 private static int getLightValue(int skyLighting, int blockLighting) { return UPPER_HALF * skyLighting * 16 + blockLighting * 16; } And that is it! There are few steps, but in the end we are just registering a translucent layer, and then adjusting the quads of that layer. Thank you everybody for the help, and I am posting pictures of the results below (for more pictures you can visit the mod's website at Minenautica). Light Image: https://ibb.co/djRYL32 Dark Image: https://ibb.co/dQ7TctP
    1 point
×
×
  • Create New...

Important Information

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