Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TechnicianLP.FactorialRevolution.common.blocks.blocks;
- import TechnicianLP.FactorialRevolution.common.FactorialRevolution;
- import TechnicianLP.FactorialRevolution.common.blocks.blockstate.AStateSupplier;
- import TechnicianLP.FactorialRevolution.common.blocks.blockstate.IBlockStateWrapper;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.state.BlockStateContainer;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.IBlockAccess;
- public abstract class BlockBase<S extends AStateSupplier> extends Block {
- public final String name;
- public S stateSupplier;
- public BlockBase(Material material, String name) {
- super(material);
- this.setHardness(5F);
- this.setResistance(10.0F);
- this.name = name;
- this.setUnlocalizedName(name);
- this.setRegistryName(name);
- this.setDefaultState(stateSupplier.getDefaultState(new IBlockStateWrapper(blockState.getBaseState())));
- FactorialRevolution.LOGGER.info(getDefaultState());
- }
- public ItemStack makeStack(int meta) {
- return new ItemStack(this, 1, meta);
- }
- @Override
- public Block setUnlocalizedName(String name) {
- return super.setUnlocalizedName(name);
- }
- // BLOCK states
- /** returns the statesupplier for this block (or default one) */
- protected abstract S getStateSupplier();
- @Override
- protected BlockStateContainer createBlockState() {
- stateSupplier = getStateSupplier();
- return stateSupplier.createBlockState(this);
- }
- @Override
- public int getMetaFromState(IBlockState state) {
- return stateSupplier.getMetaFromState(new IBlockStateWrapper(state));
- }
- @Override
- public IBlockState getStateFromMeta(int meta) {
- System.out.println(getDefaultState());
- return stateSupplier.getStateFromMeta(meta, new IBlockStateWrapper(getDefaultState()));
- }
- // @Override
- // public IBlockState getExtendedState(IBlockState state, IBlockAccess
- // world, BlockPos pos) {
- // return getActualState(state, world, pos);
- // }
- @Override
- public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
- System.out.println(state);
- return stateSupplier.getActualState(new IBlockStateWrapper(state), worldIn, pos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement