Search in sources :

Example 46 with Minecraft

use of net.minecraft.client.Minecraft in project RecurrentComplex by Ivorforce.

the class GuiHider method reopenGUI.

public static boolean reopenGUI() {
    if (!canReopen())
        return false;
    GuiScreen hiddenGUI = GuiHider.hiddenGUI;
    GuiHider.hiddenGUI = null;
    Minecraft mc = Minecraft.getMinecraft();
    mc.displayGuiScreen(hiddenGUI);
    if (mc.currentScreen == null) {
        GuiHider.hiddenGUI = hiddenGUI;
        return false;
    }
    return true;
}
Also used : GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft)

Example 47 with Minecraft

use of net.minecraft.client.Minecraft in project RecurrentComplex by Ivorforce.

the class SelectionRenderer method renderSelection.

public static void renderSelection(EntityLivingBase entity, int ticks, float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    BlockPos selPoint1 = null;
    BlockPos selPoint2 = null;
    SelectionOwner owner = SelectionOwner.getOwner(entity, null);
    if (owner != null) {
        selPoint1 = owner.getSelectedPoint1();
        selPoint2 = owner.getSelectedPoint2();
    }
    GL11.glLineWidth(3.0f);
    if (selPoint1 != null) {
        GlStateManager.color(0.6f, 0.8f, 0.95f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint1, selPoint1), 0.03f);
    }
    if (selPoint2 != null) {
        GlStateManager.color(0.2f, 0.45f, 0.65f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint2, selPoint2), 0.04f);
    }
    for (EnumHand enumHand : EnumHand.values()) {
        ItemStack heldItem = entity.getHeldItem(enumHand);
        if (heldItem != null && heldItem.getItem() instanceof ItemBlockSelectorFloating) {
            float selectionRange = ((ItemBlockSelectorFloating) heldItem.getItem()).getSelectionRange(heldItem);
            BlockPos hoverPoint = ItemBlockSelectorFloating.getHoveredBlock(entity, selectionRange);
            GlStateManager.color(0.6f, 0.6f, 1.0f);
            AreaRenderer.renderAreaLined(new BlockArea(hoverPoint, hoverPoint), 0.05f);
        }
    }
    if (selPoint1 != null && selPoint2 != null) {
        BlockArea selArea = new BlockArea(selPoint1, selPoint2);
        GlStateManager.color(0.4f, 0.65f, 0.8f);
        AreaRenderer.renderAreaLined(selArea, 0.02f);
        GlStateManager.enableBlend();
        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0001f);
        ResourceLocation curTex = TEXTURE[MathHelper.floor((ticks + partialTicks) * 0.75f) % TEXTURE.length];
        mc.renderEngine.bindTexture(curTex);
        GlStateManager.color(0.2f, 0.5f, 0.6f, 0.5f);
        AreaRenderer.renderArea(selArea, false, true, 0.01f);
        GlStateManager.color(0.4f, 0.65f, 0.8f, 0.75f);
        AreaRenderer.renderArea(selArea, false, false, 0.01f);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.002f);
        GlStateManager.disableBlend();
    }
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) ItemBlockSelectorFloating(ivorius.reccomplex.item.ItemBlockSelectorFloating) EnumHand(net.minecraft.util.EnumHand) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 48 with Minecraft

use of net.minecraft.client.Minecraft in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method getSprite.

/**
     * Gets the TextureAtlasSprite for the ItemStack. Has support for both Items and Blocks.
     *
     * @param stack The ItemStack to get the sprite for.
     * @return The sprite for the ItemStack.
     */
public static TextureAtlasSprite getSprite(ItemStack stack) {
    final Minecraft mc = Minecraft.getMinecraft();
    final Block block = StackUtils.getBlockFromStack(stack);
    if (block == null) {
        final ItemModelMesher mesher = mc.getRenderItem().getItemModelMesher();
        return !stack.isEmpty() ? mesher.getParticleIcon(stack.getItem(), stack.getItemDamage()) : mesher.getItemModel(null).getParticleTexture();
    }
    return mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(block.getStateFromMeta(stack.getItemDamage()));
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft)

Example 49 with Minecraft

use of net.minecraft.client.Minecraft in project BetterWithAddons by DaedalusGame.

the class BakedModelRopePost method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (state.getBlock() != ModBlocks.ropePost)
        return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, side, rand);
    Minecraft mc = Minecraft.getMinecraft();
    List<BakedQuad> quads = new ArrayList<>();
    IBlockState actualRope = state.getBlock().getDefaultState().withProperty(BlockRopePost.NORTH, state.getValue(BlockRopePost.NORTH)).withProperty(BlockRopePost.SOUTH, state.getValue(BlockRopePost.SOUTH)).withProperty(BlockRopePost.EAST, state.getValue(BlockRopePost.EAST)).withProperty(BlockRopePost.WEST, state.getValue(BlockRopePost.WEST)).withProperty(BlockRopePost.HAS_PLANKS, false).withProperty(BlockRopePost.HAS_POST, false);
    IBakedModel modelRope = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(actualRope);
    quads.addAll(modelRope.getQuads(actualRope, side, rand));
    BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
    IBlockState heldState = ((IExtendedBlockState) state).getValue(BlockRopePost.HELD_STATE);
    IBlockAccess heldWorld = ((IExtendedBlockState) state).getValue(BlockRopePost.HELD_WORLD);
    BlockPos heldPos = ((IExtendedBlockState) state).getValue(BlockRopePost.HELD_POS);
    if (heldWorld == null || heldPos == null) {
        return ImmutableList.of();
    }
    if (heldWorld instanceof FakeBlockAccess)
        return ImmutableList.of();
    if (heldState != null) {
        if (heldState.getBlock().canRenderInLayer(heldState, layer)) {
            IBlockState actual = heldState.getBlock().getActualState(heldState, new FakeBlockAccess(heldWorld), heldPos);
            // Steal camo's model
            IBakedModel model = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(actual);
            // Their model can be smart too
            IBlockState extended = heldState.getBlock().getExtendedState(actual, new FakeBlockAccess(heldWorld), heldPos);
            quads.addAll(model.getQuads(extended, side, rand));
        }
    }
    if (state.getValue(BlockRopePost.HAS_PLANKS)) {
        ModelRotation plankRotation = ModelRotation.X0_Y0;
        boolean x_axis = state.getValue(BlockRopePost.EAST) || state.getValue(BlockRopePost.WEST);
        boolean z_axis = state.getValue(BlockRopePost.NORTH) || state.getValue(BlockRopePost.SOUTH);
        if (x_axis && !z_axis)
            plankRotation = ModelRotation.X0_Y90;
        ItemStack heldPlanks = ((IExtendedBlockState) state).getValue(BlockRopePost.HELD_PLANKS);
        Block blockPlanks = Block.getBlockFromItem(heldPlanks.getItem());
        int meta = heldPlanks.getMetadata();
        if (// Catch items that are registered as plankWood
        blockPlanks == Blocks.AIR) {
            blockPlanks = Blocks.PLANKS;
            meta = 0;
        }
        IBlockState plankState = blockPlanks.getStateFromMeta(meta);
        String plankTexture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(plankState).getIconName();
        IModel plankModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(Reference.MOD_ID, "block/rope_bridge")).retexture(ImmutableMap.of("all", plankTexture));
        IBakedModel bakedPlankModel = plankModel.bake(new TRSRTransformation(plankRotation), DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
        quads.addAll(bakedPlankModel.getQuads(state, side, rand));
    }
    return ImmutableList.copyOf(quads);
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) IModel(net.minecraftforge.client.model.IModel) IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) IBlockAccess(net.minecraft.world.IBlockAccess) Minecraft(net.minecraft.client.Minecraft) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 50 with Minecraft

use of net.minecraft.client.Minecraft in project BetterWithAddons by DaedalusGame.

the class BakedModelRopeSideways method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (state.getBlock() != ModBlocks.ropeSideways)
        return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, side, rand);
    Minecraft mc = Minecraft.getMinecraft();
    List<BakedQuad> quads = new ArrayList<>();
    IBlockState actual = state.getBlock().getDefaultState().withProperty(BlockRopeSideways.SHAPE, state.getValue(BlockRopeSideways.SHAPE)).withProperty(BlockRopeSideways.HAS_PLANKS, false);
    IBakedModel model = mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(actual);
    quads.addAll(model.getQuads(actual, side, rand));
    ModelRotation plankRotation = ModelRotation.X0_Y0;
    if (state.getValue(BlockRopeSideways.SHAPE) == BlockRopeSideways.EnumRopeShape.X)
        plankRotation = ModelRotation.X0_Y90;
    ItemStack heldPlanks = ((IExtendedBlockState) state).getValue(BlockRopeSideways.HELD_PLANKS);
    Block blockPlanks = Block.getBlockFromItem(heldPlanks.getItem());
    int meta = heldPlanks.getMetadata();
    if (// Catch items that are registered as plankWood
    blockPlanks == Blocks.AIR) {
        blockPlanks = Blocks.PLANKS;
        meta = 0;
    }
    IBlockState plankState = blockPlanks.getStateFromMeta(meta);
    String plankTexture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(plankState).getIconName();
    IModel plankModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(Reference.MOD_ID, "block/rope_bridge")).retexture(ImmutableMap.of("all", plankTexture));
    IBakedModel bakedPlankModel = plankModel.bake(new TRSRTransformation(plankRotation), DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
    quads.addAll(bakedPlankModel.getQuads(state, side, rand));
    return ImmutableList.copyOf(quads);
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) IModel(net.minecraftforge.client.model.IModel) IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Minecraft (net.minecraft.client.Minecraft)100 ItemStack (net.minecraft.item.ItemStack)17 ScaledResolution (net.minecraft.client.gui.ScaledResolution)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 ArrayList (java.util.ArrayList)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 FontRenderer (net.minecraft.client.gui.FontRenderer)6 WorldClient (net.minecraft.client.multiplayer.WorldClient)6 World (net.minecraft.world.World)6 Tessellator (net.minecraft.client.renderer.Tessellator)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 Block (net.minecraft.block.Block)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 SimplePageView (com.almuradev.almura.feature.guide.client.gui.SimplePageView)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)3 GuiScreen (net.minecraft.client.gui.GuiScreen)3