Jump to content

Seigyoku

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by Seigyoku

  1. ####################

    # amethyst ore

    ####################

     

    "amethyst ore" {

        I:block=31541

    }

     

    Ding ding, here's our problem, it looks like. 8) I'll be editing this post as I try to traceback the process.

     

    As for you wondering why your Item IDs are so high, can we see your custom item class? This might actually solve why the config file is doing what it's doing.

     

     

     

    EDIT: Okay, we know now how the config file is messing things up, just not why.

     

    public static Block AmethystOre;

     

    this.AmethystOreID = config.getItem("Amethyst Ore", "block", 3307).getInt();

    this.AmethystOreID = config.getBlock("Amethyst Ore", "block", 3307).getInt();

     

    ####################

    # amethyst ore

    ####################

     

    "amethyst ore" {

        I:block=31541

    }

     

    AmethystOre = new A_MTM_BlockCore(this.AmethystOreID, 23).setBlockName("AmethystOre");

     

    Following that, and looking at what you wrote before:

     

    even when i removed Amethyst from my FULLY coded 19 set

     

    Since the value is already written into the config file and saved, disabling the code doesn't entirely help, you'll have to manually edit the value yourself in there too. See if it behaves changing the value from 31541 to 3307.

  2. as for the new line code of 447 , when i posted this i was still fiddleing around trying to fix it like putting Amethyst into a new core file and pasting it back in may have added a dew extra space lines hence the new number.

     

    Alright, I'm just trying to make sure for myself which of your block variables is giving you a headache. :D One more time to confirm, which one is being a pain, AmethystBlock or AmethystOre?

     

    And i shall have a wonder on that link you posted, do you know how to fix it or are you still figureing it out btw? cause ill feel very stupid if u literally  told me the fix xD

     

    I'm pretty clueless as to how Forge formats config files, but if the error is inside the file, it should be easy enough to spot. Just remember the number, 31541!

  3. That's okay! We all start off trying to figure out our hands from our feet in this sort of hobby. ;)

     

    I'll use what you supplied for hopefully something easier in explaining what's going on:

     

    public A_MTM_BlockCore(int par1, int par2)

      {

        super(par1, par2, Material.rock);

        this.setCreativeTab(CreativeTabs.tabBlock);

      }

     

    more or less means:

     

    public A_MTM_BlockCore(int ID, int texture)

      {

        super(ID, texture, Material.rock);

        this.setCreativeTab(CreativeTabs.tabBlock);

      }

     

    Your textures come from the sprite sheet you supplied for your blocks. That you already figured out, I think, looking at your getTextureFile() method for that class.

     

    So you're initializing AmethystBlock:

     

    AmethystBlock = new A_MTM_BlockCore(this.AmethystBlockID, 39).setBlockName("AmethystBlock");

     

    this.AmethystBlockID is the ID of your AmethystBlock

    39 is the texture index you're using from your supplied sprite sheet

     

    So, there isn't anything wrong with your code so far, actually! But for some reason, your compiler thinks that AmethystBlockID has the value 31541, which is no good to us. Due to that, we have to keep looking:

     

    this.AmethystBlockID = config.getBlock("Amethyst block", "block", 3607).getInt();

     

    This seems to be the real culprit. You supplied a default just-in-case value of 3607, well within the bounds of the block ID array, so the config file should be the cause of your problems. There's a very good chance that there's confusion between item IDs with block IDs in there, as 31541 is suspiciously looking like an item ID.

     

    As for where the config file should be, look in \forge\mcp\jars\config\, is anything that looks like yours in there? Configuration files aren't really known to me yet, so I'm mainly going off of what I see in this link: http://www.minecraftforge.net/wiki/How_to_make_an_advanced_configuration_file

     

     

     

    EDIT: Okay, I checked out your error logs again, the older log marks line 453:

     

    AquamarineBlock = new A_MTM_BlockCore(this.AquamarineBlockID, 36).setBlockName("AquamarineBlock");

     

    while your newer error lists line 447:

     

    AmethystOre = new A_MTM_BlockCore(this.AmethystOreID, 23).setBlockName("AmethystOre");

     

    Both have the same marked issue though, 31541 as an arrayOutOfBoundsException. Why is your compiler spitting out the same problem at different lines of code each time you try to test it? :o

  4. I can explain this simply: When you initialize a block or item, the first parameter usually is the object's ID. The object gets shoved into net.minecraft.block.Block.blocksList[iD] and net.minecraft.item.Item.itemsList[iD] if it's a block, or into net.minecraft.item.Item.itemsList[iD+256] if it's just an item. This is a very important part of initialization, because:

     

    public static final Block[] blocksList = new Block[4096];

     

    public static Item[] itemsList = new Item[32000];

     

    This can't be changed easily unless we alter the base code, or know how to tell Forge to change it for us.

     

    The constructor I showed earlier lets us know how the ID part of the block's initialization is handled:

     

    public Block(int par1, Material par2Material)

        {

            this.blockConstructorCalled = true;

            this.enableStats = true;

            this.stepSound = soundPowderFootstep;

            this.blockParticleGravity = 1.0F;

            this.slipperiness = 0.6F;

     

            if (blocksList[par1] != null)

            {

                throw new IllegalArgumentException("Slot " + par1 + " is already occupied by " + blocksList[par1] + " when adding " + this);

            }

            else

            {

                this.blockMaterial = par2Material;

                blocksList[par1] = this;

                    this.blockID = par1;

                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

                opaqueCubeLookup[par1] = this.isOpaqueCube();

                lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0;

                canBlockGrass[par1] = !par2Material.getCanBlockGrass();

            }

            isDefaultTexture = (getTextureFile() != null && getTextureFile().equalsIgnoreCase("/terrain.png"));

        }

     

    Because of this, calling an index outside of these arrays tend to lead to this kind of compile error.

     

    Some examples straight from Block's variables:

     

    public static final Block stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(soundStoneFootstep).setBlockName("stone");

    public static final Block dirt = (new BlockDirt(3, 2)).setHardness(0.5F).setStepSound(soundGravelFootstep).setBlockName("dirt");

     

    So, we know that Stone Blocks are stored in blocksList[1], and Dirt Blocks are stored in blocksList[3].

     

    Meanwhile, sprite sheet indexing is an entirely different matter, that's handled in a different part of initialization.

     

    super(par1, par2, Material.rock);

     

    That parameter in line 11 of A_MTM_BlockCore.java is your texture index parameter. See the difference?

     

     

     

    End lesson! Moving on:

     

    Your initialization of the block itself seems okay from the surface, but I'd like to see the constructor you're using with line 11 of A_MTM_BlockCore.java just in case. Is that alright?

     

    Meanwhile, the trail ends at your code attempting to pull an ID from your config file. Since you have an in-case ID for AmethystBlock to be 3607, the issue could be within the config file itself. Is there anything that looks like the number 31541 or a similar 5-digit number in there?

  5. 2013-02-14 11:58:33 [iNFO] [sTDERR] java.lang.ArrayIndexOutOfBoundsException: 31541

    2013-02-14 11:58:33 [iNFO] [sTDERR] at net.minecraft.block.Block.<init>(Block.java:324)

    2013-02-14 11:58:33 [iNFO] [sTDERR] at net.minecraft.block.Block.<init>(Block.java:359)

    2013-02-14 11:58:33 [iNFO] [sTDERR] at MeetTheMod.common.A_MTM_BlockCore.<init>(A_MTM_BlockCore.java:11)

    2013-02-14 11:58:33 [iNFO] [sTDERR] at MeetTheMod.common.A_MTM_CORE.load(A_MTM_CORE.java:453)

     

    Nothing i have ID'ed is over 4000 all block ID's are under 256 in there own spriteSheet

     

    I don't know what you're trying to accomplish, but your code is ending up calling index 31541 of net.minecraft.block.Block.blocksList[] for initializing one of your Block variables. As mentioned, the Minecraft base code by default doesn't allow blocksList[] indexes other than 0-4095.

     

    If you're getting confused with "Infinite terrain/sprite indexes", that has to do with the appearance of blocks/items and nothing to do with allocations in ID arrays. If however you're making use of a mod that tweaks the blocksList[] array bounds in the base code, it's not cooperating.

     

    This is where things are hanging up, in order:

     

    #1, line 324 of net.minecraft.block.Block:

     

    public Block(int par1, Material par2Material)

        {

            this.blockConstructorCalled = true;

            this.enableStats = true;

            this.stepSound = soundPowderFootstep;

            this.blockParticleGravity = 1.0F;

            this.slipperiness = 0.6F;

     

          if (blocksList[par1] != null)

            {

                throw new IllegalArgumentException("Slot " + par1 + " is already occupied by " + blocksList[par1] + " when adding " + this);

            }

            else

            {

                this.blockMaterial = par2Material;

                blocksList[par1] = this;

                this.blockID = par1;

                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

                opaqueCubeLookup[par1] = this.isOpaqueCube();

                lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0;

                canBlockGrass[par1] = !par2Material.getCanBlockGrass();

            }

            isDefaultTexture = (getTextureFile() != null && getTextureFile().equalsIgnoreCase("/terrain.png"));

        }

     

    #2: Line 359 of net.minecraft.block.Block:

     

    public Block(int par1, int par2, Material par3Material)

        {

            this(par1, par3Material);

            this.blockIndexInTexture = par2;

        }

     

    #3 and #4 have to do with the code you're using for your mod. Mind showing us what line 11 of A_MTM_BlockCore.java and line 453 of A_MTM_CORE.java are, and the related methods where said lines are contained?

  6. Okay, that might actually be part of the problem... Europa is a 2007 release, meant for JRE 5. :(

     

    We can go two routes at this point:

     

    1.) Scrap Europa and download a newer version of Eclipse, see if it does the same thing with the workspace

    2.) Continue working with this, see if we can get anywhere with this, I doubt this compiler is going to be helpful though

     

    Assuming you want to continue on this, use Edit and there hopefully will be a "Browse..." button next to Linked Folder Location. Try to get it to match up with your intended directory if there is.

  7. *blinkblinks* ...Well, that explains the real problem. ???

     

    While this is going on, which Eclipse are you using?

     

    Let's tackle this another way then:

     

    -Right-click src back in the Project Explorer, Build Path, Configure Build Path (We're going back to Java Build Path, this is just another way to do it for what we want right now)

    -Because of what you showed before, the Source tab should be empty of any entries. Does "Add Folder..." and "Edit..." appear?

  8. Alternatively, when initializing the food, you can use

     

    .setPotionEffect(int potionID, int durationInSeconds, int amplifier, int chance (1.0F being 100%))

     

    This is actually what the rawChicken and rottenFlesh items in net.minecraft.item.Item do, since there isn't a class extended from ItemFood for them:

     

    public static Item chickenRaw = (new ItemFood(109, 2, 0.3F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.3F).setIconCoord(9, 7).setItemName("chickenRaw");

    public static Item rottenFlesh = (new ItemFood(111, 4, 0.1F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.8F).setIconCoord(11, 5).setItemName("rottenFlesh");

     

    Both effects last 30 seconds, and Raw Chicken has a 30% chance of the effect kicking in while Rotten Flesh has an 80% chance of this happening.

     

    This is much simpler than using onFoodEaten, but that method allows you to have multiple potion effects occur at once, so I'll go over that as well.

     

    Concerning ItemFood's onFoodEaten method, the example used within the code is actually handled within a method that onFoodEaten calls and extended classes can override:

     

    public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

        {

            --par1ItemStack.stackSize;

            par3EntityPlayer.getFoodStats().addStats(this);

            par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F);

            this.func_77849_c(par1ItemStack, par2World, par3EntityPlayer);

            return par1ItemStack;

        }

     

    As for the method itself, also found in ItemFood:

     

    protected void func_77849_c(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

        {

            if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability)

            {

                par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));

            }

        }

     

    The method name is currently obfuscated, but can be seen overridden in examples like ItemAppleGold:

     

    protected void func_77849_c(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

        {

            if (par1ItemStack.getItemDamage() > 0)

            {

                if (!par2World.isRemote)

                {

                    par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3));

                    par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));

                    par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));

                }

            }

            else

            {

                super.func_77849_c(par1ItemStack, par2World, par3EntityPlayer);

            }

        }

     

    This example allows for the Enchanted Golden Apple (checked via the "if (par1ItemStack.getItemDamage() > 0)" statement) to provide 30 seconds of Regeneration IV, 5 minutes of Resistance, and 5 minutes of Fire Resistance.

     

    Divide all values by 20 for parameter #2 of PotionEffect to figure out how many seconds an effect lasts doing this. This is different than how the setPotionEffect method works when initializing an item, so be careful not to mix this up!

     

    There are pros and cons to using either approach, use the one that better suits what you want to do. ;)

  9. Good, half the problem is fixed! ;D Now for the other half:

     

    -Right-click the src you have highlighted in your image, select Properties

    -What's the Location and Resolved Location looking like? It should be something like MCP_LOC\src\minecraft & C:\whatever\forge\mcp\src\minecraft respectively

    -Click the "Edit..." button next to Location

    -Verify that it's actually pointing to \forge\mcp\src\minecraft via "Folder..."

     

    Fingers crossed!

  10. No problem, this is an odd one.  ???

     

    Here, try this out:

     

    -Right-click the project, select Properties

    -Go to Java Build Path, Libraries tab

    -Are any errors listed? Are the "missing" files there despite what it said earlier?

    -If the JARs aren't there, manually add them from \mcp\jars\bin and \mcp\lib. If they are though, first remove them and then re-add them.

     

    Let's see if this works out.

  11. I found this thread that might help shed some light on things: http://www.minecraftforge.net/forum/index.php/topic,3389.0.html

     

    I'm not sure how good the solved code is nowadays, but some things I noticed:

     

    -Since a Tile Entity is involved, it might be better to use a custom Tile Entity renderer, like they mention and write an example of later in the thread, rather than use the block rendering handlers.

    -BlockVelvetTable.java, which extends BlockContainer, uses the getTextureFile() method we're more familiar with. Maybe BlockMVBattery.java should do the same, since it also extends BlockContainer?

  12. I don't think there's a Forge Event for blocks breaking... but there is a Forge Event for LivingDropsEvent that should be helpful, if you want the item to drop from living entities in the World.

     

    From http://www.minecraftforge.net/wiki/Event_Reference#LivingDropsEvent :

     

    LivingDropsEvent

     

    Used to drop items when a living entity dies.

     

    Fields:

     

    DamageSource source - the source of the damage killing the entity

     

    ArrayList<EntityItem> drops - the list of items the entity will drop, add or remove to this list

     

    int lootingLevel - in vanilla Minecraft this is affected by the Looting enchantment

     

    boolean recentlyHit - whether the entity was hit recently before its death

     

    int specialDropValue - a random integer between 0 and 200 subtracted the looting level. In Vanilla Minecraft this must be below 5 to make a rare drop.

     

    Calling source.getEntity() will return an Entity if the damage source is an entity or null otherwise.

     

    This event is cancelable, so calling event.setCanceled(true) will cause the entity to drop nothing.

     

    It's possible inside the event method (the name doesn't matter) you can make while writing an event class (this name however does!) with this example code:

     

    public class YourModLivingDropsEvent {
    
        private EntityLiving entityDying;
        private DamageSource source;
        private ArrayList<EntityItem> drops;
        private int lootingLevel;
        private boolean recentlyHit;
        private int specialDropValue;
    
        @ForgeSubscribe
        public void entityDrops(LivingDropsEvent event) {
    
            entityDying = event.entityLiving;
            source = event.source;		
            drops = event.drops;		
            lootingLevel = event.lootingLevel;
            recentlyHit = event.recentlyHit;
            specialDropValue = event.specialDropValue;
    
            if (entityDying.getClass() == EntitySpider.class) {
                entityDying.dropItem(someItem.itemID, 1);
            }
        }
    }
    

     

    to force it to drop an item from the normal spiders already coded in. Take a look through net.minecraft.entity.*.* to see what other living entities you can make things drop from. If you really want, you could opt to not use the if statement at all for it to drop from all living entities, I believe even players.

     

    If you want a drop chance involved, create "Random r = new Random();" (or grab one of the Randoms already working in the Minecraft instance, whichever works) and use something like "if ((r.nextInt(100) + 1) <= 75))" (75 being 75-out-of-100 or 75% chance) inside the first if statement:

     

    Random r = new Random();
    
    public void entityDrops(LivingDropsEvent event) {
    
        if (entityDying.getClass() == EntitySpider.class) {
            if ((r.nextInt(100) + 1) <= 75)) entityDying.dropItem(someItem.itemID, 1);
        }
    }
    

     

    After that, register your event class (remember how I said the name mattered?) inside the preInit method of your mod (I don't know if init works just as well, preInit works for me though):

     

    @PreInit
    public void preInit(FMLPreInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(new YourModLivingDropEvent());
    }
    

     

    And voila, done!

  13. This is very much a shot in the dark since I'm not very familiar with Block/TileEntity modding yet, but would part of the answer be in net.minecraft.block.BlockRedstoneLight in order to do this? Redstone Lamps can only remain lit if they have power, which is similar to what you want, I think. I'm sure any other Redstone block will also be of help, but this seems to be the simplest case, since it otherwise acts like a simple lighting block.

     

    After that, you'll probably have to thumb through net.minecraft.tileentity.TileEntityFurnace and net.minecraft.block.BlockFurnace to figure out how to implement the idea. By glancing at the code, BlockFurnace controls external interaction with the World and Players, while TileEntityFurnace controls the internal burning process.

  14. Hello there, the ItemArmor class is a little trickier to work with than other things, mainly due to how it handles rendering its armor. I'm personally awed that you're trying this as a first project, so kudos on your progress. 8)

     

    I decided to take the time today to learn about custom armor rendering thanks to this topic, and I'm glad I managed to solve it before the night was over.

     

    You can find my source code on an example of how to do so here: https://github.com/Seigyoku/customarmortest

     

    This is my first time working with GitHub, and it sadly doesn't make use of IArmorTextureProvider, but I hope it's of help all the same!

  15. Hello, I've been an aspiring modder for at least a month now, learning the ropes concept-by-concept.

     

    Long story short, I've encountered this problem: I did the number-crunching and realized that, even with metadata-ing blocks, we can only load about 200-250 texture files if we assign all the block IDs to have one texture index per block's metadata value (4096/256 = 16, 16 x 16 = 256, less if we consider current vanilla Block/Item ID allocations). I know that MCForge is touted as having "Infinite Terrain/Sprite Indexes", but we're still limited by the ID arrays unless we go in the source code and mess with it. I don't want to do that, and would prefer a solution that doesn't make me have to do it.

     

    The reason I'm having this problem is, to be truthful, I have a project in mind that uses more than 1,000 texture files, which is far and beyond the current capacity of the Block ID array. The blocks in mind will have no logic to them and are only intended for display. If anyone have any ideas to help me with this problem, it'd be greatly appreciated. :D I'm sure there's a possible solution and that I just haven't found it yet.

×
×
  • Create New...

Important Information

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