use of net.minecraft.client.renderer.block.model.IBakedModel in project Railcraft by Railcraft.
the class JSONModelRenderer method renderModel.
public void renderModel(ResourceLocation model) {
IBakedModel bakedModel = bakedModels.get(model);
if (bakedModel == null)
return;
Minecraft mc = Minecraft.getMinecraft();
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
Tessellator tess = Tessellator.getInstance();
BufferBuilder buffer = tess.getBuffer();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
putQuads(buffer, bakedModel.getQuads(null, null, 1234));
for (EnumFacing side : EnumFacing.VALUES) {
putQuads(buffer, bakedModel.getQuads(null, side, 1234));
}
tess.draw();
mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project Railcraft by Railcraft.
the class CartContentRendererCargo method renderCargo.
public void renderCargo(RenderCart renderer, EntityCartCargo cart) {
if (!cart.hasFilter())
return;
OpenGL.glPushMatrix();
OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
OpenGL.glPushAttrib(GL11.GL_LIGHTING_BIT);
OpenGL.glEnable(GL11.GL_LIGHTING);
OpenGL.glDisable(GL11.GL_BLEND);
EntityItem item = new EntityItem(cart.getEntityWorld(), 0.0D, 0.0D, 0.0D, cart.getFilterItem().copy());
setSize(item.getItem(), 1);
item.hoverStart = 0.0F;
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(item.getItem(), cart.world, null);
boolean renderIn3D = model.isGui3d();
int numIterations;
float yOffset;
float scale;
float xScale;
float zScale;
if (renderIn3D) {
xScale = 0.3f;
zScale = 0.2F;
scale = 2.5F;
int slotsFilled = cart.getSlotsFilled();
if (slotsFilled <= 0) {
numIterations = 0;
} else {
numIterations = (int) Math.ceil(slotsFilled / 2f);
numIterations = MathHelper.clamp(numIterations, 1, 6);
}
yOffset = -1.1F;
} else {
xScale = 0.5f;
zScale = 0.6F;
scale = 1.6F;
numIterations = cart.getSlotsFilled();
yOffset = -0.8F;
}
OpenGL.glTranslatef(0.0F, yOffset, 0.0F);
OpenGL.glScalef(scale, scale, scale);
OpenGL.glRotatef(90.F, 0.0F, 1.0F, 0.0F);
rand.setSeed(cart.getEntityId());
for (int i = 0; i < numIterations; i++) {
OpenGL.glPushMatrix();
float tx = (float) (rand.nextDouble() - 0.5F) * xScale;
float ty = (float) (rand.nextDouble() - 0.5F) * 0.15F;
float tz = (float) (rand.nextDouble() - 0.5F) * zScale;
OpenGL.glTranslatef(tx, ty, tz);
renderEntityItem(renderer.getRenderManager(), item);
OpenGL.glPopMatrix();
}
OpenGL.glPopAttrib();
OpenGL.glPopAttrib();
OpenGL.glPopMatrix();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project BiomesOPlenty by Glitchfiend.
the class ModelUtils method generateModelsForTextures.
public static IBakedModel[] generateModelsForTextures(IModel model, TextureAtlasSprite[] textures) {
IBakedModel[] output = new IBakedModel[textures.length];
for (int i = 0; i < output.length; i++) {
final TextureAtlasSprite texture = textures[i];
// Defines how TextureAtlasSprites are obtained whilst baking
Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
public TextureAtlasSprite apply(ResourceLocation location) {
return texture;
}
};
output[i] = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);
}
return output;
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project LogisticsPipes by RS485.
the class LogisticsBlockModel method bake.
@Nonnull
@Override
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
final List<BakedQuad> quads = Lists.newArrayList();
TextureAtlasSprite inactiveT = bakedTextureGetter.apply(inactive);
TextureAtlasSprite activeT = bakedTextureGetter.apply(active);
return new IBakedModel() {
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side == null) {
if (quads.isEmpty()) {
quads.addAll(LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generateBlockRenderList(state, inactiveT, activeT), format, true));
}
return quads;
} else {
// LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generateBlockRenderList(state), format);
return Collections.emptyList();
}
}
@Override
public boolean isAmbientOcclusion() {
return false;
}
@Override
public boolean isGui3d() {
return true;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
@Nonnull
public TextureAtlasSprite getParticleTexture() {
return inactiveT;
}
@Override
@Nonnull
public ItemOverrideList getOverrides() {
return ItemOverrideList.NONE;
}
@Override
@Nonnull
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
return PerspectiveMapWrapper.handlePerspective(this, SimpleServiceLocator.cclProxy.getDefaultBlockState(), cameraTransformType);
}
};
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class ClientProxy method drawFluidPumpTop.
@Override
public void drawFluidPumpTop() {
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = IEContent.blockMetalDevice0.getStateFromMeta(BlockTypes_MetalDevice0.FLUID_PUMP.getMeta());
state = state.withProperty(IEProperties.MULTIBLOCKSLAVE, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, 1);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, .75f, false);
GlStateManager.popMatrix();
}
Aggregations