Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Registering 2 of the same blocks
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Kore

Registering 2 of the same blocks

By Kore, June 19, 2013 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 19, 2013

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

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 20, 2013

Please Help, Thanks!

  • Quote

Share this post


Link to post
Share on other sites

wookiederk    0

wookiederk

wookiederk    0

  • Stone Miner
  • wookiederk
  • Members
  • 0
  • 77 posts
Posted June 20, 2013

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"); 

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 20, 2013

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

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2089

Draco18s

Draco18s    2089

  • Reality Controller
  • Draco18s
  • Members
  • 2089
  • 13986 posts
Posted June 20, 2013

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.

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 20, 2013

how could i do this?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2089

Draco18s

Draco18s    2089

  • Reality Controller
  • Draco18s
  • Members
  • 2089
  • 13986 posts
Posted June 20, 2013

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 = ?

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 20, 2013

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.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2089

Draco18s

Draco18s    2089

  • Reality Controller
  • Draco18s
  • Members
  • 2089
  • 13986 posts
Posted June 20, 2013

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

 

What does this mean?

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 20, 2013

I have it in the contructor make the killer boolean true when I make the blocks, but when I try to use the killer variable, it only shows up as false.

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 23, 2013

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

  • Quote

Share this post


Link to post
Share on other sites

Kore    23

Kore

Kore    23

  • Creeper Killer
  • Kore
  • Forge Modder
  • 23
  • 239 posts
Posted June 23, 2013

Nevermind, I found the problem...

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Kangoro
      Mc Forge 1.14.4

      By Kangoro · Posted 7 minutes ago

      Where do I find it? and i copy paste here or in other web and link here?
    • thedarkcolour
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour · Posted 19 minutes ago

      Now it just freezes with no error at all.
    • thedarkcolour
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour · Posted 20 minutes ago

      I just realized what I've done. I forgot to make the BeeNestGenerator method static. I'll check if that fixes it.
    • thedarkcolour
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour · Posted 24 minutes ago

      BeeNestGenerator class
    • diesieben07
      1.89 crash forge

      By diesieben07 · Posted 1 hour ago

      1.8.9 is no longer supported on this forum due to it's age. Update to a modern version of Minecraft to receive support.
  • Topics

    • Kangoro
      4
      Mc Forge 1.14.4

      By Kangoro
      Started 23 hours ago

    • thedarkcolour
      13
      [1.14] Patching method with coremod in TreeFeature causes IncompatibleClassChangeError

      By thedarkcolour
      Started 11 hours ago

    • Pixelboss4d
      2
      1.89 crash forge

      By Pixelboss4d
      Started 1 hour ago

    • Junior240
      4
      I'm having trouble with Java on !MAC!

      By Junior240
      Started November 9

    • Cerandior
      10
      [1.14.4] [Solved] Trouble With Packets

      By Cerandior
      Started Yesterday at 03:20 PM

  • Who's Online (See full list)

    • Ryagal
    • Kangoro
    • Ronaldi2001
    • loordgek
    • thedarkcolour
    • imacatlolol
    • Choco
    • potatoking
    • Cerandior
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Registering 2 of the same blocks
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community