Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void renderMissing(PlayerEntity player, ItemStack stack, IBuildView view, RenderSorter sorter) {
- int energyCost = ((GadgetCopyPaste) stack.getItem()).getEnergyCost(stack);
- IItemIndex index = InventoryHelper.index(stack, player);
- boolean overwrite = Config.GENERAL.allowOverwriteBlocks.get();
- BlockItemUseContext useContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, VectorHelper.getLookingAt(player, stack)));
- InvertedPlacementEvaluator evaluator = new InvertedPlacementEvaluator(
- sorter.getOrderedTargets(),
- new PlacementChecker(
- stack.getCapability(CapabilityEnergy.ENERGY).map(SimulateEnergyStorage::new),
- t -> energyCost,
- index,
- (c, t) -> overwrite ? c.getWorld().getBlockState(t.getPos()).isReplaceable(useContext) : c.getWorld().isAirBlock(t.getPos()),
- false),
- view.getContext());
- //GL14.glBlendColor(1F, 1F, 1F, 0.35f); //Set the alpha of the blocks we are rendering
- //GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0001F);
- BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
- GlStateManager.disableTexture();
- GlStateManager.depthMask(false);
- bufferBuilder.begin(GL14.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
- BlockState redGlass = Blocks.RED_STAINED_GLASS.getDefaultState();
- Random rand = new Random();
- for (PlacementTarget target : evaluator) { //Now run through the UNSORTED list of coords, to show which blocks won't place if you don't have enough of them.
- GlStateManager.pushMatrix();//Push matrix again just because
- BlockPos pos = target.getPos();
- /*GlStateManager.translatef(pos.getX(), pos.getY(), pos.getZ());//Now move the render position to the coordinates we want to render at
- GlStateManager.rotatef(- 90.0F, 0.0F, 1.0F, 0.0F); //Rotate it because i'm not sure why but we need to
- GlStateManager.translatef(- 0.005f, - 0.005f, 0.005f);*/
- //GlStateManager.scalef(1.01f, 1.01f, 1.01f);
- renderBox(bufferBuilder, pos);
- //getMc().getBlockRendererDispatcher().renderBlock(redGlass, pos, player.world, bufferBuilder, rand, EmptyModelData.INSTANCE);
- //getMc().getBlockRendererDispatcher().renderBlockBrightness(Blocks.RED_STAINED_GLASS.getDefaultState(), 1f);
- //Move the render position back to where it was
- GlStateManager.popMatrix();
- }
- Tessellator.getInstance().draw();
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture();
- }
- private void renderBox(BufferBuilder bufferBuilder, BlockPos pos) {
- float red = 1;
- float green = 0;
- float blue = 0;
- float alpha = 0.5f;
- double x = pos.getX()-0.001;
- double y = pos.getY()-0.001;
- double z = pos.getZ()-0.001;
- double xEnd = pos.getX()+1.001;
- double yEnd = pos.getY()+1.001;
- double zEnd = pos.getZ()+1.001;
- //front-side
- bufferBuilder.pos(x, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, yEnd, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, z).color(red, green, blue, alpha).endVertex();
- //left-side
- bufferBuilder.pos(x, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, y, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, z).color(red, green, blue, alpha).endVertex();
- //bottom
- bufferBuilder.pos(x, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, y, zEnd).color(red, green, blue, alpha).endVertex();
- //top
- bufferBuilder.pos(xEnd, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, yEnd, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- //right-side
- bufferBuilder.pos(xEnd, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, yEnd, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, z).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, zEnd).color(red, green, blue, alpha).endVertex();
- //back-side
- bufferBuilder.pos(xEnd, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, yEnd, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(x, y, zEnd).color(red, green, blue, alpha).endVertex();
- bufferBuilder.pos(xEnd, y, zEnd).color(red, green, blue, alpha).endVertex();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement