VertexRotator rot = new VertexRotator( f2r, quad.getFace() ); rot.setParent( builder ); quad.pipe( rot ); if( quad.getFace() != null ) builder.setQuadOrientation( f2r.rotate( quad.getFace() ) ); BakedQuad packedQuad = new BakedQuad( unpackedQuad.getVertexData(), quad.getTintIndex(), unpackedQuad.getFace(), quad.getSprite(), quad .shouldApplyDiffuseLighting(), quad.getFormat() ); rotated.add( packedQuad );
private List<BakedQuad> fixQuadTint( EnumFacing facing, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright ) { List<BakedQuad> quads = this.baseModel.getQuads( null, facing, 0 ); List<BakedQuad> result = new ArrayList<>( quads.size() ); for( BakedQuad quad : quads ) { int tint; if( quad.getSprite() == texDark ) { tint = 1; } else if( quad.getSprite() == texMedium ) { tint = 2; } else if( quad.getSprite() == texBright ) { tint = 3; } else { result.add( quad ); continue; } BakedQuad newQuad = new BakedQuad( quad.getVertexData(), tint, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad .getFormat() ); result.add( newQuad ); } return result; }
EnumFacing newFace = rotation.rotate( quad.getFace() ); return new BakedQuad( newData, quad.getTintIndex(), newFace, quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat() );
quad.pipe( trans ); builder.setQuadTint( quad.getTintIndex() ); builder.setQuadOrientation( quad.getFace() ); builder.setTexture( quad.getSprite() ); builder.setApplyDiffuseLighting( false );
private static TextureAtlasSprite findTexture( TextureAtlasSprite texture, final List<BakedQuad> faceQuads, final EnumFacing myFace ) throws IllegalArgumentException, IllegalAccessException, NullPointerException { for ( final BakedQuad q : faceQuads ) { if ( q.getFace() == myFace ) { texture = findQuadTexture( q, null ); } } return texture; }
/** * Offsets the z coordinate and color the quads * @param quads The original quads * @param offset The offset to apply * @param color The color * @return The offsetted quads */ private Collection<? extends BakedQuad> offsetAndColor(List<BakedQuad> quads, float offset, int color) { List<BakedQuad> offsetQuads = Lists.newArrayListWithExpectedSize(quads.size()); for (BakedQuad quad : quads) { int[] vertexData = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); for(int i = 0; i < vertexData.length / 7; i++) { float originalZ = Float.intBitsToFloat(vertexData[i * 7 + 2]); originalZ += offset; vertexData[i * 7 + 2] = Float.floatToIntBits(originalZ); vertexData[i * 7 + 3] = color; } offsetQuads.add(new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), false, DefaultVertexFormats.ITEM)); } return offsetQuads; }
/** * Color the quads * @param quads The original quads * @param color The color * @return The colored quads */ private Collection<? extends BakedQuad> color(List<BakedQuad> quads, int color) { List<BakedQuad> offsetQuads = Lists.newArrayListWithExpectedSize(quads.size()); for (BakedQuad quad : quads) { int[] vertexData = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); for(int i = 0; i < vertexData.length / 7; i++) { vertexData[i * 7 + 3] = color; } offsetQuads.add(new BakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), false, DefaultVertexFormats.ITEM)); } return offsetQuads; }
@Override public List<BakedQuad> transformQuad(BakedQuad quad, ITextureContext context, int quadGoal) { Quad q = makeQuad(quad, context); if (context == null) { return Collections.singletonList(q.transformUVs(sprites[0], Quad.TOP_LEFT).rebake()); } return Collections.singletonList(q.transformUVs(sprites[0], getQuad(((TextureContextCTM) context).getCTM(quad.getFace()))).rebake()); }
@Override public List<BakedQuad> getGeneralQuads() { List<BakedQuad> quads = Lists.newLinkedList(); // Base chalice model quads.addAll(chaliceModel.getQuads(blockState, facing, rand)); // Colored gems int color = getColorSeed(this.id); for(BakedQuad quad : gemsModel.getQuads(blockState, facing, rand)) { int[] data = quad.getVertexData(); for(int i = 0; i < data.length / 7; i++) { data[i * 7 + 3] = color; } quads.add(new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), true, DefaultVertexFormats.ITEM)); } // Fluid if(fluidStack != null) { quads.addAll(getFluidQuads(fluidStack, TileEntangledChalice.BASE_CAPACITY)); } return quads; }
public static void tintBlockFlat(IBlockAccess world, IBlockState state, BlockPos pos, BufferBuilder buffer, BakedQuad quad, int lightColor) { if((lightColor & 0xF0) == 0) return; float[] colors = ColoredLightSystem.getLightColor(world, pos.offset(quad.getFace())); if(ColoredLights.cullToLightmap) colors = cullColorsToLightmap(colors, lightColor); if(colors.length > 0) { float[] quadTint = tintQuad(quad, state, world, pos, buffer); if(quadTint != null) for(int i = 0; i < 3; i++) colors[i] *= quadTint[i]; for(int i = 1; i < 5; i++) buffer.putColorMultiplier(colors[0], colors[1], colors[2], i); } }
private static float[] tintQuad(BakedQuad bakedquad, IBlockState stateIn, IBlockAccess blockAccessIn, BlockPos posIn, BufferBuilder buffer) { if(bakedquad.hasTintIndex()) { int k = Minecraft.getMinecraft().getBlockColors().colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex()); if(EntityRenderer.anaglyphEnable) k = TextureUtil.anaglyphColor(k); float f = (float)(k >> 16 & 255) / 255.0F; float f1 = (float)(k >> 8 & 255) / 255.0F; float f2 = (float)(k & 255) / 255.0F; if(bakedquad.shouldApplyDiffuseLighting()) { float diffuse = LightUtil.diffuseLight(bakedquad.getFace()); f *= diffuse; f1 *= diffuse; f2 *= diffuse; } return new float[] { f, f1, f2 }; } else if(bakedquad.shouldApplyDiffuseLighting()) { float diffuse = LightUtil.diffuseLight(bakedquad.getFace()); return new float[] { diffuse, diffuse, diffuse }; } return null; }
private static BakedQuad tint(PartInfo.ClientInfo info, BakedQuad quad) { return quad.hasTintIndex() ? new BakedQuad(quad.getVertexData(), info.getTint(quad.getTintIndex()), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()) : quad; }
final EnumFacing face = q.getFace();
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if (bakedQuads.isEmpty()) { IModel crateModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(Constants.MOD_ID + ":item/crate-filled")); IBakedModel bakedModel = crateModel.bake(ModelManager.getInstance().getDefaultItemState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE); //Set the crate color index to 100 for (BakedQuad quad : bakedModel.getQuads(null, null, 0L)) { bakedQuads.add(new BakedQuad(quad.getVertexData(), 100, quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat())); } } IBakedModel model; List<BakedQuad> quads = new LinkedList<>(bakedQuads); IBakedModel contentModel = getCustomContentModel(); if (contentModel == null) { model = new ModelCrateBaked(quads, contained); } else { quads.addAll(contentModel.getQuads(null, null, 0)); model = new ModelCrateBaked(quads); } return new PerspectiveMapWrapper(model, ModelManager.getInstance().getDefaultItemState()); } }
if (bakedQuad.getFace() == facing) { return bakedQuad.getSprite();
builder.setQuadOrientation(quad.getFace()); builder.setTexture(quad.getSprite()); builder.setApplyDiffuseLighting(false);