Jump to content

1.8 CreativeTabs crash


BlazeAxtrius

Recommended Posts

public static final CreativeTabs tabNormalRails = new CreativeTabs(modid+"tabNormalRails") {
        public ItemStack getIconItemStack() {
                return new ItemStack(ERMBase.diamondRail, 1, 0);
        }

	@Override
	public Item getTabIconItem() {
		// TODO Auto-generated method stub
		return null;
	}

 

The game start normally but when I try to get to the second page in the inventory, the game crashes. This code is in the main mod file.

Link to comment
Share on other sites

Is diamond rail a block or an item

item

 

Its a block.

By crikey dude, what did you think this line would do? :)

 

	@Override
	public Item getTabIconItem() {
		// TODO Auto-generated method stub
		return null;

 

and where did this method come from?

getIconItemStack()

 

This tutorial might help...

http://tutorials.darkhax.net/custom-creative-tabs.html

 

-TGG

 

I used a tutorial to make it. The idea is that these rails are blocks and not items. That is why Item getTabIconItem() doesn't work and I use the ItemStack getIconItemStack()

 

Here is my github btw. https://github.com/BlazeAxtrius/ExpandedRailsMod

Link to comment
Share on other sites

I used a tutorial to make it. The idea is that these rails are blocks and not items. That is why Item getTabIconItem() doesn't work and I use the ItemStack getIconItemStack()

 

Here is my github btw. https://github.com/BlazeAxtrius/ExpandedRailsMod

your getIconItemStack() method does nothing because no code ever calls it.

 

When your creative tab is rendered, it calls the getTabIconItem() method to find out which Item's icon it should draw on the tab.  You return null, the caller tries to draw it, and crashes because it expects a proper item.  Your getTabIconItem() method needs to return the block's corresponding item as Voltab suggested.

 

Which tutorial did you use? 

 

-TGG

Link to comment
Share on other sites

Yes but itemstack looks for an item therefore you need to use Item.getItemFromBlock(yourBlock)

 

I changed the code however the game still crashed when I click the arrow that leads to my customtabs.

Eclipse doesn't show any errors.

 

public static final CreativeTabs tabNormalRails = new CreativeTabs(modid+"tabNormalRails") {

	public Item getTabIconItem() {
		// TODO Auto-generated method stub
		return Item.getItemFromBlock(diamondRail);
	}

 

I used a tutorial to make it. The idea is that these rails are blocks and not items. That is why Item getTabIconItem() doesn't work and I use the ItemStack getIconItemStack()

 

Here is my github btw. https://github.com/BlazeAxtrius/ExpandedRailsMod

your getIconItemStack() method does nothing because no code ever calls it.

 

When your creative tab is rendered, it calls the getTabIconItem() method to find out which Item's icon it should draw on the tab.  You return null, the caller tries to draw it, and crashes because it expects a proper item.  Your getTabIconItem() method needs to return the block's corresponding item as Voltab suggested.

 

Which tutorial did you use? 

 

-TGG

 

i have no memory. I updated to the mod to 1.6.4 (that was 1 year ago) and then i decided to make the Tabs. I changed my PC so I don't have it in my history otherwise it was going to be easy.

Link to comment
Share on other sites

Ok. I fixed it.

 

I am extremely retarded. I was using "rails" that i have excluded from the mod because I don't know how to

fix .getBlock and .getBlockMetadata.

 

Some rails have properties and I have excluded them so I can fix the rest that just rails.

If you can help me fix that too that will be great.

 

Here is how a rail with properties looks. I put 2 because one of them didn't have .getBlock.

 

package com.expanded.rails.mod.rails;

import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.world.World;

public class DiamondRail extends AllRails
{

    public DiamondRail(int par1)
    {
        super(par1);
        setHardness(0.7F);
        setStepSound(Block.soundTypeMetal);
        setUnlocalizedName("expandedrails:DiamondRail");
        // TODO Auto-generated constructor stub
    }

    public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z)
    {
        return 0.5f;
    }

    public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z)
    {
        int blockMetaData = world.[b]getBlockMetadata[/b](x, y, z);

        if ((blockMetaData & 0x8) == 0)
        {
            {
                cart.motionX *= 3.5D;
                cart.motionY *= 0.0D;
                cart.motionZ *= 3.5D;
            }
        }
    }
}

 

package com.expanded.rails.mod.rails;

import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.world.World;

import com.expanded.rails.mod.ERMBase;

public class ArmedRail extends AllRails
{

    public ArmedRail(int par1)
    {
        super(par1);
        setHardness(0.7F);
        setStepSound(Block.soundTypeMetal);
        setUnlocalizedName("expandedrails:ArmedRail");
        // TODO Auto-generated constructor stub
    }

    public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z)
    {
        if ([b]world.getBlock[/b](x, y, z) == ERMBase.armedRail)
        {
            int blockMetaData = [b]world.getBlockMetadata[/b](x, y, z);
            world.createExplosion(cart, x, y, z, 0.3F, false);
            world.newExplosion(cart, x, y, z, 3.5F, true, true);
        }
    }
}

Link to comment
Share on other sites

Ok. I fixed it.

 

I am extremely retarded. I was using "rails" that i have excluded from the mod because I don't know how to

fix .getBlock and .getBlockMetadata.

 

It might have something to do with getBlockState....

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.

Link to comment
Share on other sites

Ok. I fixed it.

 

I am extremely retarded. I was using "rails" that i have excluded from the mod because I don't know how to

fix .getBlock and .getBlockMetadata.

 

It might have something to do with getBlockState....

 

I read something about that, however with .getBlockState I don't know how to make it work. .getBlockState requires (blockpos1) but my method uses (x, y, z) and it doesn't work this way.

 

Also the Tabs names are (itemgroup.NoralmRails). How can I remove the "itemgroup." thing?

Link to comment
Share on other sites

I read something about that, however with .getBlockState I don't know how to make it work. .getBlockState requires (blockpos1) but my method uses (x, y, z) and it doesn't work this way.

 

God damn.  I wonder what a BlockPos is...

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.

Link to comment
Share on other sites

I read something about that, however with .getBlockState I don't know how to make it work. .getBlockState requires (blockpos1) but my method uses (x, y, z) and it doesn't work this way.

 

God damn.  I wonder what a BlockPos is...

 

you description is really accurate :D. I don't know how to write it man.

public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z)

It doesn't accept "int" when i put .getBlockState.

Link to comment
Share on other sites

No fucking shit.  All of the x, y, z position coordinates for blocks changed to BlockPos.  Use it.

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.

Link to comment
Share on other sites

No fucking shit.  All of the x, y, z position coordinates for blocks changed to BlockPos.  Use it.

 

public void onMinecartPass(World world, EntityMinecart cart, BlockPos pos1, int x, int y, int z)
    {
        if (world.getBlockState(pos1).getBlock() == ERMBase.armedRail)
        {
            IBlockState blockMetaData = world.getBlockState(pos1);
            world.createExplosion(cart, x, y, z, 0.3F, false);
            world.newExplosion(cart, x, y, z, 3.5F, true, true);
        }
    }

 

I changed the code in this and it doesn't show any errors, but this rail is supposed to explode when the cart passes it, which it doesn't do. I don't understand why it doesn't explode.

 

Also I don't know how to fix this or do i even need it. The BOLD part.

 

public void onMinecartPass(World world, EntityMinecart cart, BlockPos pos1, int x, int y, int z)
    {
        IBlockState blockMetaData = world.getBlockState(pos1);

        [b]if ((blockMetaData & 0x8) == 0)[/b]
        {
            {
                cart.motionX *= 3.5D;
                cart.motionY *= 0.0D;
                cart.motionZ *= 3.5D;
            }
        }

Link to comment
Share on other sites

Put @Override on the line above the function.  What happens?

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.

Link to comment
Share on other sites

Put @Override on the line above the function.  What happens?

 

It shows an error "The method onMinecartPass must override or implement a supertype method.

Solutions shown are

"Create onMinecartPass() in super type AllRails"

"Create onMinecartPass() in super type ExpandedRails"

"Remove @Override annotation"

Link to comment
Share on other sites

Le gasp!  Your method signature is wrong and its not being called from anywhere!

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.

Link to comment
Share on other sites

No fucking shit.  All of the x, y, z position coordinates for blocks changed to BlockPos. Use it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Convert "int x, int y, int z" to BlockPos(x, y, z).

 

Fuck.  This is basic java.

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.

Link to comment
Share on other sites

Convert "int x, int y, int z" to BlockPos(x, y, z).

 

Fuck.  This is basic java.

 

public void onMinecartPass(World world, EntityMinecart cart, BlockPos pos1)
    {
        if (world.getBlockState(pos1) == ERMBase.chainRail)
        {
            IBlockState blockMetaData = world.getBlockState(pos1);
            double var41 = Math.sqrt(cart.motionX * cart.motionX + cart.motionZ * cart.motionZ);

            if (var41 < 0.05D)
            {
                double var43 = 0.1D;
                cart.motionX += cart.motionX / var41 * var43;
                cart.motionZ += cart.motionZ / var41 * var43;
            }
            else
            {
                cart.motionX += 0.0D;
                cart.motionZ += 0.0D;
            }
        }

 

In this rail it doesn't show any errors and the @Override works but it still doesn't work.

Also If i try to convert it from "int x, int y, int z" to BlockPos.

getBlockState() requires 1 BlockPos while createExplosion requires 3 int and I have no idea how to do that.

I tried to fix it but when i go over the rail the game crashes.

 

Also it might be basic java but I made this with a friend from watching tutorials and I have no idea what I am doing right now but I still want to make the mod work.

Link to comment
Share on other sites

getBlockState() requires 1 BlockPos while createExplosion requires 3 int and I have no idea how to do that.

 

BlockPos.x?  Jesus.

It might be xpos, or posx, I haven't actually used 1.8 yet, but I can't imagine its that difficult.

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.

Link to comment
Share on other sites

getBlockState returns an IBlockState. It will never be equal to a Block.

 

Thanks I fixed it now. But

 

public void onMinecartPass(World worldObj, EntityMinecart cart, BlockPos pos1)
    {
        if (worldObj.getBlockState(pos1).getBlock() == ERMBase.armedRail)
        {
            IBlockState blockMetaData = worldObj.getBlockState(pos1);
            worldObj.createExplosion(cart, [b]x, y, z[/b], 0.3F, false);
            worldObj.newExplosion(cart, [b]x, y, z[/b], 3.5F, true, true);
        }
    }

 

Ths BOLD things I dont know how to fix

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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