Jump to content

Recommended Posts

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)

Posted

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.

  Quote

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

Posted

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

Posted
  On 6/10/2013 at 1:29 AM, Ernio said:

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.

Posted

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) :)

  Quote

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

Posted
  On 6/10/2013 at 2:25 PM, Ernio said:

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Looks like some kind of bug with vampiricageing - or a conflict with unusualprehistory
    • Add crash-reports with sites like https://mclo.gs/ Add this mod: https://www.curseforge.com/minecraft/mc-mods/night-config-fixes  
    • Updating to 1.21.8 from 1.21.5 and the recipe book type now throws an error. The exception has written "This is not implemented yet, poke Forge if you actually use this". From net.minecraft.stats.RecipeBookSettings // FORGE -- called automatically on Enum creation - used for serialization     public static void register(RecipeBookType type) {         String name = type.name().toLowerCase(java.util.Locale.ROOT).replace("_","");         var codec = TypeSettings.codec("is" + name + "GuiOpen", "is" + name + "FilteringCraftable");         //TAG_FIELDS.put(type, Pair.of(openTag, filteringTag));         throw new IllegalStateException("This is not implemented yet, poke Forge if you actually use this");     }
    • I am playing a mod (1.16.5) that is heavily modded. I played it for a few hours completely fine but now that I am trying to load in again 6 hours later I crash. I  have 32 gigs of dedicated ram to this mod, and Ive gone into my world save, serverconfigs, and deleted usefulbackpacks-server.toml                 What do I do from here   This is my full crash log from Curseforge at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:61) ~[?:?] at net.minecraftforge.fml.config.ConfigFileTypeHandler$$Lambda$14819/1243247982.apply(Unknown Source) ~[?:?] at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:104) ~[?:?] at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:83) ~[?:?] at net.minecraftforge.fml.config.ConfigTracker$$Lambda$14818/841663910.accept(Unknown Source) ~[?:?] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_51] at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2062) ~[?:1.8.0_51] at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:83) ~[?:?] at net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:94) ~[?:?] at net.minecraft.server.integrated.IntegratedServer.func_71197_b(IntegratedServer.java:59) ~[?:?] at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:621) [?:?] at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) [?:?] at net.minecraft.server.MinecraftServer$$Lambda$21132/2071546526.run(Unknown Source) [?:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.3.jar:?] at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.3.jar:?] at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.3.jar:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.3.jar:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.3.jar:?] at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.3.jar:?] at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:57) ~[?:?] ... 13 more [23:26:44] [Server thread/FATAL]:Preparing crash report with UUID a1e4c58d-8019-4653-affd-236e2af63d55
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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