Jump to content

Recommended Posts

Posted

Just as how if you mine stone you get cobblestone (unless you use silk touch), I am trying to make it so that when basalt stone (added by me) is mined, it drops basalt cobblestone from IC2 (it's not actually basalt cobblestone, but it looks cobble-y).

I have this working for another stone I've added, but for that I added the cobble myself. It's the ore dict part I'm having trouble with.

 

According to the many tutorials I've looked at, you import "net.minecraftforge.oredict.OreDictionary", and in the 'getItemDropped' section instead of "return Item.getItemFromBlock(ModBlocks.basaltCobblestone);" one uses "return Item.getItemFromBlock(:blockBasalt);". Eclipse then tells me "blockBasalt cannot be resolved to a variable".

 

If I instead try "return Item.getItemFromBlock("blockBasalt");", "blockBasalt" shows up blue and the error reads "The method getItemFromBlock(Block) in the type Item is not applicable for the arguments (String)".

 

And combining the two "return Item.getItemFromBlock(":blockBasalt");", gives me the same error as the previous.

 

A lot of the tutorials/information on the ore dictionary (and Forge in general, depending on what aspects you're looking at) seem like they are for earlier versions, and so potentially out dated. The 'How to use the ore dictionary' tutorial is for 1.6.4, and I'm not sure how much regarding this has changed since then.

 

My block.class:

 

 

package com.fallingkitten.abstractadditions.blocks;

 

import java.util.Random;

 

import com.fallingkitten.abstractadditions.lib.Constants;

 

import cpw.mods.fml.common.registry.GameRegistry;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraftforge.oredict.OreDictionary;

 

public class BlockBasaltStone extends Block

{

 

private String name = "basaltStone";

 

public BlockBasaltStone()

{

super(Material.rock);

this.setBlockName(Constants.MODID + "_" + name);

                setBlockTextureName(Constants.MODID + ":" + name);

GameRegistry.registerBlock(this, name);

this.setCreativeTab(CreativeTabs.tabBlock);

setHardness(20.0F);

setResistance(45.0F);

setHarvestLevel("pickaxe", 0);

}

 

    @Override

    public Item getItemDropped(int metadata, Random random, int fortune) {

        return Item.getItemFromBlock(":blockBasalt");

    }

   

    @Override

    protected boolean canSilkHarvest()

    {

        return true;

    }

}

 

 

 

If anyone could help, that would be appreciated. Or point me in the direction of an up to date and informative tutorial.

Posted

1. You should understand basic java for modding.

2. OreDictionary#getOres(String name) gives List of Itemstack registered with the oredict id.

You could use first entry of it. (ofc you should check if the list is empty before that)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Yes, I realise the purpose of the ore dictionary. The fact that it is an IC2 block is incidental, in theory I want this to work with any basalt added by any mod (but IC2 is the only one I know of, and the only one I use that does, hence the mention of IC2). So going from that, I shouldn't have to specify IC2 in the code, should I? Else that would suggest that when drawing from the ore dictionary one would have to specify, say, all the copper ingots from all the mods which have them, and from what I've read that's not how it works.

 

Abastro, some people learn best by effectively poking at and playing with something, getting it wrong, and going from there.

 

Moving on, does anyone have some helpful input for me?

Posted
I want this to work with any basalt added by any mod

 

Drop your own block registered with the oreDict, the translation to any other basalt is what the ore dict DOES.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I want this to work with any basalt added by any mod

 

Drop your own block registered with the oreDict, the translation to any other basalt is what the ore dict DOES.

He might not want to add his own basalt block. Yes dropping another mods oredict item is not appropriate, but anyway he could want that.

 

@fallingkitten

Anyway, as @Draco18 said creating your own Bassalt block and registering it to the OreDict is better way.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Oh, sure you could use another block from the oreDict, that'd be fine too. :)

You just don't need to care which one.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

If I understand what the original poster is trying to do, I think Abastro's recommendation to get the list of ores from the ore dict and work with that seems like the best approach. You could drop the first thing in the list, or randomize which one comes out. Like if 5 mods for some reason all added basalt then you could randomly choose from the list.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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

    • Hello , when I try to launch the forge installer it just crash with a message for 0,5 secondes. I'm using java 17 to launch it. Here's the link of the error :https://cdn.corenexis.com/view/?img=d/ma24/qs7u4U.jpg  
    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
  • Topics

×
×
  • Create New...

Important Information

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