Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tutorial.generic;
- import cpw.mods.fml.common.FMLCommonHandler;
- import cpw.mods.fml.common.registry.LanguageRegistry;
- import cpw.mods.fml.relauncher.Side;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.Icon;
- import net.minecraft.world.World;
- public class GenericDirt extends GenericBlock {
- private boolean switched = false;
- private Icon ic1;
- private Icon ic2;
- public GenericDirt() {
- super(500, Material.ground);
- setHardness(0.5f);
- setStepSound(Block.soundAnvilFootstep);
- setUnlocalizedName("genericDirt");
- setCreativeTab(CreativeTabs.tabMisc);
- LanguageRegistry.addName(this,"Generic Dirt");
- }
- @Override
- public boolean onBlockActivated(World world,int bx,int by,int bz, EntityPlayer player,int side, float px, float py, float pz)
- {
- Side eside = FMLCommonHandler.instance().getEffectiveSide();
- if( eside == Side.SERVER)
- {
- TileEntity tEnt = world.getBlockTileEntity(bx,by,bz);
- if(tEnt == null)
- {
- System.out.println("tileEnt is null");
- }
- switched = !switched;
- if( switched )
- {
- this.blockIcon = ic2;
- }
- else
- {
- this.blockIcon = ic1;
- }
- }
- return false;
- }
- public void registerIcons(IconRegister iconRegister)
- {
- this.ic1 = iconRegister.registerIcon("Generic:" + this.getUnlocalizedName2());
- this.ic2 = iconRegister.registerIcon("Generic:genericBlock");
- this.blockIcon = ic1;
- }
- @Override
- public TileEntity createTileEntity(World world, int metadata)
- {
- return new GenericEntity();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement