2017-02-13 23:17:08 +01:00
|
|
|
/*
|
|
|
|
* This file ("BlockCrystalCluster.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://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015-2017 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
|
|
|
|
import net.minecraft.block.BlockDirectional;
|
|
|
|
import net.minecraft.block.SoundType;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.client.renderer.color.IBlockColor;
|
|
|
|
import net.minecraft.client.renderer.color.IItemColor;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2017-02-14 20:48:01 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2017-02-13 23:17:08 +01:00
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.Mirror;
|
|
|
|
import net.minecraft.util.Rotation;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem{
|
|
|
|
|
|
|
|
private final TheCrystals crystal;
|
|
|
|
|
|
|
|
public BlockCrystalCluster(String name, TheCrystals crystal){
|
|
|
|
super(Material.GLASS, name);
|
|
|
|
this.crystal = crystal;
|
|
|
|
|
|
|
|
this.setHardness(0.25F);
|
|
|
|
this.setResistance(1.0F);
|
|
|
|
this.setSoundType(SoundType.GLASS);
|
|
|
|
this.setLightOpacity(1);
|
|
|
|
this.setLightLevel(0.7F);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFullCube(IBlockState state){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube(IBlockState state){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){
|
|
|
|
return this.getStateFromMeta(side.ordinal());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
return EnumRarity.EPIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState getStateFromMeta(int meta){
|
|
|
|
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.getFront(meta));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMetaFromState(IBlockState state){
|
|
|
|
return state.getValue(BlockDirectional.FACING).getIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected BlockStateContainer createBlockState(){
|
|
|
|
return new BlockStateContainer(this, BlockDirectional.FACING);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState withRotation(IBlockState state, Rotation rot){
|
|
|
|
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState withMirror(IBlockState state, Mirror mirror){
|
|
|
|
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IBlockColor getBlockColor(){
|
|
|
|
return new IBlockColor(){
|
|
|
|
@Override
|
|
|
|
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex){
|
|
|
|
return BlockCrystalCluster.this.crystal.clusterColor;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public BlockRenderLayer getBlockLayer(){
|
|
|
|
return BlockRenderLayer.TRANSLUCENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IItemColor getItemColor(){
|
|
|
|
return new IItemColor(){
|
|
|
|
@Override
|
|
|
|
public int getColorFromItemstack(ItemStack stack, int tintIndex){
|
|
|
|
return BlockCrystalCluster.this.crystal.clusterColor;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Item getItemDropped(IBlockState state, Random rand, int fortune){
|
|
|
|
return InitItems.itemCrystalShard;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int damageDropped(IBlockState state){
|
|
|
|
return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int quantityDropped(Random random){
|
|
|
|
return random.nextInt(5)+2;
|
|
|
|
}
|
2017-02-14 20:48:01 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){
|
|
|
|
return true;
|
|
|
|
}
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|