use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.
the class RenderWaterPad method renderWorldBlockStatic.
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockWaterPad block, EnumFacing side) {
// Icon
final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();
// Check Full
SidedConnection connection = state instanceof IExtendedBlockState ? ((IExtendedBlockState) state).getValue(AgriProperties.CONNECTIONS) : DEFAULT;
// Draw Base
renderBase(tessellator, matIcon);
// Render Sides
for (EnumFacing dir : EnumFacing.HORIZONTALS) {
if (!connection.isConnected(dir)) {
renderSide(tessellator, dir, matIcon);
}
}
// Render Water
if (AgriProperties.POWERED.getValue(state)) {
renderWater(tessellator, waterIcon);
}
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project MinecraftForge by MinecraftForge.
the class OBJModel method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
for (Map.Entry<String, Material> e : matLib.materials.entrySet()) {
if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#")) {
FMLLog.severe("OBJLoader: Unresolved texture '%s' for obj model '%s'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation);
builder.put(e.getKey(), missing);
} else {
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation()));
}
}
builder.put("missingno", missing);
return new OBJBakedModel(this, state, format, builder.build());
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project MinecraftForge by MinecraftForge.
the class ItemLayerModel method bake.
public IBakedModel bake(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
Optional<TRSRTransformation> transform = state.apply(Optional.<IModelPart>absent());
for (int i = 0; i < textures.size(); i++) {
TextureAtlasSprite sprite = bakedTextureGetter.apply(textures.get(i));
builder.addAll(getQuadsForSprite(i, sprite, format, transform));
}
TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
ImmutableMap<TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
return new BakedItemModel(builder.build(), particle, map, overrides, null);
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project MinecraftForge by MinecraftForge.
the class ModelDynBucket method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableMap<TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
// if the fluid is a gas wi manipulate the initial state to be rotated 180° to turn it upside down
if (flipGas && fluid != null && fluid.isGaseous()) {
state = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null)));
}
TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity());
TextureAtlasSprite fluidSprite = null;
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
if (fluid != null) {
fluidSprite = bakedTextureGetter.apply(fluid.getStill());
}
if (baseLocation != null) {
// build base (insidest)
IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
builder.addAll(model.getQuads(null, null, 0));
}
if (liquidLocation != null && fluidSprite != null) {
TextureAtlasSprite liquid = bakedTextureGetter.apply(liquidLocation);
// build liquid layer (inside)
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, NORTH_Z_FLUID, EnumFacing.NORTH, fluid.getColor()));
builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, liquid, fluidSprite, SOUTH_Z_FLUID, EnumFacing.SOUTH, fluid.getColor()));
}
if (coverLocation != null) {
// cover (the actual item around the other two)
TextureAtlasSprite base = bakedTextureGetter.apply(coverLocation);
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, NORTH_Z_BASE, base, EnumFacing.NORTH, 0xffffffff));
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16, 16, SOUTH_Z_BASE, base, EnumFacing.SOUTH, 0xffffffff));
}
return new BakedDynBucket(this, builder.build(), fluidSprite, format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project CodeChickenLib by Chicken-Bones.
the class RenderUtils method renderFluidGauge.
public static void renderFluidGauge(FluidStack stack, Rectangle4i rect, double density, double res) {
if (!shouldRenderFluid(stack))
return;
int alpha = 255;
if (stack.getFluid().isGaseous())
alpha = (int) (fluidDensityToAlpha(density) * 255);
else {
int height = (int) (rect.h * density);
rect.y += rect.h - height;
rect.h = height;
}
TextureAtlasSprite tex = prepareFluidRender(stack, alpha);
CCRenderState.startDrawing();
renderFluidQuad(new Vector3(rect.x, rect.y + rect.h, 0), new Vector3(rect.w, 0, 0), new Vector3(0, -rect.h, 0), tex, res);
CCRenderState.draw();
postFluidRender();
}
Aggregations