use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.
the class TileRenderBucketWheel method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBucketWheel tile, double x, double y, double z, float f, int destroyStage) {
if (!tile.formed || !tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.isDummy())
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
if (model == null) {
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
model = blockRenderer.getModelForState(state);
}
OBJState objState = null;
HashMap<String, String> texMap = new HashMap<>();
if (state instanceof IExtendedBlockState) {
ArrayList<String> list = Lists.newArrayList("bucketWheel");
synchronized (tile.digStacks) {
for (int i = 0; i < tile.digStacks.length; i++) if (tile.digStacks[i] != null) {
list.add("dig" + i);
Block b = Block.getBlockFromItem(tile.digStacks[i].getItem());
IBlockState digState = b != null ? b.getStateFromMeta(tile.digStacks[i].getMetadata()) : Blocks.STONE.getDefaultState();
IBakedModel digModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(digState);
if (digModel != null && digModel.getParticleTexture() != null)
texMap.put("dig" + i, digModel.getParticleTexture().getIconName());
}
}
objState = new OBJState(list, true);
}
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
EnumFacing facing = tile.facing;
if (tile.mirrored) {
GlStateManager.scale(facing.getAxis() == Axis.X ? -1 : 1, 1, facing.getAxis() == Axis.Z ? -1 : 1);
GlStateManager.disableCull();
}
float dir = tile.facing == EnumFacing.SOUTH ? 90 : tile.facing == EnumFacing.NORTH ? -90 : tile.facing == EnumFacing.EAST ? 180 : 0;
GlStateManager.rotate(dir, 0, 1, 0);
float rot = tile.rotation + (float) (tile.active ? IEConfig.Machines.excavator_speed * f : 0);
GlStateManager.rotate(rot, 1, 0, 0);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5, -.5, -.5);
List<BakedQuad> quads;
if (model instanceof IESmartObjModel)
quads = ((IESmartObjModel) model).getQuads(state, null, 0, objState, texMap, true);
else
quads = model.getQuads(state, null, 0);
ClientUtils.renderModelTESR(quads, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.enableCull();
if (tile.mirrored) {
GlStateManager.enableCull();
}
}
use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.
the class TileRenderBelljar method render.
@Override
public void render(TileEntityBelljar tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (tile.dummy != 0 || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = tile.getPos();
if (!quads.containsKey(tile.getFacing())) {
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalDevice1)
return;
state = state.getActualState(getWorld(), blockPos);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList("glass"), true));
quads.put(tile.getFacing(), model.getQuads(state, null, 0));
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
GlStateManager.enableCull();
IPlantHandler plantHandler = tile.getCurrentPlantHandler();
if (plantHandler != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 1.0625, 0);
GlStateManager.color(1, 1, 1, 1);
NonNullList<ItemStack> inventory = tile.getInventory();
float scale = plantHandler.getRenderSize(inventory.get(1), inventory.get(0), tile.renderGrowth, tile);
GlStateManager.translate((1 - scale) / 2, 0, (1 - scale) / 2);
GlStateManager.scale(scale, scale, scale);
if (!plantHandler.overrideRender(inventory.get(1), inventory.get(0), tile.renderGrowth, tile, blockRenderer)) {
IBlockState[] states = plantHandler.getRenderedPlant(inventory.get(1), inventory.get(0), tile.renderGrowth, tile);
if (states == null || states.length < 1)
return;
for (IBlockState s : states) {
List<BakedQuad> plantQuadList = plantQuads.get(s);
if (plantQuadList == null) {
IBakedModel plantModel = blockRenderer.getModelForState(s);
plantQuadList = new ArrayList<BakedQuad>(plantModel.getQuads(s, null, 0));
for (EnumFacing f : EnumFacing.values()) plantQuadList.addAll(plantModel.getQuads(s, f, 0));
plantQuads.put(s, plantQuadList);
}
if (plantQuadList != null) {
GlStateManager.pushMatrix();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESRFancy(plantQuadList, worldRenderer, tile.getWorld(), blockPos, false);
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
GlStateManager.translate(0, 1, 0);
}
}
}
GlStateManager.popMatrix();
}
GlStateManager.depthMask(false);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESRFast(quads.get(tile.getFacing()), worldRenderer, tile.getWorld(), blockPos);
Tessellator.getInstance().draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.
the class TileRenderBucketWheel method render.
@Override
public void render(TileEntityBucketWheel tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (!tile.formed || !tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.isDummy())
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
if (model == null) {
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
state = state.withProperty(IEProperties.FACING_HORIZONTAL, EnumFacing.NORTH);
model = blockRenderer.getModelForState(state);
}
OBJState objState = null;
HashMap<String, String> texMap = new HashMap<>();
if (state instanceof IExtendedBlockState) {
ArrayList<String> list = Lists.newArrayList("bucketWheel");
synchronized (tile.digStacks) {
for (int i = 0; i < tile.digStacks.size(); i++) if (!tile.digStacks.get(i).isEmpty()) {
list.add("dig" + i);
Block b = Block.getBlockFromItem(tile.digStacks.get(i).getItem());
IBlockState digState = b != Blocks.AIR ? b.getStateFromMeta(tile.digStacks.get(i).getMetadata()) : Blocks.COBBLESTONE.getDefaultState();
IBakedModel digModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(digState);
if (digModel != null && digModel.getParticleTexture() != null)
texMap.put("dig" + i, digModel.getParticleTexture().getIconName());
}
}
objState = new OBJState(list, true);
}
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
EnumFacing facing = tile.facing;
if (tile.mirrored) {
GlStateManager.scale(facing.getAxis() == Axis.X ? -1 : 1, 1, facing.getAxis() == Axis.Z ? -1 : 1);
GlStateManager.disableCull();
}
float dir = tile.facing == EnumFacing.SOUTH ? 90 : tile.facing == EnumFacing.NORTH ? -90 : tile.facing == EnumFacing.EAST ? 180 : 0;
GlStateManager.rotate(dir, 0, 1, 0);
float rot = tile.rotation + (float) (tile.active ? IEConfig.Machines.excavator_speed * partialTicks : 0);
GlStateManager.rotate(rot, 1, 0, 0);
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
BufferBuilder worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5, -.5, -.5);
List<BakedQuad> quads;
if (model instanceof IESmartObjModel)
quads = ((IESmartObjModel) model).getQuads(state, null, 0, objState, texMap, true);
else
quads = model.getQuads(state, null, 0);
ClientUtils.renderModelTESRFast(quads, worldRenderer, tile.getWorld(), tile.getPos());
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.enableCull();
if (tile.mirrored) {
GlStateManager.enableCull();
}
}
use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.
the class TileRenderAutoWorkbench method renderModelPart.
public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, BufferBuilder worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
}
use of net.minecraftforge.client.model.obj.OBJModel.OBJState in project ImmersiveEngineering by BluSunrize.
the class TileRenderSampleDrill method render.
@Override
public void render(TileEntitySampleDrill tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
if (tile.isDummy() || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
BlockPos blockPos = tile.getPos();
IBakedModel model = blockRenderer.getModelForState(state);
if (state.getBlock() != IEContent.blockMetalDevice1)
return;
// .getModelFromBlockState(state, getWorld(), blockPos);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Lists.newArrayList("drill"), true));
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldRenderer = tessellator.getBuffer();
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
// float rot = 360*tile.rotation-(!tile.canTurn||tile.rotation==0||tile.rotation-tile.prevRotation<4?0:tile.facing.getAxis()==Axis.X?-f:f);
// GlStateManager.rotate(rot, 0,0,1);
int max = IEConfig.Machines.coredrill_time;
if (tile.process > 0 && tile.process < max) {
GlStateManager.rotate(((tile.process + partialTicks) * 22.5f) % 360f, 0, 1, 0);
float push = tile.process / (float) max;
if (tile.process > max / 2)
push = 1 - push;
GlStateManager.translate(0, -2.8f * push, 0);
}
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(tile.getWorld(), model, state, tile.getPos(), worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
Aggregations