use of net.minecraftforge.client.model.pipeline.VertexTransformer in project BluePower by Qmunity.
the class BPMicroblockModel method transform.
private static BakedQuad transform(BakedQuad sizeQuad, TextureAtlasSprite sprite, Direction dir, Block block) {
BakedQuadBuilder builder = new BakedQuadBuilder();
final IVertexConsumer consumer = new VertexTransformer(builder) {
@Override
public void put(int element, float... data) {
VertexFormatElement e = this.getVertexFormat().getElements().get(element);
if (e.getUsage() == VertexFormatElement.Usage.UV && e.getIndex() == 0) {
Vector2f vec = new Vector2f(data[0], data[1]);
float u = (vec.x - sizeQuad.getSprite().getU0()) / (sizeQuad.getSprite().getU1() - sizeQuad.getSprite().getU0()) * 16;
float v = (vec.y - sizeQuad.getSprite().getV0()) / (sizeQuad.getSprite().getV1() - sizeQuad.getSprite().getV0()) * 16;
builder.put(element, sprite.getU(u), sprite.getV(v));
} else if (e.getUsage() == VertexFormatElement.Usage.COLOR) {
int color;
try {
color = Minecraft.getInstance().getBlockColors().getColor(block.defaultBlockState(), null, null, sizeQuad.getTintIndex());
} catch (Exception ex) {
try {
color = Minecraft.getInstance().getBlockColors().getColor(block.defaultBlockState(), null, BlockPos.ZERO, sizeQuad.getTintIndex());
} catch (Exception ex2) {
color = 0;
}
}
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (color & redMask) >> 16;
int g = (color & greenMask) >> 8;
int b = (color & blueMask);
parent.put(element, r / 255F, g / 255F, b / 255F, 1);
} else {
parent.put(element, data);
}
}
};
LightUtil.putBakedQuad(consumer, sizeQuad);
return builder.build();
}
use of net.minecraftforge.client.model.pipeline.VertexTransformer in project BluePower by Qmunity.
the class BPMultipartModel method transform.
private static BakedQuad transform(BakedQuad quad, Pair<Integer, Integer> colorPair, Boolean fullBright) {
BakedQuadBuilder builder = new BakedQuadBuilder();
final IVertexConsumer consumer = new VertexTransformer(builder) {
@Override
public void put(int element, float... data) {
VertexFormatElement e = this.getVertexFormat().getElements().get(element);
if (e.getUsage() == VertexFormatElement.Usage.COLOR) {
int color = quad.getTintIndex() == 2 ? colorPair.getSecond() : colorPair.getFirst();
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (color & redMask) >> 16;
int g = (color & greenMask) >> 8;
int b = (color & blueMask);
parent.put(element, r / 255F, g / 255F, b / 255F, 1);
} else {
parent.put(element, data);
}
}
};
LightUtil.putBakedQuad(consumer, quad);
BakedQuad finalQuad = builder.build();
if (fullBright)
LightUtil.setLightData(finalQuad, 240);
return finalQuad;
}
Aggregations