Jump to content

Block Ore Errors


SoldierW518

Recommended Posts

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

    • [SOLVED]  public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Text event){ Client.hud.draw(); } } As I was playing around a little with the code, i found out about an option to change The RenderGameOverlayEvent.Post to RenderGameOverlayEvent.Text
    • public class HUD { public Minecraft mc = Minecraft.getMinecraft(); public static class ModuleComparator implements Comparator<Module>{ @Override public int compare(Module o1, Module o2) { if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) > Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return -1; } if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) < Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return 1; } return 0; } } public void draw(){ ScaledResolution sr = new ScaledResolution(mc); FontRenderer fr = mc.fontRendererObj; Collections.sort(Client.modules, new ModuleComparator()); GlStateManager.pushMatrix(); GlStateManager.translate(4,4,0); GlStateManager.scale(1.5,1.5,1); GlStateManager.translate(-4, -4, 0); fr.drawString("Skyline", 10, 10, -1); GlStateManager.popMatrix(); int count = 0; for (Module m : Client.modules){ if (!m.toggled || m.name.equals("TabGUI")) continue; int offset = count* (fr.FONT_HEIGHT + 6); GL11.glTranslated(0.0f, 0.0f, -1.0f); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 10, offset, sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, 6 + fr.FONT_HEIGHT + offset, -1); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, offset, sr.getScaledWidth(), 6 + fr.FONT_HEIGHT + offset, 0x90000000); fr.drawString(m.name, sr.getScaledWidth() - fr.getStringWidth(m.name) - 4, offset + 4, -1); count++; } Client.onEvent(new EventRenderGUI()); } } I have just recently stumbled upon this Problem, where the HudRenderer renders the wrong section of the textures and therefore completely destroys the Minecraft Armour and Hunger Bar. I am currently thinking if it is an issue with the DrawRect changing something it shouldn't. But I couldn't find anything about it. (To keep things Clean, the function is Called from another file) public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Post event){ Client.hud.draw(); } } Any help would be greatly appreciated  
    • Hello, I play on a private server (forge 47.2.0) (about 200 mods) with my friends. Everything is normal until the game crashes. I assume it's due to the generation of a chunk, possibly in a biome from the Aquamirae mod. Caused by: java.lang.NullPointerException: No chunk exists at [9, 38]     at net.minecraft.server.level.WorldGenRegion.m_6325_(WorldGenRegion.java:2079) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.server.level.WorldGenRegion.m_6924_(WorldGenRegion.java:375) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.levelgen.structure.structures.ShipwreckPieces$ShipwreckPiece.m_213694_(ShipwreckPieces.java:127) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.levelgen.structure.StructureStart.m_226850_(StructureStart.java:90) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.chunk.ChunkGenerator.m_223080_(ChunkGenerator.java:320) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422) ~[guava-31.1-jre.jar%2374!/:?]     at net.minecraft.world.level.chunk.ChunkGenerator.m_213609_(ChunkGenerator.java:319) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.chunk.ChunkStatus.m_279978_(ChunkStatus.java:108) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.chunk.ChunkStatus$SimpleGenerationTask.m_214024_(ChunkStatus.java:309) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.world.level.chunk.ChunkStatus.m_280308_(ChunkStatus.java:252) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at net.minecraft.server.level.ChunkMap.lambda$scheduleChunkGeneration$27(ChunkMap.java:643) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-6.0.8.jar%2377!/:?]     at net.minecraft.server.level.ChunkMap.lambda$scheduleChunkGeneration$29(ChunkMap.java:634) ~[server-1.20.1-20230612.114412-srg.jar%23375!/:?]     at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]     ... 11 more
    • that fixed it! Thank you soo much!!! If there is a way I can like upvote your profile or something let me know!
    • Also add the latest.log from the server after such disconnects
  • Topics

×
×
  • Create New...

Important Information

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