Jump to content

Registering 2 of the same blocks


Kore

Recommended Posts

Heres the base code you'll need

//Blocks
public static Block fencePistonOn = new BlockFencePiston(1537, Material.piston, true, false);
public static Block fencePistonOff = new BlockFencePiston(1538, Material.piston, false, false).setCreativeTab(CreativeTabs.tabRedstone);

public static Block killFencePistonOn = new BlockFencePiston(1539, Material.piston, true, true);
public static Block killFencePistonOff = new BlockFencePiston(1540, Material.piston, false, true).setCreativeTab(CreativeTabs.tabRedstone);




@Init
public static void init(FMLInitializationEvent e){
	GameRegistry.registerBlock(fencePistonOff, "Fence Piston");
	GameRegistry.registerBlock(killFencePistonOff, "Killer Fence Piston");

	LanguageRegistry.addName(fencePistonOff, "Fence Piston");
	LanguageRegistry.addName(killFencePistonOff, "Killer Fence Piston");
}

 

Alright, so the problem is that both blocks are named Killer Fence Piston, but neither have the killer effect... what did I do wrong, im new to 1.5 modding and a lot has changed.

Thanks for your help

The Korecraft Mod

Link to comment
Share on other sites

you should register all of the blocks

GameRegistry.registerBlock(fencePistonOff, "Fence Piston");
	GameRegistry.registerBlock(killFencePistonOff, "Killer Fence Piston");
GameRegistry.registerBlock(fencePistonOn, "Fence Piston On");
	GameRegistry.registerBlock(killFencePistonOn, "Killer Fence Piston On"); 

Link to comment
Share on other sites

No I dont need to, because you are never going to have the on state block in your hand, but thats not my question, my question is why are they the same names

 

Because the constructor of BlockFencePiston sets the unlocalized name to the same string in both cases.

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

Lets see.

 

You have a constructor which is passed arguments.

 

You have a function that runs in the constructor that needs arguments.

 

There are vanilla blocks that operate in a similar manner.

 

2 + 2 = ?

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

Okay, I have the names sorted out by setting the unlocalized names, but Im probably making a dumb mistake about the killer property... I have it sent into my constructor like so:

 

Base Class

//Blocks
public static Block fencePistonOn = new BlockFencePiston(1537, Material.piston, true, false).setUnlocalizedName("FencePistonOn");
public static Block fencePistonOff = new BlockFencePiston(1538, Material.piston, false, false).setUnlocalizedName("FencePiston").setCreativeTab(CreativeTabs.tabRedstone);

public static Block killFencePistonOn = new BlockFencePiston(1539, Material.piston, true, true).setUnlocalizedName("Killer Fence Piston On");
public static Block killFencePistonOff = new BlockFencePiston(1540, Material.piston, false, true).setUnlocalizedName("Killer Fence Piston").setCreativeTab(CreativeTabs.tabRedstone);

 

And then my constructor:

public boolean active;
public boolean killer;

public BlockFencePiston(int par1, Material par2Material, boolean isOn, boolean doesKill) {
	super(par1, par2Material);
	this.active = isOn;
	this.killer = doesKill;
	if (isOn)
        {
            this.setTickRandomly(true);
        }
}

 

But the code doesn't realize that the killer boolean is true.

The Korecraft Mod

Link to comment
Share on other sites

But the code doesn't realize that the killer boolean is true.

 

What does this mean?

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

So what I mean is that when I call it:

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
    {
	if(this.active){
		if(par5Entity instanceof EntityPlayer)System.out.println(this.killer);
		if(this.killer){
			par5Entity.addVelocity(0.0, 100.0, 0.0);
		}else{
			par5Entity.setFire(10);
		}
    	}
    }

 

Where it says if(par5Entity instanceof EntityPlayer)System.out.println(this.killer);

I'm printing out if it is killer or not when you collide, but it always says false

The Korecraft Mod

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



×
×
  • Create New...

Important Information

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