Custom Wood Question

Started by Mr_Alpha on Tue, 01/03/2017 - 20:05

Topic category: Advanced modding

Last seen on 20:03, 30. Apr 2019
Joined Jul 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Custom Wood Question
Tue, 01/03/2017 - 20:05

Hello there everyone,

 

(Wow I post too much on the forums here... Heheh... Whoops.)

So, I'm trying to make a tropical Survival Island-type mod. I've made coconuts, coconut trees, and the wood for the trees so far. But I have also made the wooden planks to go with it. I was wondering if there's any way to make these "Coconut Planks" behave like EVERY other wooden planks, in that they can:

1. Be used to craft everything that normal wooden planks can

2. Be used in conjunction with other types of planks for these recipes, in case the player doesn't have enough of one type of wood for something.

 

There's gotta be something I can add to the code to add this new block to a "wood class" or something, right?

 

If anyone can help, let me know.

Thanks,

  -A

Last seen on 00:57, 5. Oct 2017
Joined Oct 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
You should be able to just
Tue, 01/03/2017 - 20:28

You should be able to just look up a tutorial for making trees in eclipse

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
For usage in recipes you
Tue, 01/03/2017 - 21:28

For usage in recipes you should be able use in init FML life cycle 
OreDictionary.registerOre("plankWood", YOUR_BLOCK);

Last seen on 20:03, 30. Apr 2019
Joined Jul 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
RE:For usage in recipes you
Tue, 01/03/2017 - 23:55

@#2 Awesome. Where should I put that in the code? Here's the whole code for the block:

 

package mod.mcreator;

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
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.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.entity.player.EntityPlayer;
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.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;

import java.util.Random;

public class mcreator_coconutWoodPlanks {

    public mcreator_coconutWoodPlanks() {
    }

    public static BlockCoconutWoodPlanks block;

    public static Object instance;

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    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:CoconutWoodPlanks", "inventory"));
        }
    }

    static {

        block = (BlockCoconutWoodPlanks) (new BlockCoconutWoodPlanks().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F)
                .setUnlocalizedName("CoconutWoodPlanks").setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
        block.setHarvestLevel("axe", 0);
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    static class BlockCoconutWoodPlanks extends Block {

        int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;

        boolean red = false;

        protected BlockCoconutWoodPlanks() {
            super(Material.WOOD);

            GameRegistry.registerBlock(this, "CoconutWoodPlanks");
            setSoundType(SoundType.WOOD);

        }

        @Override
        public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
            int i = pos.getX();
            int j = pos.getY();
            int k = pos.getZ();
            EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
            world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));

        }

        @Override
        public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
            return red ? 15 : 0;
        }

        @Override
        public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
            return red ? 15 : 0;
        }

        @SideOnly(Side.CLIENT)
        @Override
        public BlockRenderLayer getBlockLayer() {
            return BlockRenderLayer.SOLID;
        }

        @Override
        public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
            return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
        }

        @Override
        public int tickRate(World world) {
            return 10;
        }

        @Override
        public int quantityDropped(Random par1Random) {
            return 1;
        }

    }
}

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
In the FML init event so in
Wed, 01/04/2017 - 20:29

In the FML init event so in public void load(FMLInitializationEvent event) {}

Last seen on 20:03, 30. Apr 2019
Joined Jul 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Ok, so I tried:
Wed, 01/04/2017 - 20:49

Ok, so I tried:

public void load(FMLInitializationEvent event) {

        OreDictionary.registerOre("plankWood", mcreator_coconutWoodPlanks);
        if (event.getSide() == Side.CLIENT) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                    .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:CoconutWoodPlanks", "inventory"));
        }
}

 

...and...

 

public void load(FMLInitializationEvent event) {

        OreDictionary.registerOre("plankWood", CoconutWoodPlanks);
        if (event.getSide() == Side.CLIENT) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                    .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:CoconutWoodPlanks", "inventory"));
        }

}

 

...and...

 

public void load(FMLInitializationEvent event) {

        OreDictionary.registerOre("plankWood", BlockCoconutWoodPlanks);
        if (event.getSide() == Side.CLIENT) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                    .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("TestEnvironmentMod:CoconutWoodPlanks", "inventory"));
        }
    }

 

...none of them worked. Could you please put it in the correct spot in that code, and look through the code to tell me what I should put in place of YOUR_BLOCK?

Last seen on 20:03, 30. Apr 2019
Joined Jul 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
RE:In the FML init event so in
Wed, 01/04/2017 - 20:50

@#3 Whoops, didn't hit reply. See above. ^^^

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
Try your block variable
Wed, 01/04/2017 - 21:15

Try your block variable