Esempio n. 1
0
  @Override
  public void onBlockAdded(World worldIn, net.minecraft.util.math.BlockPos pos, IBlockState state) {
    super.onBlockAdded(worldIn, pos, state);
    int rng = Reference.RANDOM.nextInt(3);
    EnumType enumType = EnumType.byMetadata(rng);

    IBlockState outState = state.withProperty(BlockCrystal.PROPERTY_ENUM, enumType);

    worldIn.setBlockState(pos, outState);

    TileSource crystal = (TileSource) worldIn.getTileEntity(pos);
    crystal.setScanMode();
  }
Esempio n. 2
0
 @Override
 public boolean onBlockActivated(
     World worldIn,
     BlockPos pos,
     IBlockState state,
     EntityPlayer playerIn,
     EnumHand hand,
     @Nullable ItemStack heldItem,
     EnumFacing side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!worldIn.isRemote) {
     TileSource tileSource = (TileSource) worldIn.getTileEntity(pos);
     HashMap<Block, List<BlockLocation>> densityMap = tileSource.getMap();
     densityMap.forEach(
         (block, blockLocations) -> {
           playerIn.addChatComponentMessage(
               new TextComponentString(block.getUnlocalizedName() + ":" + blockLocations.size()));
         });
   }
   return super.onBlockActivated(
       worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
 }