Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

  • Author

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

The Korecraft Mod

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.

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.

  • Author

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

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.

  • Author

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.

The Korecraft Mod

  • Author

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

  • Author

Nevermind, I found the problem...

The Korecraft Mod

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.