Search in sources :

Example 46 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite 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)

Example 47 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class RenderBlockGrate method renderWorldBlockWoodDynamic.

@Override
protected void renderWorldBlockWoodDynamic(ITessellator tess, World world, BlockPos pos, BlockGrate block, TileEntityGrate grate, TextureAtlasSprite sprite) {
    // vines
    final TextureAtlasSprite vinesIcon = BaseIcons.VINE.getIcon();
    int l = this.getMixedBrightness(grate.getWorld(), grate.getPos(), Blocks.VINE.getDefaultState());
    float f0 = (float) (l >> 16 & 255) / 255.0F;
    float f1 = (float) (l >> 8 & 255) / 255.0F;
    float f2 = (float) (l & 255) / 255.0F;
    tess.setColorRGB(f0, f1, f2);
    if (grate.hasVines(true)) {
        tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 0.001f);
    }
    if (grate.hasVines(false)) {
        tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 1.999f);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 48 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class RenderTank method renderWorldBlockWoodDynamic.

@Override
protected void renderWorldBlockWoodDynamic(ITessellator tessellator, World world, BlockPos pos, BlockWaterTank block, TileEntityTank tank, TextureAtlasSprite sprite) {
    // only render water in one on top.
    final int level = tank.getFluidHeight();
    if (level > 0) {
        // -0.0001F to avoid Z-fighting on maximum filled tanks
        final float y = (level * 16 / 1_000f) - A;
        // Calculate water brightness.
        final int l = RenderUtilBase.getMixedBrightness(tank.getWorld(), tank.getPos(), Blocks.WATER);
        tessellator.setBrightness(l);
        tessellator.setAlpha(0.39f);
        // draw surface
        final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();
        tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.UP, waterIcon, y);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite)

Example 49 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.

the class IconHelper method findMatches.

/**
 * Pure hack to find icons...
 *
 * @param name
 * @return
 */
public static Deque<String> findMatches(String name) {
    name = name.toLowerCase();
    if (findCache.containsKey(name)) {
        return findCache.get(name);
    }
    Deque<String> matches = new ArrayDeque<>();
    try {
        Field f = TextureMap.class.getDeclaredField("mapRegisteredSprites");
        f.setAccessible(true);
        Map<String, TextureAtlasSprite> textureMap = (Map<String, TextureAtlasSprite>) f.get(Minecraft.getMinecraft().getTextureMapBlocks());
        for (String e : textureMap.keySet()) {
            if (e.contains(name)) {
                matches.add(e);
            }
        }
        if (!findCache.isEmpty()) {
            findCache.put(name, matches);
        } else {
            matches.add("missingno");
        }
    } catch (NoSuchFieldException | IllegalAccessException e) {
        // Shoot
        AgriCore.getLogger("agricraft").debug("Something strange is going on with the Minecraft TextureMap!");
    } catch (SecurityException e) {
        AgriCore.getLogger("agricraft").debug("Locked out of TextureMap...");
    }
    return matches;
}
Also used : Field(java.lang.reflect.Field) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) TextureMap(net.minecraft.client.renderer.texture.TextureMap) HashMap(java.util.HashMap) Map(java.util.Map) ArrayDeque(java.util.ArrayDeque)

Example 50 with TextureAtlasSprite

use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project BetterWithAddons by DaedalusGame.

the class ModelToolShardInner method bake.

@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    Optional<TRSRTransformation> transform = state.apply(Optional.empty());
    for (int i = 0; i < textures.size(); i++) {
        ResourceLocation tex = textures.get(i);
        if (tex.toString().equals("minecraft:missingno"))
            continue;
        TextureAtlasSprite sprite = bakedTextureGetter.apply(tex);
        String breakLocation = new ResourceLocation(Reference.MOD_ID, "items/breakmask").toString();
        TextureAtlasSprite breakTemplate = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(breakLocation);
        builder.addAll(getQuadsForSprite(i, breakTemplate, sprite, format, transform));
    // builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, NORTH_Z + Z_OFFSET * i, EnumFacing.NORTH, 0xffffffff));
    // builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, SOUTH_Z - Z_OFFSET * i, EnumFacing.SOUTH, 0xffffffff));
    }
    TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
    ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms(state);
    return new BakedItemModel(builder.build(), particle, map, null);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) ImmutableList(com.google.common.collect.ImmutableList) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)

Aggregations

TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)51 ResourceLocation (net.minecraft.util.ResourceLocation)9 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)8 EnumFacing (net.minecraft.util.EnumFacing)8 Tessellator (net.minecraft.client.renderer.Tessellator)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)5 IBlockState (net.minecraft.block.state.IBlockState)5 TileEntity (net.minecraft.tileentity.TileEntity)5 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)5 Minecraft (net.minecraft.client.Minecraft)4 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 Vector3f (org.lwjgl.util.vector.Vector3f)4 ImmutableList (com.google.common.collect.ImmutableList)3 HashMap (java.util.HashMap)3 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)3 TextureManager (net.minecraft.client.renderer.texture.TextureManager)3 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)3