Jump to content

Recommended Posts

Posted

I have a problem with my ore being generated and it doesn't accept the texture code. First it was only the texture but I thought I will deal with it later. Then when I added water generation (like the clay generation code) it wouldn't generate.

 

Main class:

 

  Reveal hidden contents

 

 

Ore class

 

  Reveal hidden contents

 

 

Ore generation class

 

  Reveal hidden contents

 

Posted
  On 11/29/2013 at 10:40 PM, Sirpwnsamin said:

To fix the texture bug, instead of RegisterIcons (), add this.setTextureName("FirstMod:RedOre") under this.setResistance

The more advanced way of doing that is adding this method to your block class. It allows more control for all the sides and stuff, just for later purpose.

package first.mod.block;

// imports

public class RedOre extends Block{

   public RedOre(int par1, Material par2Material) {
      super(par1, par2Material);
      this.setCreativeTab(Base.TabRed);
      this.setHardness(10);
      this.setResistance(5);
   }
   
  @SideOnly( Side.CLIENT )
   public void RegisterIcons(IconRegister iconRegister){
      blockIcon = iconRegister.registerIcon("FirstMod:RedOre");
   }
   
   @SideOnly( Side.CLIENT )
   public Icont getIcon(int side, int meta ) {
       return this.blockIcon;
   }
   
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return Base.RedThing.itemID;
    }
}

this.setTextureName does this automatically, but I still wanted to point that out.

 

And for the not generating part.. just check this really nice tutorial for that, I mean you need IWorldGenerator and you need to register it with GameRegistry.registerWorldGenerator( x.class ); in your FMLInitializationEvent.

 

Anyway, just check this tutorial out for that.

I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!

Posted

OK so it is spawning and accepting texture now only 1 more thing. I set up this code so it would generate in the ocean but I didn't found it anywhere. It didn't generate. Why?

System.out.println is only for validating it spawned it prints it but I can't find it.

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
        if (world.getBiomeGenForCoords(chunkX, chunkZ) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

Posted

Would this workout?

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
		int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
		if (world.getBiomeGenForCoords(firstBlockXCoord, firstBlockZCoord) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	 firstBlockXCoord = chunkX + rand.nextInt(16);
        	 firstBlockYCoord = rand.nextInt(32);
        	 firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

 

The ocean is huge so I don't know how much time would it take to find it.

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

    • Hey! I noticed you're trying to register your alexandrite item and possibly set its resource location manually with setId(...). I wanted to help clarify a few things that might simplify your code and avoid errors. ✅ The issue: You're using setId(...) inside the item registration like this:   public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties().useItemDescriptionPrefix() .setId(ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, "alexandrite"))))); But: Item.Properties does not have a setId(...) method — this line will either fail or do nothing meaningful. useItemDescriptionPrefix() is mostly used for translation keys (like "item.modid.name") but isn't needed unless you have a very specific reason. 🛠 The fix: You only need to register your item like this:   public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties())); Forge automatically handles the ResourceLocation (modid:alexandrite) based on the name passed into .register(...), so there’s no need to manually assign it. 📝 For the texture: Make sure you have this file in your resources: src/main/resources/assets/tutorialmod/models/item/alexandrite.json { "parent": "item/generated", "textures": { "layer0": "tutorialmod:item/alexandrite" } } And your texture PNG goes here: src/main/resources/assets/tutorialmod/textures/item/alexandrite.png 🌍 For the name in-game: Add this to your en_us.json under: src/main/resources/assets/tutorialmod/lang/en_us.json { "item.tutorialmod.alexandrite": "Alexandrite" }   Note: if im wrong about the issues you are encountering, i apologize.
    • 🛠️ Fix for Transparent or Clipping Item Render Issues When Held in First Person (Forge 1.20+) Hey everyone! I recently ran into a frustrating bug while making a custom item (a rocket) for my Forge mod, and I’m sharing the fix because it’s a bit obscure — and it worked wonders. 💥 The Problem: My item rendered semi-transparent and see-through — but only in first person. It also clipped through nearby blocks when held, unlike default items like swords or leads. The texture file was confirmed to be fully opaque (alpha 255), so the issue wasn’t the PNG itself. Interestingly, when no texture was present and the default purple-black checkerboard appeared, the clipping issue disappeared. ✅ The Fix: I ended up resolving it by randomly trying something I found on a Forge forum post about block rendering. I added this property to my item's model JSON — even though it's typically only used for blocks: { "parent": "item/generated", "textures": { "layer0": "farbeyond:item/rocket_item" }, "render_type": "minecraft:cutout" } Boom. That single line forced the item to render using a proper opaque (cutout) layer, removing all the unwanted transparency and clipping behavior in first person. 🙌 Credit: I originally found the "render_type" trick mentioned here, in a block rendering context: 👉 https://forums.minecraftforge.net/topic/149644-1201-help-with-transparent-blocks/ Even though it was meant for blocks, I thought, why not try it on an item? And it worked! Big thanks to the poster — this fix wouldn’t have happened without that tip. Hopefully this helps anyone else stuck on a weird rendering bug like I was. This isn’t a common item solution, so feel free to share it further. I’d love to know if it works for you too.
    • Use Java 21 instead of Java 24   Also make a test without modernfix
    • Ive been on this world for 2 days now, my computer blue screens pretty often so maybe that has something to do with it. maybe just incompatible mods like a lot of people so im hoping someone more knowledgeable can help me find what i need to get rid of. thank you! paste bin
    • Should probably say that i am running minecraft 1.21.1 and with quite a lot of mods (many of which im unsure should even be on the server side)
  • Topics

×
×
  • Create New...

Important Information

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