Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/19/18 in all areas

  1. Yes, it is definitely possible but as my long "essay" above notes it is rarely worth it. 1.10 to 1.11 was a rare transition with very little big things changing between them. Most versions are much more drastic. But imagine going from a version before blockstates was introduced to afterwards -- you'd need to like replicate the whole system of one of the two approaches in order to make them compatible. Or imagine going from a version before capabilities to one afterwards, and so forth. So like I said before -- you can do it but only if you "pick your battles". If your mod focuses on a specific thing like entities and that doesn't change much between versions then it might be worth a compatibility layer.
    1 point
  2. You can subscribe to anything that is a descendant of net.minecraftforge.fml.common.eventhandler.Event regardless of it's package.
    1 point
  3. public List<BakedQuad> colorQuads(List<BakedQuad> quads, int color) { for (int i = 0; i < quads.size(); i++) { net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(Tessellator.getInstance().getBuffer(), quads.get(i), color); } return quads; } renderQuadColor renders the quad. It doesn't change the properties of said quad. So this would obviously do nothing to the quad. int colorRGBA = 0; colorRGBA |= 0x00 << 16;// r colorRGBA |= 0xFF << 8; // g colorRGBA |= 0x00 << 0; // b colorRGBA |= 0xFF << 24;// a renderQuadsColor(bufferbuilder, quads, colorRGBA); Or you could simply write int colorRGBA = 0xFF00FF00; And have the same effect without the bitshifts and or. As for the actual question. Quads are usually stored in the ITEM vertex format which has the color element. So you can absolutely apply color to BakedQuads. It is pretty straight forward. Each quad contains 4 vertices which each contain the elements of the format in the order specified by that format. In BakedQuads those vertices are unified into a single array: protected final int[] vertexData; This doesn't stop you from modifying the vertex data by modifying the array. So the logical order of operations would be to iterate 4 times(4 vertices per quad), get the color element in the array by multiplying the current vertex's index with the size of each vertex and adding the offset to the color element. All that data is available to you in the format of the quad. So basically you would need to create a custom BakedQuad wrapper and change what you return in the BakedQuad#getVertexData method. This might be tough to understand so here is a functional example: private static class ColoredQuad extends BakedQuad { private boolean wasRecolored; // Caching whether the recoloring occured. private int[] vertexData; // The data of the quad. // Wrapper constructor public ColoredQuad(BakedQuad original) { super(original.getVertexData(), original.getTintIndex(), original.getFace(), original.getSprite(), original.shouldApplyDiffuseLighting(), original.getFormat()); this.vertexData = original.getVertexData(); } private void recolor() { // First getting the format of the quad. VertexFormat format = this.format; // Getting the size of each vertex. int size = format.getIntegerSize(); // Getting the color offset. Dividing by 4 because the offset is specified in bytes. int offset = format.getColorOffset() / 4; // The color you want to recolor the quad to. Note that the format for the color is ABGR! int newColor = 0xFF0000FF; // Iterating over the vertices(4 vertices per quad) for (int i = 0; i < 4; i++) { // Modifying the element of the vertex at [i] at [offset] with the new color. this.vertexData[offset + size * i] = newColor; } // Caching that the operation was performed. this.wasRecolored = true; } // The vertex data getter. @Override public int[] getVertexData() { // Recolor the quad if it wasn't recolored. if (!this.wasRecolored) { this.recolor(); } return this.vertexData; } } And here is how it looks when I replace the model of the Iron Ingot with the one that colored the quads:
    1 point
  4. Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader Java 9+ is not currently supported, you need to use Java 8.
    1 point
  5. Or he could make an invisible helmet and put it on all zombies if they spawn without one.
    1 point
×
×
  • Create New...

Important Information

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