use of se.gory_moon.horsepower.blocks.BlockHPBase in project HorsePower by GoryMoon.
the class TileEntityHandGrindstoneRender method render.
@Override
public void render(TileEntityHandGrindstone te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
IBlockState centerState = blockState.withProperty(BlockHandGrindstone.PART, HandGrindstoneModels.CENTER);
if (!(centerState.getBlock() instanceof BlockHPBase))
return;
IBakedModel centerModel = dispatcher.getBlockModelShapes().getModelForState(centerState);
preDestroyRender(destroyStage);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
// This makes the translations that follow much easier
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
if (destroyStage >= 0) {
buffer.noColor();
renderBlockDamage(centerState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
} else
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), centerModel, centerState, te.getPos(), buffer, false);
buffer.setTranslation(0, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
GlStateManager.translate(0.5, 0.5, 0.5);
FacingToRotation.get(te.getForward()).glRotateCurrentMat();
float rotation = te.getVisibleRotation();
GlStateManager.rotate(rotation, 0, 1, 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
postDestroyRender(destroyStage);
RenderHelper.enableStandardItemLighting();
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(0), x, y, z, 0.8F, 0.7F, 0.5F, 0.7F);
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(1), x, y, z, 0.2F, 0.7F, 0.5F, 0.7F);
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(2), x, y, z, 0.5F, 0.7F, 0.2F, 0.7F);
super.render(te, x, y, z, partialTicks, destroyStage, alpha);
}
use of se.gory_moon.horsepower.blocks.BlockHPBase in project HorsePower by GoryMoon.
the class TileEntityPressRender method render.
@Override
public void render(TileEntityPress te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
IBlockState topState = blockState.withProperty(BlockPress.PART, PressModels.TOP);
if (!(topState.getBlock() instanceof BlockHPBase))
return;
IBakedModel pressModel = dispatcher.getBlockModelShapes().getModelForState(topState);
preDestroyRender(destroyStage);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
// This makes the translations that follow much easier
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
if (destroyStage >= 0) {
buffer.noColor();
renderBlockDamage(topState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
} else
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), pressModel, blockState, te.getPos(), buffer, false);
buffer.setTranslation(0, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
float move = (te.getField(0) / (float) (Configs.general.pointsForPress > 0 ? Configs.general.pointsForPress : 1));
GlStateManager.translate(0.5, 0.5, 0.5);
GlStateManager.translate(0, -(0.58 * move), 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
postDestroyRender(destroyStage);
RenderHelper.enableStandardItemLighting();
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
if (te.hasWorker())
renderLeash(te.getWorker(), x, y, z, 0D, 0.4D, 0D, partialTicks, te.getPos());
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (!te.getStackInSlot(0).isEmpty() && move <= 0.25) {
renderItem(te, te.getStackInSlot(0), 0.5F, 0.5F, 0.5F, 1F);
drawString(te, String.valueOf(te.getStackInSlot(0).getCount()), 0, 0.35, 0);
}
if (!te.getStackInSlot(1).isEmpty() && move <= 0.25) {
renderItem(te, te.getStackInSlot(1), 0.5F, 0.5F, 0.5F, 1F);
drawString(te, String.valueOf(te.getStackInSlot(1).getCount()), 0, 0.35, 0);
}
GlStateManager.popMatrix();
super.render(te, x, y + 1, z, partialTicks, destroyStage, alpha);
}
use of se.gory_moon.horsepower.blocks.BlockHPBase in project HorsePower by GoryMoon.
the class TileEntityFiller method getFilledPos.
public BlockPos getFilledPos() {
IBlockState state = getWorld().getBlockState(getPos());
if (!(state.getBlock() instanceof BlockFiller))
return getPos();
EnumFacing facing = state.getValue(BlockDirectional.FACING);
IBlockState state1 = getWorld().getBlockState(pos.offset(facing));
if (!(state1.getBlock() instanceof BlockHPBase))
return getPos();
return pos.offset(facing);
}
use of se.gory_moon.horsepower.blocks.BlockHPBase in project HorsePower by GoryMoon.
the class TileEntityGrindstoneRender method render.
@Override
public void render(TileEntityGrindstone te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
ItemStack outputStack = te.getStackInSlot(1);
ItemStack secondaryStack = te.getStackInSlot(2);
if (outputStack.getCount() < secondaryStack.getCount())
outputStack = secondaryStack;
if (blockState.getValue(BlockGrindstone.FILLED)) {
IBlockState filledState = blockState.withProperty(BlockGrindstone.PART, GrindStoneModels.FILLED);
if (!(filledState.getBlock() instanceof BlockHPBase))
return;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBakedModel filledModel = dispatcher.getBlockModelShapes().getModelForState(filledState);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), filledModel, filledState, te.getPos(), buffer, false);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.translate(0.5, 0.5, 0.5);
float maxStackSize = outputStack.getMaxStackSize() > 0 ? outputStack.getMaxStackSize() : 1F;
float fillState = 0.23F * (((float) outputStack.getCount()) / maxStackSize);
GlStateManager.translate(0, -0.187 + fillState, 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
RenderHelper.enableStandardItemLighting();
} else if (outputStack.isEmpty()) {
te.renderStack = ItemStack.EMPTY;
te.grindColor = null;
}
if (te.hasWorker())
renderLeash(te.getWorker(), x, y, z, 0D, 0D, 0D, partialTicks, te.getPos());
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (!te.getStackInSlot(0).isEmpty()) {
renderItem(te, te.getStackInSlot(0), 0.5F, 1F, 0.5F, 1F);
if (getWorld().isAirBlock(te.getPos().up()))
drawString(te, String.valueOf(te.getStackInSlot(0).getCount()), 0, 0.35, 0);
}
GlStateManager.popMatrix();
super.render(te, x, y, z, partialTicks, destroyStage, alpha);
}
use of se.gory_moon.horsepower.blocks.BlockHPBase in project HorsePower by GoryMoon.
the class TileEntityChopperRender method render.
@Override
public void render(TileEntityChopper te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
IBlockState bladeState = blockState.withProperty(BlockChopper.PART, ChopperModels.BLADE);
if (!(bladeState.getBlock() instanceof BlockHPBase))
return;
IBakedModel bladeModel = dispatcher.getBlockModelShapes().getModelForState(bladeState);
preDestroyRender(destroyStage);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
// This makes the translations that follow much easier
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
if (destroyStage >= 0) {
buffer.noColor();
renderBlockDamage(bladeState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
} else
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), bladeModel, blockState, te.getPos(), buffer, false);
buffer.setTranslation(0, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
GlStateManager.translate(0.5, 0.5, 0.5);
GlStateManager.translate(0, te.getVisualWindup(), 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
postDestroyRender(destroyStage);
RenderHelper.enableStandardItemLighting();
renderLeach(x + 0.5, y + 2.9 + te.getVisualWindup(), z + 0.5, x + 0.5, y + 0.2, z + 0.5, x + 0.5, y + 1.7, z + 0.5);
if (te.hasWorker())
renderLeash(te.getWorker(), x, y, z, 0D, 1.1D, 0D, partialTicks, te.getPos());
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (!te.getStackInSlot(0).isEmpty())
renderStillItem(te, te.getStackInSlot(0), 0.5F, 0.54F, 0.5F, 1.3F);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (!te.getStackInSlot(1).isEmpty())
renderStillItem(te, te.getStackInSlot(1), 0.5F, 0.54F, 0.5F, 1.3F);
GlStateManager.popMatrix();
super.render(te, x, y + 1, z, partialTicks, destroyStage, alpha);
}
Aggregations