Search in sources :

Example 1 with IStructure

use of com.teamwizardry.wizardry.api.block.IStructure in project Wizardry by TeamWizardry.

the class TileManaBatteryRenderer method render.

@Override
public void render(float partialTicks, int destroyStage, float alpha) {
    super.render(partialTicks, destroyStage, alpha);
    if (!getBakedModels())
        return;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    TextureManager texturemanager = Minecraft.getMinecraft().renderEngine;
    if (texturemanager != null) {
        texturemanager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    }
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    else
        GlStateManager.shadeModel(GL11.GL_FLAT);
    CapManager manager = new CapManager(tile.getWizardryCap());
    float fill = (float) (manager.getMana() / manager.getMaxMana()) / 50.0f;
    GlStateManager.translate(0, 0.5, 0);
    GlStateManager.disableRescaleNormal();
    {
        double x = RandUtil.nextDouble(-fill, fill), y = RandUtil.nextDouble(-fill, fill), z = RandUtil.nextDouble(-fill, fill);
        GlStateManager.translate(0, Math.sin((tile.getWorld().getTotalWorldTime() + ClientTickHandler.getPartialTicks()) / 40) / 8, 0);
        GlStateManager.translate(x, y, z);
        Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelCrystal, 1.0F, 1, 1, 1);
        GlStateManager.translate(-x, -y, -z);
    }
    GlStateManager.translate(0.5, 0, 0.5);
    GlStateManager.rotate(tile.getWorld().getTotalWorldTime() + ClientTickHandler.getPartialTicks(), 0, 1, 0);
    GlStateManager.translate(-0.5, 0, -0.5);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelRing, 1.0F, 1, 1, 1);
    GlStateManager.translate(0.5, 0, 0.5);
    GlStateManager.rotate(tile.getWorld().getTotalWorldTime() + ClientTickHandler.getPartialTicks(), 0, -1, 0);
    GlStateManager.rotate(tile.getWorld().getTotalWorldTime() + ClientTickHandler.getPartialTicks(), 0, -1, 0);
    GlStateManager.translate(-0.5, 0, -0.5);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelRingOuter, 1.0F, 1, 1, 1);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
    HashSet<BlockPos> errors = ((IStructure) tile.getBlockType()).getErroredBlocks(tile.getWorld(), tile.getPos());
    if (tile.revealStructure && tile.getBlockType() instanceof IStructure && !errors.isEmpty()) {
        IStructure structure = ((IStructure) tile.getBlockType());
        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(1f, -0.05f);
        GlStateManager.translate(-structure.offsetToCenter().getX(), -structure.offsetToCenter().getY(), -structure.offsetToCenter().getZ());
        Minecraft mc = Minecraft.getMinecraft();
        Tessellator tes = Tessellator.getInstance();
        BufferBuilder buffer = tes.getBuffer();
        mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        for (BlockRenderLayer layer : cachedStructure.blocks.keySet()) {
            buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
            buffer.addVertexData(cachedStructure.vboCaches.get(layer));
            for (int i = 0; i < buffer.getVertexCount(); i++) {
                int idx = buffer.getColorIndex(i + 1);
                buffer.putColorRGBA(idx, 255, 255, 255, 200);
            }
            tes.draw();
        }
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GlStateManager.enableDepth();
        GlStateManager.popMatrix();
    } else if (!tile.revealStructure && !errors.isEmpty()) {
        for (BlockPos error : errors) StructureErrorRenderer.INSTANCE.addError(error);
    }
    if (tile.getBlockType() == ModBlocks.CREATIVE_MANA_BATTERY) {
        double angle = tile.getWorld().getTotalWorldTime() / 10.0;
        double x1 = Math.cos((float) angle);
        double y1 = Math.sin((float) angle);
        ParticleBuilder builder = new ParticleBuilder(10);
        builder.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        builder.setCollision(true);
        builder.disableRandom();
        builder.disableMotionCalculation();
        ParticleSpawner.spawn(builder, tile.getWorld(), new InterpCircle(new Vec3d(tile.getPos()).addVector(0.5, 0.5, 0.5), new Vec3d(x1, x1, y1), 1.5f), 20, 0, (aFloat, particleBuilder) -> {
            particleBuilder.setScale(0.5f);
            particleBuilder.setColor(new Color(0xd600d2));
            particleBuilder.setAlphaFunction(new InterpFadeInOut(1, 1));
            particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
        });
    }
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IStructure(com.teamwizardry.wizardry.api.block.IStructure) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) Minecraft(net.minecraft.client.Minecraft) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) CapManager(com.teamwizardry.wizardry.api.capability.CapManager) TextureManager(net.minecraft.client.renderer.texture.TextureManager) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) BlockRenderLayer(net.minecraft.util.BlockRenderLayer)

Example 2 with IStructure

use of com.teamwizardry.wizardry.api.block.IStructure in project Wizardry by TeamWizardry.

the class TileCraftingPlateRenderer method render.

@Override
public void render(float partialTicks, int destroyStage, float alpha) {
    HashSet<BlockPos> errors = ((IStructure) tile.getBlockType()).getErroredBlocks(tile.getWorld(), tile.getPos());
    if (tile.revealStructure && tile.getBlockType() instanceof IStructure && !errors.isEmpty()) {
        IStructure structure = ((IStructure) tile.getBlockType());
        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(1f, -0.05f);
        GlStateManager.translate(-structure.offsetToCenter().getX(), -structure.offsetToCenter().getY(), -structure.offsetToCenter().getZ());
        Minecraft mc = Minecraft.getMinecraft();
        Tessellator tes = Tessellator.getInstance();
        BufferBuilder buffer = tes.getBuffer();
        mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        for (BlockRenderLayer layer : cachedStructure.blocks.keySet()) {
            buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
            buffer.addVertexData(cachedStructure.vboCaches.get(layer));
            for (int i = 0; i < buffer.getVertexCount(); i++) {
                int idx = buffer.getColorIndex(i + 1);
                buffer.putColorRGBA(idx, 255, 255, 255, 200);
            }
            tes.draw();
        }
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GlStateManager.enableDepth();
        GlStateManager.popMatrix();
        return;
    } else if (!tile.revealStructure && !errors.isEmpty()) {
        for (BlockPos error : errors) StructureErrorRenderer.INSTANCE.addError(error);
    }
    // render each item at its current position
    for (int i = 0; i < index; i++) {
        ItemStack stack = tile.realInventory.getHandler().getStackInSlot(i);
        LocationAndAngle locationsAndAngle = locationsAndAngles[i];
        if (!stack.isEmpty() && locationsAndAngle != null) {
            {
                GlStateManager.pushMatrix();
                GlStateManager.translate(0.5 + locationsAndAngle.location.x, 1 + locationsAndAngle.location.y, 0.5 + locationsAndAngle.location.z);
                GlStateManager.scale(0.3, 0.3, 0.3);
                GlStateManager.rotate((locationsAndAngle.randX + tile.getWorld().getTotalWorldTime()) + ClientTickHandler.getPartialTicks(), 0, 1, 0);
                GlStateManager.rotate((locationsAndAngle.randY + tile.getWorld().getTotalWorldTime()) + ClientTickHandler.getPartialTicks(), 1, 0, 0);
                GlStateManager.rotate((locationsAndAngle.randZ + tile.getWorld().getTotalWorldTime()) + ClientTickHandler.getPartialTicks(), 0, 0, 1);
                GlStateManager.enableLighting();
                GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
                RenderHelper.disableStandardItemLighting();
                Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.NONE);
                RenderHelper.enableStandardItemLighting();
                GlStateManager.popMatrix();
            }
            if (tile.suckingCooldown <= 0) {
                if (RandUtil.nextInt(index / 2) == 0) {
                    LibParticles.CLUSTER_DRAPE(tile.getWorld(), locationsAndAngle.location.add(new Vec3d(tile.getPos())).addVector(0.5, 0.5, 0.5));
                }
            } else {
                if (RandUtil.nextInt(index / 4) == 0) {
                    LibParticles.CRAFTING_ALTAR_CLUSTER_SUCTION(tile.getWorld(), new Vec3d(tile.getPos()).addVector(0.5, 0.75, 0.5), new InterpBezier3D(locationsAndAngle.location, new Vec3d(0, 0, 0)));
                }
            }
        }
    }
    ItemStack pearlToRender = tile.getInputPearl();
    if (pearlToRender.isEmpty()) {
        pearlToRender = tile.getOutputPearl();
        if (pearlToRender.isEmpty()) {
            pearlToRender = ItemStack.EMPTY;
        }
    }
    if (!pearlToRender.isEmpty()) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.5, 1, 0.5);
        GlStateManager.scale(0.4, 0.4, 0.4);
        GlStateManager.rotate((float) (tile.getWorld().getTotalWorldTime() * 10.0), 0, 1, 0);
        GlStateManager.translate(0, 0.5 + Math.sin((tile.getWorld().getTotalWorldTime() + partialTicks) / 5) / 10.0, 0);
        Minecraft.getMinecraft().getRenderItem().renderItem(pearlToRender, TransformType.NONE);
        GlStateManager.popMatrix();
    } else if (errors.isEmpty() && RandUtil.nextInt(4) == 0) {
        LibParticles.CRAFTING_ALTAR_IDLE(tile.getWorld(), new Vec3d(tile.getPos()).addVector(0.5, 0.7, 0.5));
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) BlockPos(net.minecraft.util.math.BlockPos) IStructure(com.teamwizardry.wizardry.api.block.IStructure) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

IStructure (com.teamwizardry.wizardry.api.block.IStructure)2 Minecraft (net.minecraft.client.Minecraft)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vec3d (net.minecraft.util.math.Vec3d)2 InterpBezier3D (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D)1 InterpCircle (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle)1 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)1 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)1 CapManager (com.teamwizardry.wizardry.api.capability.CapManager)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1