Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Adding Variables


  • Please log in to reply
7 replies to this topic

#1

cr3wp
    cr3wp

    Redstone Miner

  • Members
  • 517 posts
  • Location: Germany

Posted 10 April 2012 - 11:53 AM

Hi @all
I think i have a rather hard question. My question is, how can i add in this lines :
public int quantityDropped(Random random)
	{
		return 1; // How many veggie you want? 1, 2, 50?
	}
and
public int getBlockTextureFromSideAndMetadata(int i, int j)
		{
			if(j == 0)
			{
				return blockIndexInTexture;
			}
			if(j == 1)
			{
				return mod_crops.xxxCrop1;
			}
			if(j == 2)
			{
				return mod_crops.xxxCrop2; // In order to not have to change a lot more code we can just make
			}								// the plant grow the same but make it "look" like it has fewer steps
			if(j == 3)					   // Through 8 steps the sequence is 0, 1, 1, 2, 2, 3, 3, 4.
			{
				return mod_crops.xxxCrop3;
			}
			if(j == 4)
			{
				return mod_crops.xxxCrop4;
			}
			if(j == 5)
			{
				return mod_crops.xxxCrop5;
			}
			if(j == 6)
			{
				return mod_crops.xxxCrop6;
			}
			if(j == 7)
			{
				return mod_crops.xxxCrop7;
			}
				return -1;
		}
and
protected boolean canThisPlantGrowOnThisBlockID(int i)
	{
		return i == Block.tilledField.blockID;
	}
variables, that i can change in my mod_xxx.java e.g.
xxxCrop.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/mod/crops/xxx/crops/xxxCrop0.png");
so like a xxxCrop.canThisPlantGrowOnThisBlockID = Block.tilledField.blockID; line
Posted Image
Hey, please check out my MoreFoodMod :D

Register or log in to remove.

#2

Beardedcow

Posted 10 April 2012 - 10:26 PM

I don't quite understand what you want to do??

#3

cr3wp
    cr3wp

    Redstone Miner

  • Members
  • 517 posts
  • Location: Germany

Posted 11 April 2012 - 09:03 AM

I want, that i can arrange in my mod_xxx.java, on which Block the plants can grow, how fast they grow, how much items it drops and so on. So i want 1 new BlockmodCrop.java, that i dont need a BlockxxxCrop.java for each new crop
Posted Image
Hey, please check out my MoreFoodMod :D

#4

RANKSHANK
  • Location: American lost in Aussyland
  • Minecraft: RANKSHANK

Posted 11 April 2012 - 11:51 AM

View Postcr3wp, on 11 April 2012 - 09:03 AM, said:

I want, that i can arrange in my mod_xxx.java, on which Block the plants can grow, how fast they grow, how much items it drops and so on. So i want 1 new BlockmodCrop.java, that i dont need a BlockxxxCrop.java for each new crop
so basically one class to rule them all?

the only way i can see you being able to do that is
TileEntityCrop
and then using metadata to save the block type. the growth and speed would all be controlled in the tile entity class, as well as saving and managing those variables. the problem is, controlling speed woulllld be CPU munching
Posted Image

#5

cr3wp
    cr3wp

    Redstone Miner

  • Members
  • 517 posts
  • Location: Germany

Posted 11 April 2012 - 12:04 PM

So it isnt possible to change the grow speed with e.g. .setGrowSpeed(1)
Posted Image
Hey, please check out my MoreFoodMod :D

#6

Joneal9174
  • Minecraft: Joneal

Posted 11 April 2012 - 06:52 PM

Do you mean so you can change all of these values in a config file?  Or do you need different ones at the same time?
Did I help?  Hit the Posted Image at the lower right corner of my post!

#7

Beardedcow

Posted 11 April 2012 - 09:47 PM

Yes it is certainly possible. Maybe a little more complicated than one would hope, but problem the easiest way is to do it by setting up your own terrain file, much like minecraft uses, where its one file and it has different icon index, then you could add 1 or add 2, or sort out some different maths for increase the speed, and it would also increase it icon index.

Sorry if you don't quite understand, its late here so I can't go write you the code, but if I have time tomorrow I will guide you how to do it by this method. Saying that if you look through some of the pre-written code it wouldn't be too hard to figure out what's going on.

Best of luck to you.

#8

Baummann1703
  • Location: Germany
  • Minecraft: Baummann1703

Posted 12 April 2012 - 09:57 PM

At the top:
private float growSpeed = 1.0f; //1.0f = default grow speed adjust it to your preference

Method to change the grow speed:
public void setGrowSpeed(float f) {
	   this.growSpeed = f;
}

Then just replace the grow speed value in your growing method with "growSpeed".

I don't know if that's what you mean, but if it is, there you go.
Posted Image