Jump to content

hydroflame

Members
  • Posts

    1511
  • Joined

  • Last visited

Posts posted by hydroflame

  1. heu ... yeah no shit you're having a NPE

     

     

     

    package nicba1010.chemistryzation.common;

     

     

     

    import net.minecraft.client.Minecraft;

     

    import net.minecraft.client.gui.FontRenderer;

     

    import net.minecraft.client.gui.Gui;

     

    import net.minecraft.entity.player.EntityPlayer;

     

    import net.minecraft.nbt.NBTTagCompound;

     

    import net.minecraftforge.client.event.RenderGameOverlayEvent;

     

    import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

     

    import net.minecraftforge.event.EventPriority;

     

    import net.minecraftforge.event.ForgeSubscribe;

     

     

     

    //

     

    // GuiBuffBar implements a simple status bar at the top of the screen which

     

    // shows the current buffs/debuffs applied to the character.

     

    //

     

    public class GuiChemistryLevel extends Gui {

     

            private Minecraft mc;

     

            FontRenderer fontrenderer;

     

            EntityPlayer p;

     

            NBTTagCompound nbt;

     

     

     

            public GuiChemistryLevel(Minecraft mc) {

     

                    super();

     

                    fontrenderer = mc.fontRenderer;

     

                    // We need this to invoke the render engine.

     

                    this.mc = mc;

     

                    nbt = p.getEntityData();

     

            }

     

     

     

            @ForgeSubscribe(priority = EventPriority.NORMAL)

     

            public void onRenderExperienceBar(RenderGameOverlayEvent event) {

     

                    if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

     

                            return;

     

                    }

     

                    int level;

     

                    level = nbt.getInteger("level");

     

                    if (level == 0) {

     

                            nbt.setInteger("level", 1);

     

                            level = nbt.getInteger("level");

     

                            fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

     

                    } else {

     

                            fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

     

                    }

     

     

     

                    this.mc.renderEngine.bindTexture("/gui/inventory.png");

     

            }

     

    }

     

     

     

    the EntityPlayer is never initialized

     

     

     

     

    package nicba1010.chemistryzation.common;

     

     

     

    import net.minecraft.client.Minecraft;

     

    import net.minecraft.client.gui.FontRenderer;

     

    import net.minecraft.client.gui.Gui;

     

    import net.minecraft.entity.player.EntityPlayer;

     

    import net.minecraft.nbt.NBTTagCompound;

     

    import net.minecraftforge.client.event.RenderGameOverlayEvent;

     

    import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

     

    import net.minecraftforge.event.EventPriority;

     

    import net.minecraftforge.event.ForgeSubscribe;

     

     

     

    //

     

    // GuiBuffBar implements a simple status bar at the top of the screen which

     

    // shows the current buffs/debuffs applied to the character.

     

    //

     

    public class GuiChemistryLevel extends Gui {

     

            private Minecraft mc;

     

            FontRenderer fontrenderer;

     

            EntityPlayer p;

            //this should probably be a

            EntityClientPlayerMP player;

     

            NBTTagCompound nbt;

     

     

     

            public GuiChemistryLevel(Minecraft mc) {

     

                    super();

     

                    fontrenderer = mc.fontRenderer;

     

                    // We need this to invoke the render engine.

     

                    this.mc = mc;

                    //now like i said earlier

                    p = Minecraft.getMinecraft().thePlayer;

                    //or

                    p = mc.thePlayer;

                    //since mc is a reference to the current Minecraft

     

                    nbt = p.getEntityData();

     

            }

     

     

     

            @ForgeSubscribe(priority = EventPriority.NORMAL)

     

            public void onRenderExperienceBar(RenderGameOverlayEvent event) {

     

                    if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

     

                            return;

     

                    }

     

                    int level;

     

                    level = nbt.getInteger("level");

     

                    if (level == 0) {

     

                            nbt.setInteger("level", 1);

     

                            level = nbt.getInteger("level");

     

                            fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

     

                    } else {

     

                            fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

     

                    }

     

     

     

                    this.mc.renderEngine.bindTexture("/gui/inventory.png");

     

            }

     

    }

     

     

     

    btw not to be mean but i suggest you attack smaller mods. This is a pretty obvious error.

  2. if you use a

    spoiler

    maybe, because my current network blocks pastebin

     

    btw if you wanna check which side your on use:

     

    FMLCo[ac].instance().getEffectiveSide().isClient()  ( the [ac] is auto complete, i dont remember the class name exactly)

  3. Hi again,

     

     

    basicly you want your block to implement the "onNeighborBlockChange" method.

    it is called everytime a neighbor block is updated.

    Inside the implementations do

    world.getBlockTileEntity

    cast it into your "TileEntityPowerConduit" and call the updateEntity method you made

     

    Cheers,

    -hydroflame, FRev-

  4. ah ok

     

    generic description: tile entities are used to store any extra information that wont fit in the metadata (aka a number between 0-15)

     

    vanilla blocks that use tile entities(TE): sign, store the text to be displayed, chest, store  if if or not the chest is opened by someone, beacon, store how many buff are available and if its active.

     

    random idea i have at 6am just woke up: statue that holds buff that player can get and recover them periodically, 2 way teleporter, slot machine, bank

     

    for more exemple look at almost any mod on github.

     

    -hydroflame, FRev-

  5. 50% laziness 50% i didn't expect it to be that many changes my mod also does some small dirty vanilla modification ..... *shame on me*  so i tend not to switch version too often. plus i heard that the texture thigny was changed in 1.5+ so i though i was good for a while.

     

    thanks  ^^

  6. Minecraft.getMinecraft().objectMouseOver.entityHit is the client side version of which entity the player is looking at

    if(Minecraft.getMinecraft().objectMouseOver.entityHit != null){
        if(Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityLiving){
            //here you know the player is looking at a entityliving
        }
    }

     

     

    this is only for client side, if you want server side, send a packet

  7. Hi again, i found a way to bypass the bug. heuuuuu don't ask why, just know that the texture will render correctly after you draw at least 1 item with renderItem

     

    this is a code i was playing around, it seems to render fine even with 0 item to render

     

    package com.hydroflame.gui;

     

    import java.io.ByteArrayOutputStream;

    import java.io.DataOutputStream;

    import java.io.IOException;

    import java.util.LinkedList;

    import java.util.Random;

     

     

    import net.minecraft.block.Block;

    import net.minecraft.client.gui.GuiButton;

    import net.minecraft.client.gui.GuiScreen;

    import net.minecraft.client.gui.GuiSmallButton;

    import net.minecraft.client.renderer.RenderHelper;

    import net.minecraft.client.renderer.Tessellator;

    import net.minecraft.client.renderer.entity.RenderItem;

    import net.minecraft.entity.player.EntityPlayer;

    import net.minecraft.item.ItemStack;

    import net.minecraft.network.packet.Packet250CustomPayload;

    import net.minecraft.util.Icon;

    import net.minecraft.util.MathHelper;

    import net.minecraft.util.StatCollector;

     

    import org.lwjgl.input.Mouse;

    import org.lwjgl.opengl.GL11;

    import org.lwjgl.opengl.GL12;

     

    import cpw.mods.fml.common.network.PacketDispatcher;

    import cpw.mods.fml.relauncher.Side;

    import cpw.mods.fml.relauncher.SideOnly;

     

    public class tempGui extends GuiScreen {

    public static final int GUI_ID = 6666115;

     

    /** The top x coordinate of the achievement map */

    private int guiMapTop = 0 - 112;

     

    /** The left y coordinate of the achievement map */

    private int guiMapLeft = 0 - 112;

     

    /** The bottom x coordinate of the achievement map */

    private int guiMapBottom = 100 - 77;

     

    /** The right y coordinate of the achievement map */

    private static int guiMapRight = 100 - 77;

    private int guiPaneWidth = 256;

    private int guiPaneHeight = 202;

     

    /** The current mouse x coordinate */

    private int mouseX = 0;

     

    /** The current mouse y coordinate */

    protected int mouseY = 0;

    protected double field_74117_m;

    protected double field_74115_n;

     

    /** The x position of the achievement map */

    protected double guiMapX;

     

    /** The y position of the achievement map */

    protected double guiMapY;

    protected double field_74124_q;

    protected double field_74123_r;

     

    /** Whether the Mouse Button is down or not */

    private int isMouseButtonDown = 0;

     

     

    private final EntityPlayer player;

     

    public tempGui(EntityPlayer player) {

    short short1 = 141;

    short short2 = 141;

    field_74117_m = guiMapX = field_74124_q = 0 - short1 / 2 - 12;

    field_74115_n = guiMapY = field_74123_r = 0 - short2 / 2;

     

    this.player = player;

     

    // Adds the achievements to its list

     

     

    guiMapTop = 0 - 112;

    guiMapLeft = 0 - 112;

    guiMapBottom = 100 - 77;

    guiMapRight = 100 - 77;

    }

     

    /**

    * Adds the buttons (and other controls) to the screen in question.

    */

    @Override

    public void initGui() {

    buttonList.clear();

    // adds the exit button to the Gui

    buttonList.add(new GuiSmallButton(1, width / 2 + 24, height / 2 + 74,

    80, 20, StatCollector.translateToLocal("gui.done")));

    }

     

    /**

    * Fired when a control is clicked. This is the equivalent of

    * ActionListener.actionPerformed(ActionEvent e).

    */

    @Override

    protected void actionPerformed(GuiButton par1GuiButton) {

    // has the exit button been pressed

    if (par1GuiButton.id == 1) {

    mc.displayGuiScreen((GuiScreen) null);

    mc.setIngameFocus();

    }

     

    super.actionPerformed(par1GuiButton);

    }

     

    /**

    * Fired when a key is typed. This is the equivalent of

    * KeyListener.keyTyped(KeyEvent e).

    */

    @Override

    protected void keyTyped(char par1, int par2) {

    // has E been pressed

    if (par2 == mc.gameSettings.keyBindInventory.keyCode) {

    mc.displayGuiScreen((GuiScreen) null);

    mc.setIngameFocus();

    } else

    super.keyTyped(par1, par2);

    }

     

    /**

    * Draws the screen and all the components in it.

    */

    @Override

    public void drawScreen(int par1, int par2, float par3) {

    // is LMB down

    if (Mouse.isButtonDown(0)) {

    int k = (width - guiPaneWidth) / 2;

    int l = (height - guiPaneHeight) / 2;

    int i1 = k + 8;

    int j1 = l + 17;

     

    // Is the mouse within the Gui

    if ((isMouseButtonDown == 0 || isMouseButtonDown == 1)

    && par1 >= i1 && par1 < i1 + 224 && par2 >= j1

    && par2 < j1 + 155) {

    // was the mouse down last tick?

    if (isMouseButtonDown == 0)

    // sets the mouse variable to be read next tick

    isMouseButtonDown = 1;

    else {

    // moves screen by the same as mouse

    guiMapX -= par1 - mouseX;

    guiMapY -= par2 - mouseY;

    // these fields are all the same, I think render/screen

    // bounds/position?

    field_74124_q = field_74117_m = guiMapX;

    field_74123_r = field_74115_n = guiMapY;

    }

    // sets the previous mouse positions

    mouseX = par1;

    mouseY = par2;

    }

    // Limits screen movement

    if (field_74124_q < guiMapTop)

    field_74124_q = guiMapTop;

     

    if (field_74123_r < guiMapLeft)

    field_74123_r = guiMapLeft;

     

    if (field_74124_q >= guiMapBottom)

    field_74124_q = guiMapBottom - 1;

     

    if (field_74123_r >= guiMapRight)

    field_74123_r = guiMapRight - 1;

    } else

    // if mouse is released then this is 0, Used to detect drag vs click

    isMouseButtonDown = 0;

     

    // Draws the screen background

    drawDefaultBackground();

    // draws the achievement page background (terrain type thing)

    genAchievementBackground(par1, par2, par3);

    // GL lighting stuff scares me :(

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    // draws the title

    drawTitle();

    GL11.glEnable(GL11.GL_LIGHTING);

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    }

     

    /**

    * Called from the main game loop to update the screen.

    */

    @Override

    public void updateScreen() {

    // saves the current screen position

    field_74117_m = guiMapX;

    field_74115_n = guiMapY;

    // the movement of the screen

    double d0 = field_74124_q - guiMapX;

    double d1 = field_74123_r - guiMapY;

     

    // moved less than 2?

    if (d0 * d0 + d1 * d1 < 4.0D) {

    // x = field_74124_q

    guiMapX += d0;

     

    // y = field_74123_r

    guiMapY += d1;

    }

    // if more than 2 move less

    else {

    guiMapX += d0 * 0.85D;

    guiMapY += d1 * 0.85D;

    }

    }

     

    /**

    * Draws the "Achievements" title at the top of the GUI.

    */

    protected void drawTitle() {

    int i = (width - guiPaneWidth) / 2;

    int j = (height - guiPaneHeight) / 2;

    fontRenderer.drawString("Alters", i + 15, j + 5, 4210752);

    }

     

    protected void genAchievementBackground(int par1, int par2, float par3) {

    // does something

    int k = MathHelper.floor_double(field_74117_m

    + (guiMapX - field_74117_m) * par3);

    int l = MathHelper.floor_double(field_74115_n

    + (guiMapY - field_74115_n) * par3);

     

    // limits l and k to the screen boundary

    if (k < guiMapTop)

    k = guiMapTop;

     

    if (l < guiMapLeft)

    l = guiMapLeft;

     

    if (k >= guiMapBottom)

    k = guiMapBottom - 1;

     

    if (l >= guiMapRight)

    l = guiMapRight - 1;

     

    // top and left bounds for the screen

    int i1 = (width - guiPaneWidth) / 2;

    int j1 = (height - guiPaneHeight) / 2;

    // ummm... possibly bounds for achievement window

    int k1 = i1 + 16;

    int l1 = j1 + 17;

    zLevel = 0.0F;

    GL11.glDepthFunc(GL11.GL_GEQUAL);

    GL11.glPushMatrix();

    GL11.glTranslatef(0.0F, 0.0F, -200.0F);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    mc.renderEngine.bindTexture("/terrain.png");

    int i2 = k + 288 >> 4;

    int j2 = l + 288 >> 4;

    int k2 = (k + 288) % 16;

    int l2 = (l + 288) % 16;

    Random random = new Random();

    int i3;

    int j3;

    int k3;

     

     

    // nested loop with texture stuff

    for (i3 = 0; i3 * 16 - l2 < 155; ++i3) {

    float f1 = 0.6F - (j2 + i3) / 25.0F * 0.3F;

    GL11.glColor4f(f1, f1, f1, 1.0F);

     

    // Background texture randomiser

    for (k3 = 0; k3 * 16 - k2 < 224; ++k3) {

    random.setSeed(1234 + i2 + k3);

    random.nextInt();

    j3 = random.nextInt(1 + j2 + i3) + (j2 + i3) / 2;

    Icon icon = Block.sand.getBlockTextureFromSide(0);

     

    drawTexturedModelRectFromIcon(k1 + k3 * 16 - k2, l1 + i3 * 16

    - l2, icon, 16, 16);

    }

    }

     

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int l3;

    int j4;

     

    int par4 = 0, par5 = 0, par6 = 0;

    float f1 = 0, f = 0;

    Tessellator tessellator = Tessellator.instance;

            tessellator.startDrawingQuads();

            tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + 0) * f), (double)((float)(par4 + par6) * f1));

            tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + par5) * f), (double)((float)(par4 + par6) * f1));

            tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + par5) * f), (double)((float)(par4 + 0) * f1));

            tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 0) * f), (double)((float)(par4 + 0) * f1));

            tessellator.draw();

     

     

    // Achievement saved to this if mouse over

    RenderHelper.enableGUIStandardItemLighting();

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    int l4;

    int i5;

    //NOTE THIS  \/

    //renders somethign somewhere invisible, seems to fix the problem

    RenderItem renderitem = new RenderItem();

    renderitem.renderItemAndEffectIntoGUI(mc.fontRenderer,mc.renderEngine, new ItemStack(Block.dirt), 0 + 3,0 + 3);

     

     

    // iterates over achievements and renders them

    for (k3 = 0; k3 < 4; ++k3) {

    // achievement being rendered

    // position of element relative to screen

    j4 = k3*50 - k;

    l3 = 0 - l;

    // is on page/is visible?

    if (j4 >= -24 && l3 >= -24 && j4 <= 224 && l3 <= 155) {

    // properties of element colour/shade for rendering

    float f2;

    f2 = 1.0F;

    GL11.glColor4f(f2, f2, f2, 1.0F);

    i5 = k1 + j4;

    l4 = l1 + l3;

    mc.renderEngine.bindTexture("/achievement/bg.png");

    // element position relative to view-port

    // element render properties

    drawTexturedModalRect(i5 - 2, l4 - 2, 0, 202, 26, 26);

    // renders an item on the gui

     

    GL11.glEnable(GL11.GL_LIGHTING);

    GL11.glEnable(GL11.GL_CULL_FACE);

    renderitem.renderItemAndEffectIntoGUI(mc.fontRenderer,mc.renderEngine, new ItemStack(Block.dirt), i5 + 3,l4 + 3);

    GL11.glDisable(GL11.GL_LIGHTING);

     

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    // is mouse over

    }

    }

     

     

     

     

     

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glEnable(GL11.GL_BLEND);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    mc.renderEngine.bindTexture("/achievement/bg.png");

    drawTexturedModalRect(i1, j1, 0, 0, guiPaneWidth, guiPaneHeight);

    GL11.glPopMatrix();

    zLevel = 0.0F;

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    super.drawScreen(par1, par2, par3);

    // renders the info of the mouse over element

     

     

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glEnable(GL11.GL_LIGHTING);

    RenderHelper.disableStandardItemLighting();

    }

     

    /**

    * Returns true if this GUI should pause the game when it is displayed in

    * single-player

    */

    @Override

    public boolean doesGuiPauseGame() {

    return true;

    }

     

    @Override

    protected void mouseClicked(int par1, int par2, int par3) {

     

    super.mouseClicked(par1, par2, par3);

    }

    }

     

     

     

    i had to remove all "altars" related because i didn't have them, but it shouldn't affect the rendering code

     

    Cheer,

     

    -hydroflame, author FRev-

  8. heu ..... i just noticed something

     

     

    you said its always the first one to be renderer that fails to have a texture

    1 in the case of having "destinations" (or wtv you called your achievement-like-element) the first one to get drawn doesnt have a texture

    2 in the case of no "destination" the overlay is white.

     

    is it possible that the first thing to get drawn will always be white....

     

     

    if thats the case ... cant you just render anything in the background, somethign that will get drawn over by the gui ... this way youll pass over the "first thing drawn is white"

     

    -hydroflame-

  9. come to think of it it can be done in 1 pass ....

     

     

    1 render normal skin

    2 render scars (and everything that is directly over the skin like eyes and whatnot)

    3 render hairs

    4 render clothes (with alpha at this point you will also have the scars and skin)

    5 render auras and whatever else you might have to.

     

    just be sure that theyre are in order  and in 1 renderFunction call(exemple if you render scars after clothes you might see the scar OVER the clothes)

     

    it does requires you to rewrite the renderers.

  10. ahhh, yeah well with help you can usually do fine, tough watch out wich question you ask because people end up asking stuff were you just know they have no idea what they're doing.

     

    good modding

  11. interresting, though if you have something very visual you wouldnt want your players to have to interract with the statue to update the visual

     

    lets say hum .. idk  a statue that glows when its ready to give a blessing. you would want players to know immidiately hen the statue is ready. not having to right click it to update it

     

    but yeah i would deff use it if it was container related

     

    thanks ^^

     

    -hydroflame, author FRev-

  12. every place it says "//here"

     

     

    package tutorial.generic;

     

    import cpw.mods.fml.common.Mod;

    import cpw.mods.fml.common.Mod.Init;

    import cpw.mods.fml.common.Mod.Instance;

    import cpw.mods.fml.common.Mod.PostInit;

    import cpw.mods.fml.common.Mod.PreInit;

    import cpw.mods.fml.common.SidedProxy;

    import cpw.mods.fml.common.event.FMLInitializationEvent;

    import cpw.mods.fml.common.event.FMLPostInitializationEvent;

    import cpw.mods.fml.common.event.FMLPreInitializationEvent;

    import cpw.mods.fml.common.network.NetworkMod;

     

    @Mod(modid="Generic", name="Generic", version="0.0.0")

    @NetworkMod(clientSideRequired=true, serverSideRequired=false)

    public class Generic {

    //here

            // The instance of your mod that Forge uses.

            @Instance("Generic")

            public static Generic instance;

          //here, preferably here

            // Says where the client and server 'proxy' code is loaded.

            @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")

            public static CommonProxy proxy;

          //here

            @PreInit

            public void preInit(FMLPreInitializationEvent event) {

                    // Stub Method

            }

          //or here

            @Init

            public void load(FMLInitializationEvent event)

            {

                    proxy.registerRenderers();

                 

                    GameRegistry.registerBlock(genericDirt, "genericDirt");

                    LanguageRegistry.addName(genericDirt, "Generic Dirt");

                    MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0);

            }

         

            @PostInit

            public void postInit(FMLPostInitializationEvent event) {

                    // Stub Method

            }

    }

     

     

    but please learn to code before doing modding, if you couldnt figure it was because you didnt declare a variable you will clearly have much worst problem later on, sorry :(

  13. as the change for 0 to 26, my fear was that it was actually in that space on the texture where theres nothing, turn out its not.

     

    I'm sorry i dont have any other idea other then hardcore debugging, but i would very much like to hear about the progress of this. Whats the name of the mod you're making and when do you think you'll be done ?

     

    the last thing you could try is straight up duplicate EVERYTHING the achievement thigny use and change things ONE BY ONE, slowly but surely

     

    -hydroflame, author FRev-

     

     

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.