Jump to content

custom bars not modeled like web issue


hhggtg3279

Recommended Posts

Basically it is modeled as a normal block instead of being like the spider web, even though it uses the same code from BlocKWeb

 

n7HR1F3.png

 

 

Blocks class

 

package top.mod.block;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBlock;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.common.registry.GameRegistry;

import top.mod.item.ModItems;

import top.mod.main.Reference;

import top.mod.tab.TopTab;

 

public class ModBlocks {

 

public static BlockBase copperore;

public static BlockBase copperblock;

public static BlockBase copperbars;

 

public static final void preinit(){

copperore = registerBlock(new CopperOre(Material.ROCK), "copperore");

copperblock = registerBlock(new CopperBlock(Material.IRON), "copperblock");

copperbars = registerBlock(new CopperBars(Material.WEB), "copperbars");

}

 

public static final void registerRenders() {

ModItems.registerRender(copperore.i);

ModItems.registerRender(copperblock.i);

ModItems.registerRender(copperbars.i);

}

 

public static final BlockBase registerBlock(BlockBase b, String n){

    ResourceLocation r = new ResourceLocation(Reference.MODID, n);

   

b.setUnlocalizedName(n);

b.setRegistryName®;

b.i = new ItemBlock(b);

b.setCreativeTab(TopTab.toptab);

 

GameRegistry.register(b);

GameRegistry.register(b.i, r);

return b;

 

}

}

 

 

Copperbars class

 

package top.mod.block;

 

import java.util.Random;

 

import javax.annotation.Nullable;

 

import net.minecraft.block.SoundType;

import net.minecraft.block.material.Material;

import net.minecraft.block.state.IBlockState;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.stats.StatList;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.BlockRenderLayer;

import net.minecraft.util.math.AxisAlignedBB;

import net.minecraft.util.math.BlockPos;

import net.minecraft.world.World;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import top.mod.item.ModItems;

 

public class CopperBars extends BlockBase {

 

public CopperBars(Material mat) {

super(mat);

 

setHardness(3F);

setResistance(3F);

setHarvestLevel("pickaxe", 0);

this.setSoundType(SoundType.STONE);

 

}

 

 

 

/**

* Called When an Entity Collided with the Block

*/

public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)

{

    entityIn.setInWeb();

}

 

/**

* Used to determine ambient occlusion and culling when rebuilding chunks for render

*/

public boolean isOpaqueCube(IBlockState state)

{

    return false;

}

 

@Nullable

public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)

{

    return NULL_AABB;

}

 

public boolean isFullCube(IBlockState state)

{

    return false;

}

 

/**

* Get the Item that this Block should drop when harvested.

*/

@Nullable

public Item getItemDropped(IBlockState state, Random rand, int fortune)

{

    return Items.STRING;

}

 

protected boolean canSilkHarvest()

{

    return true;

}

 

@SideOnly(Side.CLIENT)

public BlockRenderLayer getBlockLayer()

{

    return BlockRenderLayer.CUTOUT;

}

 

public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)

{

    if (!worldIn.isRemote && stack != null && stack.getItem() == Items.SHEARS)

    {

        player.addStat(StatList.getBlockStats(this));

        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1));

    }

    else

    {

        super.harvestBlock(worldIn, player, pos, state, te, stack);

    }

}

}

 

 

Link to comment
Share on other sites

Look at the model for IronBars

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.