net.minecraft.client.renderer.model.BakedQuad Java Examples
The following examples show how to use
net.minecraft.client.renderer.model.BakedQuad.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
public static BakedQuad buildQuad(VertexFormat format, TextureAtlasSprite sprite, Direction face, Colour colour, UVTransformation t, Vertex5 v1, Vertex5 v2, Vertex5 v3, Vertex5 v4) { // BakedQuadBuilder builder = new BakedQuadBuilder(format); // builder.setQuadTint(-1); // builder.setQuadOrientation(face); // builder.setTexture(sprite); // // t.apply(v1.uv); // t.apply(v2.uv); // t.apply(v3.uv); // t.apply(v4.uv); // putVertex(builder, format, face, v1, colour); // putVertex(builder, format, face, v2, colour); // putVertex(builder, format, face, v3, colour); // putVertex(builder, format, face, v4, colour); // // return copyQuad(builder.build()); return null; }
Example #2
Source File: AbstractBakedPropertiesModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
protected boolean checkDepth(BakedQuad quad, Vector3 hit, Direction hitFace) { int[] quadData = quad.getVertexData(); CachedFormat format = CachedFormat.lookup(DefaultVertexFormats.BLOCK); Vector3 posVec = new Vector3(); float[] pos = new float[4]; for (int v = 0; v < 4; v++) { LightUtil.unpack(quadData, pos, format.format, v, format.positionIndex); posVec.add(pos[0], pos[1], pos[2]); } posVec.divide(4); double diff = 0; switch (hitFace.getAxis()) { case X: diff = Math.abs(hit.x - posVec.x); break; case Y: diff = Math.abs(hit.y - posVec.y); break; case Z: diff = Math.abs(hit.z - posVec.z); break; } return !(diff > 0.01); }
Example #3
Source File: RenderBlockTER.java From MiningGadgets with MIT License | 6 votes |
private void renderModelBrightnessColorQuads(MatrixStack.Entry matrixEntry, IVertexBuilder builder, float red, float green, float blue, float alpha, List<BakedQuad> listQuads, int combinedLightsIn, int combinedOverlayIn) { for(BakedQuad bakedquad : listQuads) { float f; float f1; float f2; if (bakedquad.hasTintIndex()) { f = red * 1f; f1 = green * 1f; f2 = blue * 1f; } else { f = 1f; f1 = 1f; f2 = 1f; } builder.addVertexData(matrixEntry, bakedquad, f, f1, f2, alpha, combinedLightsIn, combinedOverlayIn); } }
Example #4
Source File: ModelBakery.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
public static IBakedModel generateItemModel(ItemStack stack) { Item item = stack.getItem(); if (item instanceof IBakeryProvider) { IItemBakery bakery = (IItemBakery) ((IBakeryProvider) item).getBakery(); List<BakedQuad> generalQuads = new LinkedList<>(); Map<Direction, List<BakedQuad>> faceQuads = new HashMap<>(); generalQuads.addAll(bakery.bakeItemQuads(null, stack)); for (Direction face : Direction.BY_INDEX) { List<BakedQuad> quads = new LinkedList<>(); quads.addAll(bakery.bakeItemQuads(face, stack)); faceQuads.put(face, quads); } PerspectiveProperties properties = bakery.getModelProperties(stack); return new PerspectiveAwareBakedModel(faceQuads, generalQuads, properties); } return missingModel; }
Example #5
Source File: AbstractBakedPropertiesModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Set<TextureAtlasSprite> getHitEffects(@Nonnull BlockRayTraceResult traceResult, BlockState state, IBlockReader world, BlockPos pos, IModelData modelData) { Vector3 vec = new Vector3(traceResult.getHitVec()).subtract(traceResult.getPos()); return getAllQuads(state, modelData).stream()// .filter(quad -> quad.getFace() == traceResult.getFace())// .filter(quad -> checkDepth(quad, vec, traceResult.getFace()))// .map(BakedQuad::func_187508_a)// .collect(Collectors.toSet());// }
Example #6
Source File: TextureUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Deprecated public static TextureAtlasSprite[] getIconsForBlock(BlockState state, Direction side) { IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state); if (model != null) { List<BakedQuad> quads = model.getQuads(state, side, new Random(0)); if (quads != null && quads.size() > 0) { TextureAtlasSprite[] sprites = new TextureAtlasSprite[quads.size()]; for (int i = 0; i < quads.size(); i++) { sprites[i] = quads.get(i).func_187508_a(); } return sprites; } } return new TextureAtlasSprite[0]; }
Example #7
Source File: VertexDataUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static Map<Direction, List<BakedQuad>> sortFaceData(List<BakedQuad> quads) { Map<Direction, List<BakedQuad>> faceQuadMap = new HashMap<>(); for (BakedQuad quad : quads) { List<BakedQuad> faceQuads = faceQuadMap.computeIfAbsent(quad.getFace(), k -> new ArrayList<>()); faceQuads.add(quad); } return faceQuadMap; }
Example #8
Source File: PerspectiveAwareMultiModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData data) { List<BakedQuad> quads = new LinkedList<>(); if (baseModel != null) { quads.addAll(baseModel.getQuads(state, side, rand, data)); } for (IBakedModel subModel : subModels) { quads.addAll(subModel.getQuads(state, side, rand, data)); } return quads; }
Example #9
Source File: AbstractPerspectiveLayeredModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected List<BakedQuad> getAllQuads(BlockState state, IModelData data) { List<BakedQuad> allQuads = new ArrayList<>(); for (RenderType layer : RenderType.getBlockRenderTypes()) { allQuads.addAll(getLayerQuads(state, null, layer, new Random(0), data)); for (Direction face : Direction.BY_INDEX) { allQuads.addAll(getLayerQuads(state, face, layer, new Random(0), data)); } } return allQuads; }
Example #10
Source File: AbstractPerspectiveLayeredModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData data) { RenderType layer = MinecraftForgeClient.getRenderLayer(); if (layer == null) { layer = generalLayer; } return getLayerQuads(state, side, layer, rand, data); }
Example #11
Source File: PerspectiveAwareOverrideModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { if (state == null && side == null) { return quads; } return Collections.emptyList(); }
Example #12
Source File: PerspectiveAwareBakedModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) { if (side == null) { return generalQuads; } else { if (faceQuads.containsKey(side)) { return faceQuads.get(side); } } return ImmutableList.of(); }
Example #13
Source File: AbstractBakedPropertiesModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
protected List<BakedQuad> getAllQuads(BlockState state, IModelData modelData) { List<BakedQuad> allQuads = new ArrayList<>(); allQuads.addAll(getQuads(state, null, new Random(0), modelData)); for (Direction face : Direction.BY_INDEX) { allQuads.addAll(getQuads(state, face, new Random(0), modelData)); } return allQuads; }
Example #14
Source File: PerspectiveAwareLayeredModelWrapper.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getLayerQuads(BlockState state, Direction side, RenderType layer, Random rand, IModelData data) { if (layerModelMap.containsKey(layer)) { return layerModelMap.get(layer).getQuads(state, side, rand); } return Collections.emptyList(); }
Example #15
Source File: PerspectiveAwareLayeredModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public List<BakedQuad> getLayerQuads(BlockState state, Direction side, RenderType layer, Random rand, IModelData data) { if (side == null) { if (layerGeneralQuads.containsKey(layer)) { return layerGeneralQuads.get(layer); } } else if (layerFaceQuadMap.containsKey(layer)) { Map<Direction, List<BakedQuad>> faceQuadMap = layerFaceQuadMap.get(layer); if (faceQuadMap.containsKey(side)) { return faceQuadMap.get(side); } } return Collections.emptyList(); }
Example #16
Source File: EnderPouchBakery.java From EnderStorage with MIT License | 5 votes |
@Override public List<BakedQuad> bakeItemQuads(Direction face, ItemStack stack) { List<BakedQuad> quads = new ArrayList<>(); if (face == null) { Frequency frequency = Frequency.readFromStack(stack); boolean open = EnderStorageManager.instance(true).getStorage(frequency, EnderItemStorage.TYPE).openCount() > 0; TextureAtlasSprite bagTexture = BAG_TEXTURES[frequency.hasOwner() ? 1 : 0][open ? 1 : 0]; TextureAtlasSprite leftButton = COLOUR_TEXTURES[0][frequency.getLeft().getWoolMeta()]; TextureAtlasSprite middleButton = COLOUR_TEXTURES[1][frequency.getMiddle().getWoolMeta()]; TextureAtlasSprite rightButton = COLOUR_TEXTURES[2][frequency.getRight().getWoolMeta()]; quads.addAll(ItemQuadBakery.bakeItem(bagTexture, leftButton, middleButton, rightButton)); } return quads; }
Example #17
Source File: Quad.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Bakes this Quad to a BakedQuad. * * @return The BakedQuad. */ public BakedQuad bake() { if (format.format != DefaultVertexFormats.BLOCK) { throw new IllegalStateException("Unable to bake this quad to the specified format. " + format.format); } int[] packedData = new int[format.format.getSize()]; for (int v = 0; v < 4; v++) { for (int e = 0; e < format.elementCount; e++) { LightUtil.pack(vertices[v].raw[e], packedData, format.format, v, e); } } return new BakedQuad(packedData, tintIndex, orientation, sprite, diffuseLighting); }
Example #18
Source File: ItemQuadBakery.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static List<BakedQuad> bakeItem(TransformationMatrix transform, TextureAtlasSprite... sprites) { LambdaUtils.checkArgument(sprites, "Sprites must not be Null or empty!", ArrayUtils::isNullOrContainsNull); List<BakedQuad> quads = new LinkedList<>(); for (int i = 0; i < sprites.length; i++) { TextureAtlasSprite sprite = sprites[i]; quads.addAll(ItemLayerModel.getQuadsForSprite(i, sprite, transform)); } return quads; }
Example #19
Source File: PerspectiveAwareBakedModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public PerspectiveAwareBakedModel(List<BakedQuad> generalQuads, PerspectiveProperties properties) { this(ImmutableMap.of(), generalQuads, properties); }
Example #20
Source File: BakedQuadVertexBuilder.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public List<BakedQuad> bake() { if (current != null) { throw new IllegalStateException("Not finished building."); } return quadList.stream().map(Quad::bake).collect(Collectors.toList()); }
Example #21
Source File: PerspectiveAwareMultiModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) { return getQuads(state, side, rand, EmptyModelData.INSTANCE); }
Example #22
Source File: ItemQuadBakery.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static List<BakedQuad> bakeItem(TextureAtlasSprite... sprites) { return bakeItem(TransformationMatrix.identity(), sprites); }
Example #23
Source File: AbstractPerspectiveLayeredModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { return getQuads(state, side, rand, EmptyModelData.INSTANCE); }
Example #24
Source File: OverrideListModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { return Collections.emptyList(); }
Example #25
Source File: WrappedItemModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) { return Collections.emptyList(); }
Example #26
Source File: DummyBakedModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { return Collections.emptyList(); }
Example #27
Source File: PerspectiveAwareOverrideModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public PerspectiveAwareOverrideModel(ItemOverrideList overrideList, PerspectiveProperties properties, List<BakedQuad> quads) { super(properties); this.overrideList = overrideList; this.quads = quads; }
Example #28
Source File: PlanarFaceBakery.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static BakedQuad bakeFace(Direction face, TextureAtlasSprite sprite) { return bakeFace(face, sprite, DefaultVertexFormats.BLOCK); }
Example #29
Source File: PerspectiveAwareBakedModel.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public PerspectiveAwareBakedModel(Map<Direction, List<BakedQuad>> faceQuads, List<BakedQuad> generalQuads, PerspectiveProperties properties) { super(properties); this.faceQuads = ImmutableMap.copyOf(faceQuads); this.generalQuads = ImmutableList.copyOf(generalQuads); }
Example #30
Source File: PlanarFaceBakery.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static BakedQuad bakeFace(Direction face, TextureAtlasSprite sprite, VertexFormat format, Colour colour) { UVTransformation t = new IconTransformation(sprite); double x1 = Cuboid6.full.min.x; double x2 = Cuboid6.full.max.x; double y1 = Cuboid6.full.min.y; double y2 = Cuboid6.full.max.y; double z1 = Cuboid6.full.min.z; double z2 = Cuboid6.full.max.z; double u1; double u2; double v1; double v2; Vertex5 vert1; Vertex5 vert2; Vertex5 vert3; Vertex5 vert4; switch (face) { case DOWN: u1 = x1; v1 = z1; u2 = x2; v2 = z2; vert1 = new Vertex5(x1, y1, z2, u1, v2); vert2 = new Vertex5(x1, y1, z1, u1, v1); vert3 = new Vertex5(x2, y1, z1, u2, v1); vert4 = new Vertex5(x2, y1, z2, u2, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); case UP: u1 = x1; v1 = z1; u2 = x2; v2 = z2; vert1 = new Vertex5(x2, y2, z2, u2, v2); vert2 = new Vertex5(x2, y2, z1, u2, v1); vert3 = new Vertex5(x1, y2, z1, u1, v1); vert4 = new Vertex5(x1, y2, z2, u1, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); case NORTH: u1 = 1 - x1; v1 = 1 - y2; u2 = 1 - x2; v2 = 1 - y1; vert1 = new Vertex5(x1, y1, z1, u1, v2); vert2 = new Vertex5(x1, y2, z1, u1, v1); vert3 = new Vertex5(x2, y2, z1, u2, v1); vert4 = new Vertex5(x2, y1, z1, u2, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); case SOUTH: u1 = x1; v1 = 1 - y2; u2 = x2; v2 = 1 - y1; vert1 = new Vertex5(x2, y1, z2, u2, v2); vert2 = new Vertex5(x2, y2, z2, u2, v1); vert3 = new Vertex5(x1, y2, z2, u1, v1); vert4 = new Vertex5(x1, y1, z2, u1, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); case WEST: u1 = z1; v1 = 1 - y2; u2 = z2; v2 = 1 - y1; vert1 = new Vertex5(x1, y1, z2, u2, v2); vert2 = new Vertex5(x1, y2, z2, u2, v1); vert3 = new Vertex5(x1, y2, z1, u1, v1); vert4 = new Vertex5(x1, y1, z1, u1, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); case EAST: u1 = 1 - z1; v1 = 1 - y2; u2 = 1 - z2; v2 = 1 - y1; vert1 = new Vertex5(x2, y1, z1, u1, v2); vert2 = new Vertex5(x2, y2, z1, u1, v1); vert3 = new Vertex5(x2, y2, z2, u2, v1); vert4 = new Vertex5(x2, y1, z2, u2, v2); return VertexDataUtils.buildQuad(format, sprite, face, colour, t, vert1, vert2, vert3, vert4); } return null; }