113 lines
3.4 KiB
Java
113 lines
3.4 KiB
Java
package WayofTime.bloodmagic.block;
|
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
|
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
|
import WayofTime.bloodmagic.tile.TileDemonCrucible;
|
|
import WayofTime.bloodmagic.util.Utils;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.EnumBlockRenderType;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.EnumHand;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
import javax.annotation.Nullable;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock {
|
|
public BlockDemonCrucible() {
|
|
super(Material.ROCK);
|
|
|
|
setUnlocalizedName(BloodMagic.MODID + ".demonCrucible");
|
|
setCreativeTab(BloodMagic.TAB_BM);
|
|
setHardness(2.0F);
|
|
setResistance(5.0F);
|
|
setHarvestLevel("pickaxe", 0);
|
|
|
|
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
|
}
|
|
|
|
@Override
|
|
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube(IBlockState state) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean causesSuffocation(IBlockState state) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public EnumBlockRenderType getRenderType(IBlockState state) {
|
|
return EnumBlockRenderType.MODEL;
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
|
ItemStack heldItem = player.getHeldItem(hand);
|
|
TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos);
|
|
|
|
if (crucible == null || player.isSneaking())
|
|
return false;
|
|
|
|
if (!heldItem.isEmpty()) {
|
|
if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
Utils.insertItemToTile(crucible, player);
|
|
|
|
world.notifyBlockUpdate(pos, state, state, 3);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
|
|
TileDemonCrucible tile = (TileDemonCrucible) world.getTileEntity(blockPos);
|
|
if (tile != null)
|
|
tile.dropItems();
|
|
|
|
super.breakBlock(world, blockPos, blockState);
|
|
}
|
|
|
|
@Override
|
|
public boolean hasTileEntity(IBlockState state) {
|
|
return true;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
|
return new TileDemonCrucible();
|
|
}
|
|
|
|
@Override
|
|
public void populateVariants(Int2ObjectMap<String> variants) {
|
|
variants.put(0, "normal");
|
|
}
|
|
|
|
@Override
|
|
public ItemBlock getItem() {
|
|
return new ItemBlock(this);
|
|
}
|
|
}
|