Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, I've been working on my mod and ran into some problems. Anything that is glowing in red shows an error in the code.

 

package SoldierW518.Soldiers_Mod;

 

import java.util.Random;

import net.minecraft.block.Block;

import net.minecraft.block.BlockOre;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

 

public class IridiumOre extends BlockOre {

public IridiumOre (int id, int texture, Material material) {

[glow=red,2,300]super(id, texture, material);[/glow]

 

setHardness(5.0F);

setStepSound(Block.soundStoneFootstep);

[glow=red,2,300]setBlockName[/glow]("iridiumOre");

setCreativeTab(CreativeTabs.tabBlock);

}

        @Override

public String [glow=red,2,300]getTextureFile()[/glow] {

return CommonProxy.BLOCK_PNG;

}

 

public int idDropped(int par1, Random random, int par2) {

return Soldiers_Mod.iridiumOre.blockID;

}

 

}

 

Any suggestions would be very helpful and feel free to leave them down below!

 

Thanks for any help and for reading,

 

- Justin (SoldierW518)

Use this one... (please read, not copy)

package MyMod.blocks;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Icon;
import net.minecraft.world.World;

import MyMod.Main;

public class BlockOre extends Block
{
public BlockOre (int id, Material material, String Unlocalized)
{
	super(id, material);
		setCreativeTab(CreativeTabs.tabBlock);
		setStepSound(Block.soundMetalFootstep);
		setUnlocalizedName(Unlocalized);
}

public int idDropped (int par1, Random random, int par2)
{
	return this.blockID;
}

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	return this.blockIcon;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
	blockIcon = iconRegister.registerIcon("MyMod:" + getUnlocalizedName().replace("tile.", ""));
}
}

This one:

	blockIcon = iconRegister.registerIcon("MyMod:" + getUnlocalizedName().replace("tile.", ""));

Will call for /minecarft.jar/mods/MyMod/textures/blocks/Unlocalized.png

Where unlocalized is your String.

.replace("tile.", "") - and yes, this is needed.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

So I was looking through your code and I came up with this.

public IridiumOre (int id, Material material, String IridiumOre)
{
super(id, material);
	setCreativeTab(CreativeTabs.tabBlock);
	setStepSound(Block.soundStoneFootstep);
	setUnlocalizedName("IridiumOre");
}

 

Because by the looks of it I could just change the String Variable and that would allow me to use a IridiumOre.png

Use this one... (please read, not copy)

package MyMod.blocks;

import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Icon;
import net.minecraft.world.World;

import MyMod.Main;

public class BlockOre extends Block
{
public BlockOre (int id, Material material, String Unlocalized)
{
	super(id, material);
		setCreativeTab(CreativeTabs.tabBlock);
		setStepSound(Block.soundMetalFootstep);
		setUnlocalizedName(Unlocalized);
}

public int idDropped (int par1, Random random, int par2)
{
	return this.blockID;
}

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	return this.blockIcon;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
	blockIcon = iconRegister.registerIcon("MyMod:" + getUnlocalizedName().replace("tile.", ""));
}
}

This one:

	blockIcon = iconRegister.registerIcon("MyMod:" + getUnlocalizedName().replace("tile.", ""));

Will call for /minecarft.jar/mods/MyMod/textures/blocks/Unlocalized.png

Where unlocalized is your String.

.replace("tile.", "") - and yes, this is needed.

It's easier if you use getUnlocalizedName2(); that doesn't have the "tile."

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

As far as i know, no you don't :)

public Block(int par1, Material par2Material)
{
}

Or maybe there has been changes on 1.5.2? because i am using 1.5.1 (No need to update, will when I'm finished or if I would really need something).

 

As to you Soldier - do you even know how constructors work?

Ok man, look:

You got my code, so you just leave it. Copy to BlockOre.class (or something)

Next go to the MainMod.class and write this:

public static final Block IridiumOre = new BlockOre(1000, Material.rock, "IridiumOre");
//1 - ID, 2 - Material, 3 - Unlocalized name

Now you just need to register block and add IngameName (which you can also do in BlockOre.class by adding more code of course).

 

 

ObsequiousNewt - thanks pal, didn't noticed that, but in BlockOre I personally wont use it (but in other yes) :)

1.7.10 is no longer supported by forge, you are on your own.

As far as i know, no you don't :)

public Block(int par1, Material par2Material)
{
}

Or maybe there has been changes on 1.5.2? because i am using 1.5.1 (No need to update, will when I'm finished or if I would really need something).

Block takes a Material argument. BlockOre doesn't—it's preset to Material.rock.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.