ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/blocks/BlockLaserRelay.java

114 lines
3.5 KiB
Java
Raw Normal View History

2015-10-18 19:21:32 +02:00
/*
* This file ("BlockLaserRelay.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2015-11-02 20:55:19 +01:00
* © 2015 Ellpeck
2015-10-18 19:21:32 +02:00
*/
2015-12-30 22:02:15 +01:00
package de.ellpeck.actuallyadditions.blocks;
2015-10-18 19:21:32 +02:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2015-12-30 22:02:15 +01:00
import de.ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.util.AssetUtil;
2015-10-18 19:21:32 +02:00
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
2015-10-18 19:21:32 +02:00
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
2015-10-18 19:21:32 +02:00
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
2015-10-18 19:21:32 +02:00
import net.minecraft.world.World;
import java.util.List;
public class BlockLaserRelay extends BlockContainerBase{
2015-10-18 19:21:32 +02:00
public BlockLaserRelay(String name){
super(Material.rock, name);
2015-10-18 19:21:32 +02:00
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, axis, list, entity);
}
@Override
2015-10-18 19:21:32 +02:00
public boolean renderAsNormalBlock(){
return false;
}
@Override
public int getRenderType(){
return AssetUtil.laserRelayRenderId;
2015-10-18 19:21:32 +02:00
}
@Override
2015-10-28 14:46:04 +01:00
@SideOnly(Side.CLIENT)
2015-10-18 19:21:32 +02:00
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
}
@Override
public boolean isOpaqueCube(){
return false;
}
2015-10-23 16:54:33 +02:00
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata){
return side;
}
2015-12-19 10:30:39 +01:00
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
int meta = world.getBlockMetadata(x, y, z);
float pixel = 1F/16F;
if(meta == 0){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F, 1F-3*pixel);
}
else if(meta == 1){
this.setBlockBounds(3*pixel, 0F, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 2){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F);
}
else if(meta == 3){
this.setBlockBounds(3*pixel, 3*pixel, 0F, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 4){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 5){
this.setBlockBounds(0F, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
}
2015-10-18 19:21:32 +02:00
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.stone.getIcon(0, 0);
2015-10-18 19:21:32 +02:00
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
2015-10-18 19:21:32 +02:00
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityLaserRelay();
2015-10-18 19:21:32 +02:00
}
}