• 0

    posted a message on How to make an addon

    Hello,


    does anyone know how to make an addon to another mod? I'm working on my own mod and I have machines that are supposed to be powered by electricity. I could probably program my own electricity, but I though it might be a better idea to use electricity from other mod, for example IC2, which, since I'm already using IC2, would mean one less electrical grid for me. At least it would be good to make it possible to convert the two electricities to each other. There are several more places in my mod where it would be useful to use things from other mods, but I think the electricity is enough as an example. Thanks for any advice!

    Posted in: Modification Development
  • 1

    posted a message on Do I need to study vanilla Minecraft's code to learn how to mod effectively?? Either way, how would I even go about doing that?

    It depends what Minecraft version do you want to make mod for. Each version differs a bit and the tutorials are usually for defined version.

    Posted in: Modification Development
  • 1

    posted a message on Do I need to study vanilla Minecraft's code to learn how to mod effectively?? Either way, how would I even go about doing that?

    You don't need to know how the entire Minecraft code works, the basics are enough. I think the best way to learn modding in Minecraft is to first learn the basics like creating "inert" blocks and items and then learn more and more advanced functions you can add to your creations. While learning those functions, you will also probably start understanding the principle of the vanilla Minecraft code over time. If you need to know how to program any particular function, just google it. And if you find nothing, write on the forum. Someone might know the answer. At least I personally do it that way.


    And when learning more advanced funcions, it is allways important to know what exactly you want to make. There are simply too many options to learn all of them.


    Good luck programing your first mod!

    Posted in: Modification Development
  • 0

    posted a message on My Smelting recipes don´t work

    Did you call the method init() in preloading?

    Posted in: Modification Development
  • 0

    posted a message on Wiring tutorial

    Hello, does someone know about any tutorial how to write a code for electrical wires (like those from IC2, for example)? I tried to reverse-engineer the original code from several mods, but it is mostly just total mess. Thanks for any tips!

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] Biome specific ore generation

    I tried to use the advice you gave me and it appears it worked! Thank you very much!

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] Biome specific ore generation

    Hello,


    does anyone know how to generate ores only in specific biomes (like in vanilla Minecraft emeralds generate only in mountains)? I already wrote my own code according to a guide I found somewhere (I don't remember where anymore), but it doesn't work as supposed. Instead of generating each of my ores in certain biomes, it generates random ore (usually only one of them) in more or less random biomes. In each world I tried to create, it generated different ore. Here is my code:

    package testmod;
    
    import java.util.Random;
    
    import blocks.BlocksManager;
    
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import net.minecraft.world.World;
    import net.minecraft.world.chunk.IChunkProvider;
    import net.minecraft.world.gen.feature.WorldGenMinable;
    import cpw.mods.fml.common.IWorldGenerator;
    
    public class OreGenerator implements IWorldGenerator {
    
    	@Override
    	public void generate(Random random, int chunkX, int chunkZ, World world,
    			IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    		switch (world.provider.dimensionId) {
    		case 1:
    			generateEnd(world, random, chunkX, chunkZ);
    			break;
    		case 0:
    			generateOverworld(world, random, chunkX, chunkZ);
    			break;
    		case -1:
    			generateNether(world, random, chunkX, chunkZ);
    			break;
    		}
    
    	}
    
    	private void generateNether(World world, Random random, int chunkX,
    			int chunkZ) {
    		// TODO Auto-generated method stub
    
    	}
    
    	private void generateOverworld(World world, Random random, int chunkX,
    			int chunkZ) {
    		String s = world.getBiomeGenForCoords(chunkX, chunkZ).biomeName;
    		if(s.startsWith("Savanna")){
    			generateOre(BlocksManager.blockChromiumOre, world, random, chunkX, chunkZ, 4, 9, 10, 0, 48, Blocks.stone);
    		}else if(s.startsWith("Snowy")){
    			generateOre(BlocksManager.blockNickelOre, world, random, chunkX, chunkZ, 4, 12, 8, 0, 48, Blocks.stone);
    		}else if(s.startsWith("Forest")){
    			generateOre(BlocksManager.blockBauxiteOre, world, random, chunkX, chunkZ, 6, 17, 5, 48, 70, Blocks.stone);
    			generateOre(BlocksManager.blockLimestone, world, random, chunkX, chunkZ, 8, 16, 5, 32, 70, Blocks.stone);
    		}else if(s.startsWith("Jungle")){
    			generateOre(BlocksManager.blockBauxiteOre, world, random, chunkX, chunkZ, 6, 17, 5, 48, 70, Blocks.stone);
    			generateOre(BlocksManager.blockCobaltOre, world, random, chunkX, chunkZ, 2, 6, 4, 0, 42, Blocks.stone);
    		}else if(s.startsWith("Mesa") && !s.startsWith("mesa_plateau")){
    			generateOre(BlocksManager.blockBoraxOre, world, random, chunkX, chunkZ, 4, 8, 10, 56, 80, Blocks.stone);
    		}else if(s.startsWith("Swamp")){
    			generateOre(BlocksManager.blockZincOre, world, random, chunkX, chunkZ, 4, 9, 8, 0, 48, Blocks.stone);
    		}else if(s.startsWith("Plains")){
    			generateOre(BlocksManager.blockMagnesiteOre, world, random, chunkX, chunkZ, 6, 12, 5, 32, 63, Blocks.stone);
    			generateOre(BlocksManager.blockLimestone, world, random, chunkX, chunkZ, 8, 16, 5, 32, 70, Blocks.stone);
    		}else if(s.startsWith("Desert")){
    			generateOre(BlocksManager.blockRockSalt, world, random, chunkX, chunkZ, 8, 24, 4, 48, 80, Blocks.stone);
    			generateOre(BlocksManager.blockSylvite, world, random, chunkX, chunkZ, 4, 12, 2, 48, 80, Blocks.stone);
    		}else if(s.startsWith("ExtremeHills")){
    			generateOre(BlocksManager.blockFluoriteOre, world, random, chunkX, chunkZ, 4, 9, 10, 0, 80, Blocks.stone);
    		}else if(s.startsWith("StoneBeach")){
    			generateOre(BlocksManager.blockLimestone, world, random, chunkX, chunkZ, 8, 24, 4, 48, 100, Blocks.stone);
    		}else if(s.contains("Ocean")){
    			generateOre(BlocksManager.blockZeolite, world, random, chunkX, chunkZ, 6, 12, 4, 20, 60, Blocks.gravel);
    			generateOre(BlocksManager.blockZeolite, world, random, chunkX, chunkZ, 6, 12, 4, 20, 60, Blocks.stone);
    		}
    	}
    
    	private void generateEnd(World world, Random random, int chunkX, int chunkZ) {
    		// TODO Auto-generated method stub
    
    	}
    
    	public void generateOre(Block block, World world, Random random,
    			int chunkX, int chunkZ, int minVeinSize, int maxVeinSize,
    			int chance, int minY, int maxY, Block generateIn) {
    		int veinSize = minVeinSize + random.nextInt(maxVeinSize - minVeinSize);
    		int heightRange = maxY - minY;
    		WorldGenMinable gen = new WorldGenMinable(block, veinSize, generateIn);
    		for (int i = 0; i < chance; i++) {
    			int xRand = chunkX * 16 + random.nextInt(16);
    			int yRand = random.nextInt(heightRange) + minY;
    			int zRand = chunkZ * 16 + random.nextInt(16);
    			gen.generate(world, random, xRand, yRand, zRand);
    		}
    	}
    
    }

    Thanks for any advice!

    Posted in: Modification Development
  • 0

    posted a message on GUI not working right
    Quote from master801»

    Make sure you're not using the client when dealing with server side things, like items.


    Thanks for the advice, but it still doesn't fix the issue. To tell the truth, I have put that Client side annotation there just as an attempt to fix the issue.
    Posted in: Modification Development
  • 0

    posted a message on GUI not working right

    Hello,


    I'm working on a new mod and I have a problem with one of the GUIs. Its purpose is to remove a certain amount of substance ("chemical") from one item ("jar") and add it to another item ("beaker"). The amount of substance is typed into the text field ("text") and the weighting is performed by the only button in the GUI (ID 1). After weighting, the beaker turns into item called ("Mixture"), which is simply a beaker with content, and amount of substance in the jar decreases accordingly. The problem is that while the GUI is working mostly right, when you remove either if the containers, it resets both containers to the previous state. For example, if I weight, let's say, 10 grams of sugar from a jar containing 100 grams of sugar into an empty beaker, it first turns the beaker into mixture containing 10 grams of sugat and turns the jar into jar containing 90 grams of sugar. But after I remove either the jar or the beaker from the GUI, the jar will have 100 grams of sugat in it and the beaker becomes empty again. Does someone know how to fix this? Thanks.


    Code of the GUI:

    package gui;
    
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiTextField;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    
    import org.lwjgl.input.Keyboard;
    import org.lwjgl.opengl.GL11;
    
    import tileentities.TileEntityScale;
    
    public class GuiScale extends GuiContainer{
    	private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("tm:textures/gui/GUIScale.png");
    	private TileEntityScale tileFurnace;
    	private GuiTextField text;
    
    	public GuiScale(InventoryPlayer invPlayer, TileEntityScale tile) {
    		super(new ContainerScale(invPlayer, tile));
    		this.tileFurnace = tile;
    		
    	}
    	
    	protected void drawGuiContainerForegroundLayer(int par1, int par2){
    		String string = this.tileFurnace.hasCustomInventoryName() ? this.tileFurnace.getInventoryName() : I18n.format(this.tileFurnace.getInventoryName(), new Object[0]);
    		this.fontRendererObj.drawString(string, this.xSize / 2 - this.fontRendererObj.getStringWidth(string)/2, 6, 4210752);
    		
    	}
    
    	@Override
    	protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    		 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    	        this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
    	        int k = (this.width - this.xSize) / 2;
    	        int l = (this.height - this.ySize) / 2;
    	        this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
    	}
    	public void initGui(){
    		super.initGui();
    		int k = (this.width - this.xSize) / 2;
            int l = (this.height - this.ySize) / 2;
    		this.text = new GuiTextField(this.fontRendererObj, k+65, l+57, 45, 11);
            text.setMaxStringLength(9);
            text.setText("");
            text.setTextColor(-1);
            text.setDisabledTextColour(-1);
            text.setEnableBackgroundDrawing(true);
            this.text.setFocused(true);
            this.buttonList.add(new GuiButton(1, k+74, l+69, 27, 10, "Weight"));
    	}
    	protected void keyTyped(char par1, int par2){
    		super.keyTyped(par1, par2);
            this.text.textboxKeyTyped(par1, par2);
    	}
    	public void updateScreen(){
    		super.updateScreen();
            this.text.updateCursorCounter();
    	}
    	public void drawScreen(int par1, int par2, float par3){
    		this.drawDefaultBackground();
            this.text.drawTextBox();
            super.drawScreen(par1, par2, par3);
    	}
    	protected void mouseClicked(int x, int y, int btn){
            super.mouseClicked(x, y, btn);
            this.text.mouseClicked(x, y, btn);
        }
    	protected void actionPerformed (GuiButton gb){
    		tileFurnace.weight(text.getText());
    	}
    }

    And code of the method weight() from TileEntity class:

    @SideOnly(Side.CLIENT)
    	public void weight(String amount){
    		if(slots[0] != null && slots[1] != null){
    			if(slots[1].getItem() instanceof ItemChemical && slots[0].getItem().equals(ItemsManager.itemBeaker)){
    				try{
    					double a = Double.parseDouble(amount);
    					Chemical c = ((ItemChemical)slots[1].getItem()).content;
    					NBTTagCompound tag = slots[1].getTagCompound();
    					double amountInJar = tag.getDouble("amount");
    					if(amountInJar >= a && a>0){
    						Mixture m = new Mixture();
    						m.add(c, a);
    						ItemStack itemstack = new ItemStack(ItemsManager.itemMixture, 1);
    						ItemMixture.setComposition(itemstack, m);
    						slots[0] = itemstack;
    						if(amountInJar > a){
    							tag.setDouble("amount", amountInJar-a);
    						}else{
    							slots[1] = new ItemStack(ItemsManager.itemJar, 1);
    						}
    					}
    				}catch(Exception e){
    				}
    			}
    		}
    	}
    Posted in: Modification Development
  • To post a comment, please .