I've been working on a mod that adds bioluminescent blocks and mobs to the game, including four new mushrooms and their giant counterparts. I've successfully implemented the small mushrooms, however I'm struggling with the big ones. Vanilla minecraft uses one block with 13 different block states to create its giant mushrooms, which is what I've tried to do. I'm not getting any errors, but I can only obtain my huge mushroom block in the default state. Did I do something wrong? How do I access the other blockstates?
This is my first mod, and I didn't know much about java before I started this project. I've been relying on tutorials, and there are no tutorials on how to make custom big mushrooms.
Huge Mushroom Block class
public class BlockHugeMycenaChlorophos extends Block implements IMetaBlockName
{
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", HugeMushroom.class);
public BlockHugeMycenaChlorophos()
{
super(Material.WOOD, MapColor.LIME);
setSoundType(SoundType.WOOD);
setHardness(0.2F);
setLightLevel(10/16F);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, HugeMushroom.ALL_OUTSIDE));
}
public int quantityDropped(Random random)
{
return Math.max(0, random.nextInt(10) - 7);
}
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(ModBlocks.mycena_chlorophos);
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {VARIANT});
}
@Override
public int getMetaFromState(IBlockState state)
{
HugeMushroom variant = (HugeMushroom) state.getValue(VARIANT);
return variant.getID();
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, HugeMushroom.values()[meta]);
}
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
for(int i = 0; i < HugeMushroom.values().length; i++)
{
list.add(new ItemStack(itemIn, 1, i));
}
}
@Override
public String getSpecialName(ItemStack stack)
{
return HugeMushroom.values()[stack.getItemDamage()].getName();
}
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
}
public int damageDropped(IBlockState state)
{
return getMetaFromState(state);
}
}
ModBlocks class:
@ObjectHolder(MainMod.MODID)
public class ModBlocks
{
public static final BlockJackolanternMushroom jackolantern_mushroom = null;
public static final BlockMilkdropMycena milkdrop_mycena = null;
public static final BlockMycenaChlorophos mycena_chlorophos = null;
public static final BlockLilacBellcap lilac_bellcap = null;
public static final BlockHugeMycenaChlorophos huge_mycena_chlorophos = null;
@ObjectHolder("jackolantern_mushroom")
public static final ItemBlock item_block_jackolantern_mushroom = null;
@ObjectHolder("milkdrop_mycena")
public static final ItemBlock item_block_milkdrop_mycena = null;
@ObjectHolder("mycena_chlorophos")
public static final ItemBlock item_block_mycena_chlorophos = null;
@ObjectHolder("lilac_bellcap")
public static final ItemBlock item_block_lilac_bellcap = null;
@ObjectHolder("huge_mycena_chlorophos")
public static final ItemBlock item_block_huge_mycena_chlorophos = null;
@EventBusSubscriber(modid = MainMod.MODID)
public static class RegistrationHandler
{
@SubscribeEvent
public static void onEvent(final RegistryEvent.Register<Block> event)
{
// DEBUG
System.out.println("Registering Blocks");
final IForgeRegistry<Block> registry = event.getRegistry();
registry.register(Utilities.setBlockName(new BlockJackolanternMushroom(), "jackolantern_mushroom"));
registry.register(Utilities.setBlockName(new BlockMilkdropMycena(), "milkdrop_mycena"));
registry.register(Utilities.setBlockName(new BlockMycenaChlorophos(), "mycena_chlorophos"));
registry.register(Utilities.setBlockName(new BlockLilacBellcap(), "lilac_bellcap"));
registry.register(Utilities.setBlockName(new BlockHugeMycenaChlorophos(), "huge_mycena_chlorophos"));
}
@SubscribeEvent
public static void registerItemBlocks(final RegistryEvent.Register<Item> event)
{
// DEBUG
System.out.println("Registering ItemBlocks");
final IForgeRegistry<Item> registry = event.getRegistry();
registry.register(Utilities.setItemName(new ItemBlock(jackolantern_mushroom), jackolantern_mushroom.getRegistryName().getResourcePath()));
registry.register(Utilities.setItemName(new ItemBlock(milkdrop_mycena), milkdrop_mycena.getRegistryName().getResourcePath()));
registry.register(Utilities.setItemName(new ItemBlock(mycena_chlorophos), mycena_chlorophos.getRegistryName().getResourcePath()));
registry.register(Utilities.setItemName(new ItemBlock(lilac_bellcap), lilac_bellcap.getRegistryName().getResourcePath()));
registry.register(Utilities.setItemName(new ItemBlock(huge_mycena_chlorophos), huge_mycena_chlorophos.getRegistryName().getResourcePath()));
}
@SubscribeEvent
public static void onModelEvent(final ModelRegistryEvent event)
{
// DEBUG
System.out.println("Registering block models");
registerBlockModel(jackolantern_mushroom, 0);
registerBlockModel(milkdrop_mycena, 0);
registerBlockModel(mycena_chlorophos, 0);
registerBlockModel(lilac_bellcap, 0);
for(int i = 0; i < EnumHandler.HugeMushroom.values().length; i++)
{
registerBlockModel(huge_mycena_chlorophos, "block_huge_mycena_chlorophos" + EnumHandler.HugeMushroom.values()[i][i].getName());
}
}
public static void registerBlockModel(Block parBlock, String string)
{
registerBlockModel(parBlock, 0);
}
public static void registerBlockModel(Block parBlock, int parMetaData)
{
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(parBlock), parMetaData,
new ModelResourceLocation(MainMod.MODID + ":" + parBlock.getUnlocalizedName().substring(5), "inventory"));
}
}
}
[/i][/i]
EnumHandler:
public class EnumHandler
{
public static enum HugeMushroom implements IStringSerializable
{
ALL_OUTSIDE("all_outside", 0),
ALL_INSIDE("all_inside", 1),
ALL_STEM("all_stem", 2),
STEM("stem", 3),
NORTH_WEST("north_west", 4),
NORTH("north", 5),
NORTH_EAST("north_east", 6),
WEST("west", 7),
CENTER("center", 8),
EAST("east", 9),
SOUTH_WEST("south_west", 10),
SOUTH("south", 11),
SOUTH_EAST("south_east", 12);
private int ID;
private String name;
private HugeMushroom(String name, int ID)
{
this.ID = ID;
this.name =name;
}
@Override
public String getName()
{
return this.name;
}
public int getID()
{
return ID;
}
@Override
public String toString()
{
return getName();
}
}
}
if you get your normal mushroom texture for the first command I put up there, then probably messed up with textures when creating different variants of muchroom blocks.
I would take a look at biome o plenty's code. They have custom muchrooms in the nether
I've been working on a mod that adds bioluminescent blocks and mobs to the game, including four new mushrooms and their giant counterparts. I've successfully implemented the small mushrooms, however I'm struggling with the big ones. Vanilla minecraft uses one block with 13 different block states to create its giant mushrooms, which is what I've tried to do. I'm not getting any errors, but I can only obtain my huge mushroom block in the default state. Did I do something wrong? How do I access the other blockstates?
This is my first mod, and I didn't know much about java before I started this project. I've been relying on tutorials, and there are no tutorials on how to make custom big mushrooms.
Huge Mushroom Block class
ModBlocks class:
[/i][/i]
EnumHandler:
I don't know much about how blockstates work, however try giving yourself your modded block with a damage value of 1 for example.
/give coffeeaddict101 mushroommodid:mushroomblockid 1 1
if that works try increasing the second number to 2
/give coffeeaddict101 mushroommodid:mushroomblockid 1 2
if you get your normal mushroom texture for the first command I put up there, then probably messed up with textures when creating different variants of muchroom blocks.
I would take a look at biome o plenty's code. They have custom muchrooms in the nether
https://github.com/Glitchfiend/BiomesOPlenty
Hope I helped <3