Ok so I am creating a custom slab and as I am a complete novice to JAVA coding (I do not know the basics) I have been using YouTube tutorials to get a mod started, now I am coding in 1.12.2, and Harry's Tech Reviews is who I am following for the coding breakdown, but I have run into an issue as the BlockInit I made does not use the same methods for registering a block, and one part of the code calls for me to have new ItemSlab(my halfslab, myhalfslab, my doubleslab), but as I do not know JAVA, I am not sure how to call that in the new code. What I have seen in other tutorials
public static void register()public static void register()
{
registerBlock(my block, newItemSlab(my halfslab, myhalfslab, my doubleslab);
}
but I dun have that field in my BlockInit.java file. so I am not sure where to place the new ItemSlab part of the code
Any assistance would be greatly appreciated
BlockInit.java
package guardia.coremod.init;
import java.util.ArrayList;
import java.util.List;
import guardia.coremod.Main;
import guardia.coremod.objects.blocks.AnvilAssembler;
import guardia.coremod.objects.blocks.BlockBase;
import guardia.coremod.objects.blocks.BlockCraftBench;
import guardia.coremod.objects.blocks.BlockOresEnd;
import guardia.coremod.objects.blocks.BlockOresNether;
import guardia.coremod.objects.blocks.BlockOresOverworld;
import guardia.coremod.objects.blocks.BlockStairsBase;
import guardia.coremod.objects.blocks.slab.BlockDoubleSlabBase;
import guardia.coremod.objects.blocks.slab.BlockHalfSlabBase;
import guardia.coremod.objects.blocks.slab.BlockSlabBase;
import guardia.coremod.objects.blocks.BlockLeavesBase;
import guardia.coremod.objects.blocks.BlockLogBase;
import guardia.coremod.objects.blocks.BlockPlanksBase;
import guardia.coremod.objects.blocks.BlockSaplingBase;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
public class BlockInit
{
public static final List<Block> BLOCKS = new ArrayList<Block>();
public static final Block BLOCK_COPPER = new BlockBase("block_copper", Material.IRON, 5F, 30F);
public static final Block BLOCK_TIN = new BlockBase("block_tin", Material.IRON, 5F, 20F);
public static final Block BLOCK_ALUMINUM = new BlockBase("block_aluminum", Material.IRON, 5F, 10F);
public static final Block BLOCK_AZURIUM = new BlockBase("block_azurium", Material.IRON, 5F, 60F);
public static final Block ORE_END = new BlockOresEnd("ore_end", "end", Material.ROCK, 3F, 45F, 3);
public static final Block ORE_OVERWORLD = new BlockOresOverworld("ore_overworld", "overworld", Material.ROCK, 3F, 15F, 2);
public static final Block ORE_NETHER = new BlockOresNether("ore_nether", "nether", Material.ROCK, 4F, 15F, 3);
public static final Block PLANKS = new BlockPlanksBase("planks");
public static final Block LOGS = new BlockLogBase("logs");
public static final Block LEAVES = new BlockLeavesBase("leaves");
public static final Block SAPLINGS = new BlockSaplingBase("saplings");
public static final Block STAIRS = new BlockStairsBase("stairs_elder_oak", PLANKS.getDefaultState());
public static final BlockHalfSlabBase HALF_SLAB = new BlockHalfSlabBase("slab_half_elder_oak");
public static final BlockDoubleSlabBase DOUBLE_SLAB = new BlockDoubleSlabBase("slab_double_elder_oak");
public static final Block ANVIL_ASSEMBLER = new AnvilAssembler("anvil_assembler", 5F, 45F);
public static final Block CRAFTING_BENCH = new BlockCraftBench("crafting_bench", 3F, 25F);
}
BlockSlabBase.java
package guardia.coremod.objects.blocks.slab;
import java.util.Random;
import guardia.coremod.Main;
import guardia.coremod.init.BlockInit;
import guardia.coremod.init.ItemInit;
import guardia.coremod.utils.interfaces.IHasModel;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
public abstract class BlockSlabBase extends BlockSlab implements IHasModel
{
public BlockSlabBase(String name)
{
super(Material.WOOD);
setUnlocalizedName(name);
setRegistryName(name);
setHardness(3F);
setResistance(15F);
IBlockState state = this.blockState.getBaseState();
if(!this.isDouble())
{
state = state.withProperty(HALF, EnumBlockHalf.BOTTOM);
}
setDefaultState(state);
this.useNeighborBrightness = true;
BlockInit.BLOCKS.add(this);
ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
}
@Override
public void registerModels()
{
Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
}
@Override
public String getUnlocalizedName(int meta)
{
return this.getUnlocalizedName();
}
@Override
public IProperty<?> getVariantProperty()
{
return HALF;
}
@Override
public Comparable<?> getTypeForItem(ItemStack stack)
{
return EnumBlockHalf.BOTTOM;
}
@Override
public int damageDropped(IBlockState state)
{
return 0;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
if(!this.isDouble())
{
return this.getDefaultState().withProperty(HALF, EnumBlockHalf.values()[meta % EnumBlockHalf.values().length]);
}
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state)
{
if(!this.isDouble())
{
return 0;
}
return ((EnumBlockHalf)state.getValue(HALF)).ordinal() + 1;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(BlockInit.HALF_SLAB);
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {HALF});
}
}
Ok so I am creating a custom slab and as I am a complete novice to JAVA coding (I do not know the basics) I have been using YouTube tutorials to get a mod started, now I am coding in 1.12.2, and Harry's Tech Reviews is who I am following for the coding breakdown, but I have run into an issue as the BlockInit I made does not use the same methods for registering a block, and one part of the code calls for me to have new ItemSlab(my halfslab, myhalfslab, my doubleslab), but as I do not know JAVA, I am not sure how to call that in the new code. What I have seen in other tutorials
public static void register()public static void register()
{
registerBlock(my block, newItemSlab(my halfslab, myhalfslab, my doubleslab);
}
but I dun have that field in my BlockInit.java file. so I am not sure where to place the new ItemSlab part of the code
Any assistance would be greatly appreciated
BlockInit.java
BlockSlabBase.java
RegistryHandler.java