use of net.minecraft.client.renderer.block.model.BakedQuad in project ImmersiveEngineering by BluSunrize.
the class ClientUtils method renderModelTESR.
public static void renderModelTESR(List<BakedQuad> quads, VertexBuffer renderer, int brightness) {
int l1 = (brightness >> 0x10) & 0xFFFF;
int l2 = brightness & 0xFFFF;
for (BakedQuad quad : quads) {
int[] vData = quad.getVertexData();
VertexFormat format = quad.getFormat();
int size = format.getIntegerSize();
int uv = format.getUvOffsetById(0) / 4;
for (int i = 0; i < 4; ++i) {
renderer.pos(Float.intBitsToFloat(vData[size * i]), Float.intBitsToFloat(vData[size * i + 1]), Float.intBitsToFloat(vData[size * i + 2])).color(255, 255, 255, 255).tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1])).lightmap(l1, l2).endVertex();
}
}
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project ImmersiveEngineering by BluSunrize.
the class ConveyorCovered method modifyQuads.
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> modifyQuads(List<BakedQuad> baseModel, @Nullable TileEntity tile, EnumFacing facing) {
ItemStack cover = this.cover != null ? this.cover : defaultCover;
Block b = Block.getBlockFromItem(cover.getItem());
IBlockState state = b != null ? b.getStateFromMeta(cover.getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
if (model != null) {
TextureAtlasSprite sprite = model.getParticleTexture();
HashMap<EnumFacing, TextureAtlasSprite> sprites = new HashMap<>();
ConveyorDirection conDir = this.getConveyorDirection();
for (EnumFacing f : EnumFacing.VALUES) for (BakedQuad q : model.getQuads(state, f, 0)) if (q != null && q.getSprite() != null)
sprites.put(f, q.getSprite());
for (BakedQuad q : model.getQuads(state, null, 0)) if (q != null && q.getSprite() != null && q.getFace() != null)
sprites.put(q.getFace(), q.getSprite());
Function<EnumFacing, TextureAtlasSprite> getSprite = f -> sprites.containsKey(f) ? sprites.get(f) : sprite;
Function<EnumFacing, TextureAtlasSprite> getSpriteHorizontal = f -> f.getAxis() == Axis.Y ? null : sprites.containsKey(f) ? sprites.get(f) : sprite;
float[] colour = { 1, 1, 1, 1 };
Matrix4 matrix = new Matrix4(facing);
boolean wallLeft = tile == null || this.renderWall(tile, facing, 0);
boolean wallRight = tile == null || this.renderWall(tile, facing, 1);
Function<Vector3f[], Vector3f[]> vertexTransformer = conDir == ConveyorDirection.HORIZONTAL ? vertices -> vertices : vertices -> {
Vector3f[] ret = new Vector3f[vertices.length];
for (int i = 0; i < ret.length; i++) ret[i] = new Vector3f(vertices[i].x, vertices[i].y + (vertices[i].z == (conDir == ConveyorDirection.UP ? 0 : 1) ? 1 : 0), vertices[i].z);
return ret;
};
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .75f, 0), new Vector3f(1, 1, 1), matrix, facing, vertexTransformer, getSprite, colour));
if (wallLeft)
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, 0), new Vector3f(.0625f, .75f, 1), matrix, facing, vertexTransformer, getSpriteHorizontal, colour));
else {
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, 0), new Vector3f(.0625f, .75f, .0625f), matrix, facing, getSpriteHorizontal, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(0, .1875f, .9375f), new Vector3f(.0625f, .75f, 1), matrix, facing, getSpriteHorizontal, colour));
}
if (wallRight)
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, 0), new Vector3f(1, .75f, 1), matrix, facing, vertexTransformer, getSpriteHorizontal, colour));
else {
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, 0), new Vector3f(1, .75f, .0625f), matrix, facing, getSpriteHorizontal, colour));
baseModel.addAll(ClientUtils.createBakedBox(new Vector3f(.9375f, .1875f, .9375f), new Vector3f(1, .75f, 1), matrix, facing, getSpriteHorizontal, colour));
}
}
return baseModel;
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project BetterWithAddons by DaedalusGame.
the class ModelToolShardInner method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
Optional<TRSRTransformation> transform = state.apply(Optional.empty());
for (int i = 0; i < textures.size(); i++) {
ResourceLocation tex = textures.get(i);
if (tex.toString().equals("minecraft:missingno"))
continue;
TextureAtlasSprite sprite = bakedTextureGetter.apply(tex);
String breakLocation = new ResourceLocation(Reference.MOD_ID, "items/breakmask").toString();
TextureAtlasSprite breakTemplate = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(breakLocation);
builder.addAll(getQuadsForSprite(i, breakTemplate, sprite, format, transform));
// builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, NORTH_Z + Z_OFFSET * i, EnumFacing.NORTH, 0xffffffff));
// builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, SOUTH_Z - Z_OFFSET * i, EnumFacing.SOUTH, 0xffffffff));
}
TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms(state);
return new BakedItemModel(builder.build(), particle, map, null);
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project Charset by CharsetMC.
the class ModelPipeShaped method generateQuads.
protected List<BakedQuad> generateQuads(boolean[] connections, BlockRenderLayer layer) {
List<BakedQuad> quads = new ArrayList<>();
Vector3f from, to;
for (EnumFacing facing : EnumFacing.VALUES) {
EnumFacing[] neighbors = CONNECTION_DIRS[facing.ordinal()];
int connectionMatrix = (connections[neighbors[0].ordinal()] ? 8 : 0) | (connections[neighbors[1].ordinal()] ? 4 : 0) | (connections[neighbors[2].ordinal()] ? 2 : 0) | (connections[neighbors[3].ordinal()] ? 1 : 0);
TextureAtlasSprite sprite = getTexture(facing, layer, connectionMatrix);
float min = 8 - (getThickness(layer) / 2);
float max = 8 + (getThickness(layer) / 2);
int outsideColor = getOutsideColor(facing, layer);
int insideColor = getInsideColor(facing, layer);
if (!isOpaque() && connections[facing.ordinal()]) {
// Connected; render up to four quads.
if (connections[neighbors[2].ordinal()]) {
from = new Vector3f(0, min, min);
to = new Vector3f(min, min, max);
if (RENDER_OUTER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, outsideColor, sprite, EnumFacing.DOWN, ROTATIONS[facing.ordinal()], true));
if (RENDER_INNER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, insideColor, sprite, EnumFacing.UP, ROTATIONS[facing.ordinal()], true));
}
if (connections[neighbors[0].ordinal()]) {
from = new Vector3f(min, min, 0);
to = new Vector3f(max, min, min);
if (RENDER_OUTER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, outsideColor, sprite, EnumFacing.DOWN, ROTATIONS[facing.ordinal()], true));
if (RENDER_INNER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, insideColor, sprite, EnumFacing.UP, ROTATIONS[facing.ordinal()], true));
}
if (connections[neighbors[3].ordinal()]) {
from = new Vector3f(max, min, min);
to = new Vector3f(16, min, max);
if (RENDER_OUTER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, outsideColor, sprite, EnumFacing.DOWN, ROTATIONS[facing.ordinal()], true));
if (RENDER_INNER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, insideColor, sprite, EnumFacing.UP, ROTATIONS[facing.ordinal()], true));
}
if (connections[neighbors[1].ordinal()]) {
from = new Vector3f(min, min, max);
to = new Vector3f(max, min, 16);
if (RENDER_OUTER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, outsideColor, sprite, EnumFacing.DOWN, ROTATIONS[facing.ordinal()], true));
if (RENDER_INNER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, insideColor, sprite, EnumFacing.UP, ROTATIONS[facing.ordinal()], true));
}
} else {
// Not connected; render one quad.
from = new Vector3f(connections[neighbors[2].ordinal()] ? 0 : min, min, connections[neighbors[0].ordinal()] ? 0 : min);
to = new Vector3f(connections[neighbors[3].ordinal()] ? 16 : max, min, connections[neighbors[1].ordinal()] ? 16 : max);
if (RENDER_OUTER_FACES)
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, outsideColor, sprite, EnumFacing.DOWN, ROTATIONS[facing.ordinal()], true));
if (RENDER_INNER_FACES && !isOpaque()) {
quads.add(RenderUtils.BAKERY.makeBakedQuad(from, to, insideColor, sprite, EnumFacing.UP, ROTATIONS[facing.ordinal()], true));
}
}
}
return quads;
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project Charset by CharsetMC.
the class ProxyClient method onModelBake.
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
IBakedModel origModel = event.getModelRegistry().getObject(bmLoc);
ModelCompressionCrafter result = new ModelCompressionCrafter(origModel);
event.getModelRegistry().putObject(bmLoc, result);
ProgressManager.ProgressBar bar = ProgressManager.push("Compression Crafter", 6 + (4 * 12));
IModel modelRod = RenderUtils.getModel(new ResourceLocation("charset:block/compression_crafter_rod"));
for (EnumFacing side : EnumFacing.VALUES) {
bar.step("rod " + side.name());
rodModels[side.ordinal()] = modelRod.bake(ROTATIONS[side.ordinal()], DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
}
IModel model = RenderUtils.getModel(new ResourceLocation("charset:block/compression_crafter_block"));
IBlockState defState = CharsetCraftingCompression.blockCompressionCrafter.getDefaultState();
for (int i = 0; i < 4; i++) {
IModel retexModel = model.retexture(ImmutableMap.of("top", "charset:blocks/compact/compact_inner#" + i, "bottom", "charset:blocks/compact/compact_bottom#" + i, "side_x", "charset:blocks/compact/compact_side#" + i, "side_z", "charset:blocks/compact/compact_side#" + i));
for (int k = 0; k < 12; k++) {
bar.step("crafter " + (i * 4 + k + 1) + "/48");
if (i == 0 && k >= 6) {
for (EnumFacing side : EnumFacing.VALUES) {
result.quads[k][side.ordinal()][i] = result.quads[k - 6][side.ordinal()][i];
}
continue;
}
EnumFacing facing = EnumFacing.getFront(k % 6);
IModelState modelState = ROTATIONS[k % 6];
if (k >= 6) {
modelState = new ModelStateComposition(modelState, ModelRotation.X0_Y90);
}
IBakedModel bakedModel = retexModel.bake(modelState, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
for (EnumFacing side : EnumFacing.VALUES) {
List<BakedQuad> list = bakedModel.getQuads(defState, side, 0);
int j = i;
if ((facing == EnumFacing.DOWN && (side == EnumFacing.SOUTH || side == EnumFacing.WEST)) || (facing == EnumFacing.UP && (side == EnumFacing.NORTH || side == EnumFacing.EAST)) || ((facing == EnumFacing.SOUTH || facing == EnumFacing.WEST) && (side.getAxis() == EnumFacing.Axis.Y || (side.getAxis() == facing.getAxis() && k < 8))) || (facing == EnumFacing.DOWN && side == EnumFacing.UP && k >= 6) || (facing.getAxis() != EnumFacing.Axis.Y && k >= 8 && side == facing.rotateY())) {
if (j == 1)
j = 2;
else if (j == 2)
j = 1;
}
result.quads[k][side.ordinal()][j] = list.get(0);
}
}
}
ProgressManager.pop(bar);
}
Aggregations