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

So, by looking at the title you're probably passing me up as an average Joe that knows no code, but you are wrong! *dun, dun, duuuun!*

 

More seriously, though, I have 3 different ore blocks and I want them all to drop gems of themselves (say RubyOre drops RubyGem) but I refuse to make classes for them just to say I want them to drop these items.

 

rubyOre = new Block(MASS_Info.rubyOreID, Material.rock);

 

That is the example I want to use. I want my ores to just be basic blocks and to Extend Block and not have to create individual classes.

 

My question is can I change what they drop in my base classes init() method?

For example, is there a method or a function to do so?

 

Thanks!

Nope. Sorry.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

  • Author

Nope. Sorry.

Ah, I see. Is there a way in which all three of my ores can share one BlockOre file and use if statements to check what their block ID is then drop the corresponding id of the item?

You can put a setter for the drop in a custom block class file, so you can chain it into your block initialization line.

  • Author

So my compromise was to make one BlockOre.class and inside put the method:

 

public int idDropped(int par1, Random par2Random, int par3) {
	if (blockID == MyBlocks.myOre1.blockID) {
		return MyItems.myGem1.itemID;
	}
	if (blockID == MyBlocks.myOre2.blockID) {
		return MyItems.myGem2.itemID;
	}
	if (blockID == MyBlocks.myOre3.blockID) {
		return MyItems.myGem3.itemID;
	}

	return blockID;
}

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.