Jump to content

Recommended Posts

Posted (edited)

Continuing from 

I am going to be following the same format of editing the post and describing my actions to create this mod to add new plants.

To be specific, I am going to be adding new blocks, items, sounds and recipes.

 

 

Updates: 

-Adding first plant block (Bamboo)

  Reveal hidden contents

 

-Create new Package and Class named accordingly (plants.bamboo) (BlockBamboo.java)

  Reveal hidden contents

 

-Make BlockBamboo extend Block and  implement IPlantable

import net.minecraft.block.Block;

public class BlockBamboo extends Block implements net.minecraftforge.common.IPlantable{
}

This requires us to add a constructor giving the Material for the block

	protected BlockBamboo()
	{
		super(Material.PLANTS);
	}

which requires import net.minecraft.block.material.Material
 

  Reveal hidden contents

 

-Need Imports for next steps

import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

-Define an age property before constructor inside class to determine growth

public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 7);

-Initialize the age to 0 inside of our constructor

this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));

 

-IPlantable requires us to implement EnumPlantType getPlantType() and IBlockState getPlant() Both of which are just asking for more metadata about the plant

	@Override
	public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
	{	return net.minecraftforge.common.EnumPlantType.Beach;	}

	@Override
	public IBlockState getPlant(IBlockAccess world, BlockPos pos) 
	{	return getDefaultState();	}
  Reveal hidden contents

 

-A quick thing to do is set creative tab

import net.minecraft.creativetab.CreativeTabs;

and in the constructor for our block 

this.setCreativeTab(CreativeTabs.DECORATIONS);

 

-Need Random Ticks for Growth, Add inside constructor

this.setTickRandomly(true);

-Then we need an UpdateTick function to tell it to grow

  Reveal hidden contents

-Which was pulled from the BlockCactus.class with only the maximum height, max age and neighborChanged edited

  Reveal hidden contents


-Variable Model

-Pulling directly from BlockWall.class

  Reveal hidden contents

 


--Taking breather to work on another mod

Edited by Gotlyfe

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.