2020-09-09 16:49:01 +02:00
|
|
|
package de.ellpeck.actuallyadditions.common.blocks;
|
2017-02-13 23:17:08 +01:00
|
|
|
|
2020-09-09 16:49:01 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.items.metalists.TheCrystals;
|
|
|
|
import de.ellpeck.actuallyadditions.common.util.IColorProvidingBlock;
|
|
|
|
import de.ellpeck.actuallyadditions.common.util.IColorProvidingItem;
|
2020-09-09 09:58:55 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockState;
|
2017-02-13 23:17:08 +01:00
|
|
|
import net.minecraft.block.SoundType;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.color.IBlockColor;
|
|
|
|
import net.minecraft.client.renderer.color.IItemColor;
|
2020-09-09 09:58:55 +02:00
|
|
|
import net.minecraft.item.BlockItemUseContext;
|
|
|
|
import net.minecraft.state.StateContainer;
|
|
|
|
import net.minecraft.state.properties.BlockStateProperties;
|
2017-02-13 23:17:08 +01:00
|
|
|
import net.minecraft.util.Mirror;
|
|
|
|
import net.minecraft.util.Rotation;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2020-09-09 09:58:55 +02:00
|
|
|
import net.minecraft.world.IBlockReader;
|
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2017-02-13 23:17:08 +01:00
|
|
|
|
2020-09-08 00:46:45 +02:00
|
|
|
public class BlockCrystalCluster extends Block implements IColorProvidingBlock, IColorProvidingItem {
|
2017-02-13 23:17:08 +01:00
|
|
|
|
|
|
|
private final TheCrystals crystal;
|
|
|
|
|
2020-09-08 00:46:45 +02:00
|
|
|
public BlockCrystalCluster(TheCrystals crystal) {
|
|
|
|
super(Properties.create(Material.GLASS)
|
|
|
|
.hardnessAndResistance(0.25f, 1.0f)
|
|
|
|
.sound(SoundType.GLASS)
|
|
|
|
.lightValue(7));
|
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
this.crystal = crystal;
|
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos){
|
|
|
|
return 1;
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public BlockState getStateForPlacement(BlockItemUseContext context){
|
|
|
|
return super.getStateForPlacement(context).with(BlockStateProperties.FACING, context.getPlacementHorizontalFacing().getOpposite());
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder){
|
|
|
|
builder.add(BlockStateProperties.FACING);
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public BlockState rotate(BlockState state, Rotation rot){
|
|
|
|
return state.with(BlockStateProperties.FACING, rot.rotate(state.get(BlockStateProperties.FACING)));
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public BlockState mirror(BlockState state, Mirror mirror){
|
|
|
|
return this.rotate(state, mirror.toRotation(state.get(BlockStateProperties.FACING)));
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBlockColor getBlockColor() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public IItemColor getItemColor() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
|
|
|
|
2020-09-09 09:58:55 +02:00
|
|
|
/* todo canitzp: realise block drops with loot tables
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public Item getItemDropped(BlockState state, Random rand, int fortune) {
|
2017-02-13 23:17:08 +01:00
|
|
|
return InitItems.itemCrystalShard;
|
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder){
|
|
|
|
return Collections.singletonList(new ItemStack(InitItems.itemCrystalShard, new Random().nextInt(5) + 2));
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-18 18:30:54 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public int damageDropped(BlockState state) {
|
|
|
|
return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this);
|
2017-02-18 18:30:54 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-13 23:17:08 +01:00
|
|
|
@Override
|
2020-09-09 09:58:55 +02:00
|
|
|
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player){
|
|
|
|
super.onBlockHarvested(worldIn, pos, state, player);
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|
2020-09-09 09:58:55 +02:00
|
|
|
|
2017-02-14 20:48:01 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
|
2017-02-14 20:48:01 +01:00
|
|
|
return true;
|
2020-09-09 09:58:55 +02:00
|
|
|
}*/
|
2017-02-13 23:17:08 +01:00
|
|
|
}
|