Search in sources :

Example 1 with BlockEnderChest

use of net.minecraft.block.BlockEnderChest in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunnerClient method onDrawBlockDamageTexture.

public static void onDrawBlockDamageTexture(RenderGlobal renderGlobal, Tessellator tessellatorIn, VertexBuffer worldRendererIn, Entity entityIn, float partialTicks) {
    double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    if (!renderGlobal.damagedBlocks.isEmpty()) {
        renderGlobal.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        renderGlobal.preRenderDamagedBlocks();
        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
        worldRendererIn.setTranslation(-d0, -d1, -d2);
        worldRendererIn.noColor();
        Iterator<DestroyBlockProgress> iterator = renderGlobal.damagedBlocks.values().iterator();
        while (iterator.hasNext()) {
            DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) iterator.next();
            BlockPos blockpos = destroyblockprogress.getPosition();
            double d3 = (double) blockpos.getX() - d0;
            double d4 = (double) blockpos.getY() - d1;
            double d5 = (double) blockpos.getZ() - d2;
            Block block = renderGlobal.theWorld.getBlockState(blockpos).getBlock();
            TileEntity te = renderGlobal.theWorld.getTileEntity(blockpos);
            boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull;
            if (!hasBreak)
                hasBreak = te != null && te.canRenderBreaking();
            if (!hasBreak) {
                PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(renderGlobal.theWorld, blockpos);
                if (wrapper == null && (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)) {
                    iterator.remove();
                } else {
                    IBlockState iblockstate = renderGlobal.theWorld.getBlockState(blockpos);
                    if (wrapper != null) {
                        wrapper.wrapping.renderer.setupTranslation(partialTicks);
                        worldRendererIn.setTranslation(-wrapper.wrapping.renderer.offsetPos.getX(), -wrapper.wrapping.renderer.offsetPos.getY(), -wrapper.wrapping.renderer.offsetPos.getZ());
                    }
                    if (iblockstate.getMaterial() != Material.AIR) {
                        int i = destroyblockprogress.getPartialBlockDamage();
                        TextureAtlasSprite textureatlassprite = renderGlobal.destroyBlockIcons[i];
                        BlockRendererDispatcher blockrendererdispatcher = renderGlobal.mc.getBlockRendererDispatcher();
                        try {
                            blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, renderGlobal.theWorld);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    worldRendererIn.setTranslation(-d0, -d1, -d2);
                    // TODO: Reverse the Matrix Transforms here
                    if (wrapper != null) {
                        tessellatorIn.draw();
                        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
                        wrapper.wrapping.renderer.inverseTransform(partialTicks);
                    }
                }
            }
        }
        tessellatorIn.draw();
        worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
        renderGlobal.postRenderDamagedBlocks();
    }
}
Also used : BlockSkull(net.minecraft.block.BlockSkull) IBlockState(net.minecraft.block.state.IBlockState) BlockChest(net.minecraft.block.BlockChest) BlockEnderChest(net.minecraft.block.BlockEnderChest) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IOException(java.io.IOException) TileEntity(net.minecraft.tileentity.TileEntity) DestroyBlockProgress(net.minecraft.client.renderer.DestroyBlockProgress) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockSign(net.minecraft.block.BlockSign) Block(net.minecraft.block.Block) EnumSkyBlock(net.minecraft.world.EnumSkyBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Aggregations

PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 IOException (java.io.IOException)1 Block (net.minecraft.block.Block)1 BlockChest (net.minecraft.block.BlockChest)1 BlockEnderChest (net.minecraft.block.BlockEnderChest)1 BlockSign (net.minecraft.block.BlockSign)1 BlockSkull (net.minecraft.block.BlockSkull)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)1 DestroyBlockProgress (net.minecraft.client.renderer.DestroyBlockProgress)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 EnumSkyBlock (net.minecraft.world.EnumSkyBlock)1