Jump to content

hydroflame

Members
  • Posts

    1511
  • Joined

  • Last visited

Posts posted by hydroflame

  1. not sure which part you are talking about,

     

    Icon c = block.getIcon(side, meta);

    thsi whole line is inside your renderer

    the meta you can get by using world.getMetaAtWtvSomething(x, y, z);

    the side you just chose which side you want, when you render your cue you obviously render all 6 sides :P manualy

     

     

    the getIcon method itself goes inside your Block class, you can use another method if you want

    like create your own method getAllIcon will return an array of all texture you registered insode your Block class

  2. public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

    {

    if(player.getItemInUse() == null) return this.itemIcon;

    int Pulling = stack.getMaxItemUseDuration() - useRemaining;

    if (Pulling >= 16)

    {

    return iconArray[2];

     

    Icon[] myIcons = new Icon[5];
    myIcons[0] = iconRegister.registerIcon(ModMain.modid+":"+"myItem");
    myIcons[1] = iconRegister.registerIcon(ModMain.modid+":"+"myItem2");
    myIcons[2] = iconRegister.registerIcon(ModMain.modid+":"+"myItem3");
    etc

  3. this hurts so much xD

     

     

    public class TileEntityComputerRenderer extends TileEntitySpecialRenderer {

     

        //The model of your block

        public final ModelComputer model;

        private static final ResourceLocation resourceloc = new ResourceLocation(Reference.MOD_ID + ":" + "textures/tileentity/computer.png");

     

        public TileEntityComputerRenderer() {

            this.model = new ModelComputer();

        }

     

        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {//hydro: never called ??? why does it exists

            int meta = world.getBlockMetadata(x, y, z);

          //*facepalm*

          GL11.glPushMatrix();

            GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);

            GL11.glPopMatrix();

        }

     

        @Override

        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

            //The PushMatrix tells the renderer to "start" doing something. // hydro: correction, tell openGL to "save current matrix transform".

            GL11.glPushMatrix();

            //This is setting the initial location.//

            GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);

            Minecraft.getMinecraft().renderEngine.func_110577_a(resourceloc);

            //This is the texture of your block. It's pathed to be the same place as your other blocks here.

            //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!//the reason is because if you dont push you will not see your model, it will be renderered but very far from where you expect it to be

            GL11.glPushMatrix();

            GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

            //A reference to your Model file. Again, very important.

            this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

            //Tell it to stop rendering for both the PushMatrix's//hydro: tell openGL to restore saved matrix transform has nothing to do with rendering

            GL11.glPopMatrix();

            GL11.glPopMatrix();

        }

     

        //Set the lighting stuff, so it changes it's brightness properly.     

        private void adjustLightFixture(World world, int i, int j, int k, Block block) {//hydro:copy pasted never called ? ....

            Tessellator tess = Tessellator.instance;

            float brightness = block.getBlockBrightness(world, i, j, k);

            int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);

            int modulousModifier = skyLight % 65536;

            int divModifier = skyLight / 65536;

            tess.setColorOpaque_F(brightness, brightness, brightness);

            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier);

     

        }

    }

     

    and now clean version:

     

     

    public class TileEntityComputerRenderer extends TileEntitySpecialRenderer {

     

        //The model of your block

        public final ModelComputer model;

        private static final ResourceLocation resourceloc = new ResourceLocation(Reference.MOD_ID + ":" + "textures/tileentity/computer.png");

     

        public TileEntityComputerRenderer() {

            this.model = new ModelComputer();

        }

     

        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {

            int meta = world.getBlockMetadata(x, y, z);

            GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);

        }

     

        @Override

        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

            GL11.glPushMatrix();

            GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);

            Minecraft.getMinecraft().renderEngine.func_110577_a(resourceloc);

            GL11.glPushMatrix();

            adjustRotatePivotViaMeta(te.worldObj, te.xCoord, te.yCoord, te.zCoord);//rotation 1

            GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

            //adjustRotatePivotViaMeta(te.worldObj, te.xCoord, te.yCoord, te.zCoord);//comment line "rotation 1" and uncomment this line if it doesnt work.

            model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

            GL11.glPopMatrix();

            GL11.glPopMatrix();

        }

    }

     

  4. well for 1 you are not overriding the right method in your block

    you are suppose to override:

    public boolean hasTileEntity(int metadata)

    not

    public boolean hasTileEntity()

     

    2, dont blame the TE if you have a problem, the TE obviously work because chest, furnace, beacon, sign load correctly and TE are VANILLA class, not forge

     

    3

    your block class name... its ressemble insanelly a song by macklemore "waddup i got a BigClock(Block)" *irrelevant*

  5. well for the gui part its pretty straightfoward but here an example of my party gui (theres also a packet send in there)

     

     

    
    import java.util.List;
    
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiScreen;
    import net.minecraft.client.gui.GuiTextField;
    
    import org.lwjgl.input.Keyboard;
    
    import com.hydroflame.GuiApi.GuiNewList;
    import com.hydroflame.mod.TheMod;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    /**
    * The gui for party managing
    * @author hydroflame
    *
    */
    @SideOnly(Side.CLIENT)
    public class PartyGUI extends GuiScreen {
    
    public static int GUI_ID = 0;
    private boolean absorb = false;
    
    private GuiNewList<String> newList;
    private GuiButton[] guiButton;
    private GuiButton acceptButton;
    private GuiButton declineButton;
    private GuiButton leavePartyButton;
    private GuiButton inviteButton;
    private GuiTextField userTextField;
    
    
    public PartyGUI() {
    }
    
    // button is (id, x, y, width, height, text)
    public void initGui() {
    	newList = new GuiNewList<String>(125, this.width/2-200, this.height/2-50, 200, 100);
    
    	List<String> alist = TheMod.proxy.getList();
    	for (int i = 0; i < alist.size(); i++) {
    		newList.add(alist.get(i));
    	}
    
    	acceptButton = new GuiButton(0, this.width / 2 + 30,
    			this.height / 2 - 50, 60, 20, "accept");
    	userTextField = new GuiTextField(fontRenderer, this.width / 2 - 130,
    			this.height / 2 - 100, 103, 20);
    	userTextField.setTextColor(-1);
    	userTextField.setEnableBackgroundDrawing(true);
    	userTextField.setMaxStringLength(30);
    	userTextField.setFocused(true);
    	inviteButton = new GuiButton(1, this.width / 2 - 20,
    			this.height / 2 - 100, 50, 20, "invite");
    	declineButton = new GuiButton(2, this.width / 2 + 30,
    			this.height / 2 - 30, 60, 20, "decline");
    	leavePartyButton = new GuiButton(3, this.width/2+30, this.height/2 -10, 60, 20, "leave party");
    
    	buttonList.add(leavePartyButton);
    	buttonList.add(declineButton);
    	buttonList.add(acceptButton);
    	buttonList.add(inviteButton);
    	buttonList.add(newList);
    	setAvailability();
    }
    
    protected void mouseClicked(int par1, int par2, int par3) {
    	super.mouseClicked(par1, par2, par3);
    }
    
    protected void keyTyped(char par1, int par2) {
    	if (absorb) {
    		if (this.userTextField.textboxKeyTyped(par1, par2)) {
    
    		} else if (userTextField.isFocused() && par2 == Keyboard.KEY_RETURN) {
    			sendInvite();
    		} else {
    			super.keyTyped(par1, par2);
    		}
    		setAvailability();
    	}else{
    		absorb = true;
    	}
    }
    
    protected void actionPerformed(GuiButton button) {
    	if (button.id == acceptButton.id) {
    		TheMod.proxy.acceptInvite(newList.getSelectedItem());
    		TheMod.proxy.decline(newList.getSelected());
    		newList.remove(newList.getSelected());
    	} else if (button.id == declineButton.id) {
    		TheMod.proxy.decline(newList.getSelected());
    		newList.remove(newList.getSelected());
    	}else if (button.id == inviteButton.id) {
    		sendInvite();
    	}else if (button.id == leavePartyButton.id) {
    		leaveParty();
    	}
    	setAvailability();
    }
    
    private void leaveParty() {
    	TheMod.proxy.leaveParty();
    }
    
    public void drawScreen(int x, int y, float idk) {
    	this.drawDefaultBackground();
    	super.drawScreen(x, y, idk);
    	userTextField.drawTextBox();
    	this.fontRenderer.drawStringWithShadow("invites:", this.width / 2 - 200,
    			this.height / 2 - 60, 0xffffff);
    }
    
    private void sendInvite() {
    	TheMod.proxy.sendInviteToServer(userTextField.getText());
    	userTextField.setText("");
    }
    
    private void setAvailability(){
    	if(TheMod.proxy.isInParty()){
    		leavePartyButton.enabled = true;
    	}else{
    		leavePartyButton.enabled = false;
    	}
    	if(!userTextField.getText().equals("")){
    		inviteButton.enabled = true;
    	}else{
    		inviteButton.enabled = false;
    	}
    	if(newList.getSelected() == -1){
    		acceptButton.enabled = false;
    		declineButton.enabled = false;
    	}else{
    		acceptButton.enabled = true;
    		declineButton.enabled = true;
    	}
    }
    }
    

    for the nbt/item part, just open a container with that and you should have no problem figuring out how to manipulate PlayerInventory for you concern

     

    ==========================

     

    about the 2nd question, i dont like to encourage anything related to bukkit but...

     

    what i would do is make the mods register their config files to your mod, then reading would be easy if you setup a convention

    aka something like

    "place all item under the category "ItemFlenix" and place an array of 2 value containing {itemId, price}

    then the same for block but under category "BlockFlenix""

     

    but liek i said ... we probably shouldnt be encouraging bukkit

×
×
  • Create New...

Important Information

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