mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-05 08:29:09 +01:00
146 lines
No EOL
4.7 KiB
Java
146 lines
No EOL
4.7 KiB
Java
/*
|
|
* 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 java.util.Random;
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
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;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
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.util.math.RayTraceResult;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
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.byIndex(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 (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
|
|
}
|
|
|
|
@Override
|
|
public BlockRenderLayer getRenderLayer() {
|
|
return BlockRenderLayer.TRANSLUCENT;
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IItemColor getItemColor() {
|
|
return (stack, tintIndex) -> 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 ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
|
return new ItemStack(this);
|
|
}
|
|
|
|
@Override
|
|
public int quantityDropped(Random random) {
|
|
return random.nextInt(5) + 2;
|
|
}
|
|
|
|
@Override
|
|
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
|
|
return true;
|
|
}
|
|
} |