Basic block registration works
This commit is contained in:
parent
7f6ace64e9
commit
5f7015aeee
5 changed files with 241 additions and 3 deletions
|
@ -6,7 +6,7 @@ mod_version=8.0.0
|
|||
|
||||
minecraft_version=1.13
|
||||
minecraft_version_toml=13
|
||||
forge_version=24.0.55-1.13-pre
|
||||
forge_version=24.0.59-1.13-pre
|
||||
forge_version_toml=24
|
||||
forge_group=net.minecraftforge.test
|
||||
mappings_version=20181221-1.13.1
|
||||
|
|
119
src/main/java/biomesoplenty/api/block/BOPBlocks.java
Normal file
119
src/main/java/biomesoplenty/api/block/BOPBlocks.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2019, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
package biomesoplenty.api.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class BOPBlocks
|
||||
{
|
||||
public static Block ash_block;
|
||||
|
||||
/*public static Block grass;
|
||||
public static Block dirt;
|
||||
public static Block grass_path;
|
||||
public static Block farmland_0;
|
||||
public static Block farmland_1;
|
||||
|
||||
public static Block white_sand;
|
||||
public static Block white_sandstone;
|
||||
public static Block white_sandstone_stairs;
|
||||
public static Block mud;
|
||||
public static Block mud_brick_block;
|
||||
public static Block mud_brick_stairs;
|
||||
public static Block other_slab;
|
||||
public static Block double_other_slab;
|
||||
|
||||
public static Block dried_sand;
|
||||
public static Block flesh;
|
||||
|
||||
public static Block blue_fire;
|
||||
|
||||
public static Block log_0;
|
||||
public static Block log_1;
|
||||
public static Block log_2;
|
||||
public static Block leaves_0;
|
||||
public static Block leaves_1;
|
||||
public static Block leaves_2;
|
||||
public static Block leaves_3;
|
||||
public static Block leaves_4;
|
||||
public static Block sapling_0;
|
||||
public static Block sapling_1;
|
||||
public static Block sapling_2;
|
||||
|
||||
public static Block planks_0;
|
||||
public static Block wood_slab_0;
|
||||
public static Block wood_slab_1;
|
||||
public static Block double_wood_slab_0;
|
||||
public static Block double_wood_slab_1;
|
||||
public static Block cherry_stairs;
|
||||
public static Block umbran_stairs;
|
||||
public static Block fir_stairs;
|
||||
public static Block ethereal_stairs;
|
||||
public static Block magic_stairs;
|
||||
public static Block palm_stairs;
|
||||
public static Block redwood_stairs;
|
||||
public static Block willow_stairs;
|
||||
public static Block hellbark_stairs;
|
||||
public static Block jacaranda_stairs;
|
||||
public static Block mahogany_stairs;
|
||||
public static Block cherry_fence;
|
||||
public static Block umbran_fence;
|
||||
public static Block fir_fence;
|
||||
public static Block ethereal_fence;
|
||||
public static Block magic_fence;
|
||||
public static Block palm_fence;
|
||||
public static Block redwood_fence;
|
||||
public static Block willow_fence;
|
||||
public static Block hellbark_fence;
|
||||
public static Block jacaranda_fence;
|
||||
public static Block mahogany_fence;
|
||||
public static Block cherry_fence_gate;
|
||||
public static Block umbran_fence_gate;
|
||||
public static Block fir_fence_gate;
|
||||
public static Block ethereal_fence_gate;
|
||||
public static Block magic_fence_gate;
|
||||
public static Block palm_fence_gate;
|
||||
public static Block redwood_fence_gate;
|
||||
public static Block willow_fence_gate;
|
||||
public static Block hellbark_fence_gate;
|
||||
public static Block jacaranda_fence_gate;
|
||||
public static Block mahogany_fence_gate;
|
||||
public static Block cherry_door;
|
||||
public static Block umbran_door;
|
||||
public static Block fir_door;
|
||||
public static Block ethereal_door;
|
||||
public static Block magic_door;
|
||||
public static Block palm_door;
|
||||
public static Block redwood_door;
|
||||
public static Block willow_door;
|
||||
public static Block hellbark_door;
|
||||
public static Block jacaranda_door;
|
||||
public static Block mahogany_door;
|
||||
|
||||
public static Block coral;
|
||||
public static Block seaweed;
|
||||
|
||||
public static Block ivy;
|
||||
public static Block willow_vine;
|
||||
|
||||
public static Block foliage_0;
|
||||
public static Block plant_0;
|
||||
public static Block double_plant;
|
||||
public static Block flower_0;
|
||||
|
||||
public static Block flat_plant;
|
||||
public static Block mushroom;
|
||||
|
||||
public static Block bramble_plant;
|
||||
|
||||
public static Block blood;
|
||||
public static Fluid blood_fluid;
|
||||
public static Block hot_spring_water;
|
||||
public static Fluid hot_spring_water_fluid;
|
||||
*/
|
||||
}
|
71
src/main/java/biomesoplenty/common/block/BlockBOPAsh.java
Normal file
71
src/main/java/biomesoplenty/common/block/BlockBOPAsh.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2019, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
package biomesoplenty.common.block;
|
||||
|
||||
import javafx.geometry.Side;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBOPAsh extends Block
|
||||
{
|
||||
protected static final AxisAlignedBB COLLISION_BOX = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D);
|
||||
|
||||
public BlockBOPAsh()
|
||||
{
|
||||
// TODO: Sound
|
||||
super(Builder.create(Material.SAND, MapColor.BLACK).hardnessAndResistance(0.4F, 0.4F));
|
||||
|
||||
//this.setHarvestLevel("shovel", 0);
|
||||
}
|
||||
|
||||
// ash blocks are slightly lower
|
||||
/*@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return COLLISION_BOX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
return (side == EnumFacing.UP);
|
||||
}
|
||||
|
||||
// drop 4 balls of ash instead of one block
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return BOPItems.ash;
|
||||
}
|
||||
@Override
|
||||
public int quantityDropped(Random random)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
// randomly show some smoke particles
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random)
|
||||
{
|
||||
if (random.nextInt(2) == 0)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + random.nextFloat(), pos.getY() + 1.1F, pos.getZ() + random.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2016, the Biomes O' Plenty Team
|
||||
* Copyright 2014-2019, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
|
@ -8,7 +8,10 @@
|
|||
|
||||
package biomesoplenty.core;
|
||||
|
||||
import biomesoplenty.init.ModBlocks;
|
||||
import net.minecraft.init.Bootstrap;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
|
||||
|
||||
|
@ -22,11 +25,19 @@ public class BiomesOPlenty
|
|||
public BiomesOPlenty()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
FMLModLoadingContext.get().getModEventBus().addListener(this::preInit);
|
||||
FMLModLoadingContext.get().getModEventBus().addListener(this::init);
|
||||
|
||||
// As of right now registry events are fired after construction
|
||||
ModBlocks.init();
|
||||
}
|
||||
|
||||
private void preInit(final FMLPreInitializationEvent event)
|
||||
{
|
||||
System.out.println("Here we go again...");
|
||||
}
|
||||
|
||||
private void init(final FMLInitializationEvent event)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
37
src/main/java/biomesoplenty/init/ModBlocks.java
Normal file
37
src/main/java/biomesoplenty/init/ModBlocks.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2014-2019, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
package biomesoplenty.init;
|
||||
|
||||
import biomesoplenty.common.block.BlockBOPAsh;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import static biomesoplenty.api.block.BOPBlocks.*;
|
||||
|
||||
public class ModBlocks
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
ash_block = registerBlock(new BlockBOPAsh(), "ash_block");
|
||||
}
|
||||
|
||||
public static Block registerBlock(Block block, String name)
|
||||
{
|
||||
ItemBlock itemBlock = new ItemBlock(block, new Item.Builder().group(ItemGroup.MISC));
|
||||
block.setRegistryName(name);
|
||||
itemBlock.setRegistryName(name);
|
||||
ForgeRegistries.BLOCKS.register(block);
|
||||
ForgeRegistries.ITEMS.register(itemBlock);
|
||||
return block;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue