Started by
Hakann
on
Topic category: Advanced modding
How to create mushroom (new plant) with code in mcreator (not big mushrom)?
Edited by Hakann on Sat, 03/17/2018 - 10:37
Topic category: Advanced modding
How to create mushroom (new plant) with code in mcreator (not big mushrom)?
Please stop using text formatting without purpose. It is meant to be used for highlighting important words, not the entire text.
You can create the plant using the plant option in the new mod dialog.
You can not create mushroom with using option in the new mod dialog!
You can create mushroom only using code!!!
Please write the code of this.
What kind of mushroom are you talking about? If you want a mushroom like minecraft vanilla one you choose the plant option and put in the texture. A mushroom is not a special element it is simply a plant.
You can make plants behave mushroom like using the provided events with conditions.
Please write the code of provided event
Please edit this code
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.NonNullList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.Block;
import java.util.Random;
public class mcreator_greenmushroom {
public mcreator_greenmushroom() {
}
public static Block block;
public static Object instance;
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
block = (Block) (new BlockCustomFlower()).setHardness(0.01F).setResistance(2.0F).setLightLevel(0.0F).setUnlocalizedName("greenmushroom");
block.setRegistryName("greenmushroom");
ForgeRegistries.BLOCKS.register(block);
ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
public void registerRenderers() {
}
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:greenmushroom", "inventory"));
}
}
public void generateSurface(World world, java.util.Random randomGenerator, int chunkX, int chunkZ) {
for (int i = 0; i < 20; i++) {
int l6 = chunkX + randomGenerator.nextInt(16) + 8;
int i11 = randomGenerator.nextInt(128);
int l14 = chunkZ + randomGenerator.nextInt(16) + 8;
(new WorldGenFlowers(((BlockFlower) mcreator_greenmushroom.block), BlockFlower.EnumFlowerType.DANDELION)).generate(world,
randomGenerator, new BlockPos(l6, i11, l14));
}
}
public static class BlockCustomFlower extends BlockFlower {
public BlockCustomFlower() {
super();
setSoundType(SoundType.GROUND);
this.setCreativeTab(CreativeTabs.DECORATIONS);
}
@Override
public BlockFlower.EnumFlowerColor getBlockType() {
return BlockFlower.EnumFlowerColor.YELLOW;
}
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (BlockFlower.EnumFlowerType blockflower$enumflowertype : BlockFlower.EnumFlowerType.getTypes(this.getBlockType())) {
list.add(new ItemStack(this, 1, blockflower$enumflowertype.getMeta()));
}
}
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(block);
}
}
}
Do you want mushroom like these?
https://ibb.co/eNydjc
no they should be placed on a tree on a stone and under a certain light (like conventional mushrooms)