Package vazkii.botania.common.block

Source Code of vazkii.botania.common.block.BlockPlatform

/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Jun 7, 2014, 2:25:22 PM (GMT)]
*/
package vazkii.botania.common.block;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.block.tile.TileCamo;
import vazkii.botania.common.block.tile.TilePlatform;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;

public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable {

  IIcon[] icons;
  private static final int SUBTYPES = 3;

  public BlockPlatform() {
    super(Material.wood);
    setHardness(2.0F);
    setResistance(5.0F);
    setStepSound(Block.soundTypeWood);
    setBlockName(LibBlockNames.PLATFORM);
  }

  @Override
  protected boolean shouldRegisterInNameSet() {
    return false;
  }

  @Override
  public int damageDropped(int par1) {
    return par1;
  }

  @Override
  public Block setBlockName(String par1Str) {
    GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
    return super.setBlockName(par1Str);
  }

  @Override
  public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
    for(int i = 0; i < SUBTYPES; i++)
      par3List.add(new ItemStack(par1, 1, i));
  }

  @Override
  public void registerBlockIcons(IIconRegister par1IconRegister) {
    icons = new IIcon[SUBTYPES];
    for(int i = 0; i < SUBTYPES; i++)
      icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
  }

  @Override
  public IIcon getIcon(int par1, int par2) {
    return icons[Math.min(SUBTYPES - 1, par2)];
  }

  @Override
  public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
    int meta = par1World.getBlockMetadata(par2, par3, par4);
    if(meta == 2 || meta == 0 && par7Entity != null && par7Entity.posY > par3 + (par7Entity instanceof EntityPlayer ? 2 : 0) && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
      super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
  }

  @Override
  public float getBlockHardness(World par1World, int par2, int par3, int par4) {
    int meta = par1World.getBlockMetadata(par2, par3, par4);
    return meta == 2 ? -1F : super.getBlockHardness(par1World, par2, par3, par4);
  }

  @Override
  public TileCamo createNewTileEntity(World world, int meta) {
    return new TilePlatform();
  }

  @Override
  public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
    int meta = world.getBlockMetadata(x, y, z);
    return meta == 0 ? LexiconData.platform : meta == 2 ? null : LexiconData.spectralPlatform;
  }

  @Override
  public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
    TilePlatform tile = (TilePlatform) world.getTileEntity(x, y, z);
    return tile.onWanded(player);
  }

}
TOP

Related Classes of vazkii.botania.common.block.BlockPlatform

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.