use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ApiUtils method getRegisterSprite.
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite getRegisterSprite(TextureMap map, String path) {
TextureAtlasSprite sprite = map.getTextureExtry(path);
if (sprite == null) {
map.registerSprite(new ResourceLocation(path));
sprite = map.getTextureExtry(path);
}
return sprite;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ApiUtils method getRegisterSprite.
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite getRegisterSprite(TextureMap map, ResourceLocation path) {
TextureAtlasSprite sprite = map.getTextureExtry(path.toString());
if (sprite == null) {
map.registerSprite(path);
sprite = map.getTextureExtry(path.toString());
}
return sprite;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ModelConfigurableSides method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
TextureAtlasSprite[] tex = new TextureAtlasSprite[6];
for (int i = 0; i < tex.length; i++) tex[i] = this.textures[i][0];
char[] keyArray = "000000".toCharArray();
if (state instanceof IExtendedBlockState) {
IExtendedBlockState extended = (IExtendedBlockState) state;
for (int i = 0; i < IEProperties.SIDECONFIG.length; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i])) {
IEEnums.SideConfig config = extended.getValue(IEProperties.SIDECONFIG[i]);
if (config != null) {
int c = config.ordinal();
tex[i] = this.textures[i][c];
keyArray[i] = Character.forDigit(c, 10);
}
}
}
String key = name + String.copyValueOf(keyArray);
if (!modelCache.containsKey(key))
modelCache.put(key, bakeQuads(tex));
return modelCache.get(key);
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project ImmersiveEngineering by BluSunrize.
the class ClientUtils method drawRepeatedFluidSprite.
public static void drawRepeatedFluidSprite(FluidStack fluid, float x, float y, float w, float h) {
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE.toString());
TextureAtlasSprite sprite = mc().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill(fluid).toString());
if (sprite != null) {
int col = fluid.getFluid().getColor(fluid);
GlStateManager.color((col >> 16 & 255) / 255.0f, (col >> 8 & 255) / 255.0f, (col & 255) / 255.0f, 1);
int iW = sprite.getIconWidth();
int iH = sprite.getIconHeight();
if (iW > 0 && iH > 0)
drawRepeatedSprite(x, y, w, h, iW, iH, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
}
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite 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;
}
Aggregations